Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Configuration / System / Configuration / ProviderCollection.cs / 1305376 / ProviderCollection.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Configuration.Provider { using System.Collections; using System.Collections.Specialized; using System.Runtime.Serialization; ////// public class ProviderCollection : IEnumerable, ICollection //, ICloneable { private Hashtable _Hashtable = null; private bool _ReadOnly = false; //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// public ProviderCollection() { _Hashtable = new Hashtable(10, StringComparer.OrdinalIgnoreCase); } //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// public virtual void Add(ProviderBase provider) { if (_ReadOnly) throw new NotSupportedException(SR.GetString(SR.CollectionReadOnly)); if (provider == null) throw new ArgumentNullException("provider"); if (provider.Name == null || provider.Name.Length < 1) throw new ArgumentException(SR.GetString(SR.Config_provider_name_null_or_empty)); _Hashtable.Add(provider.Name, provider); } //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// public void Remove(string name) { if (_ReadOnly) throw new NotSupportedException(SR.GetString(SR.CollectionReadOnly)); _Hashtable.Remove(name); } //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// public ProviderBase this[string name] { get { return _Hashtable[name] as ProviderBase; } } //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// public IEnumerator GetEnumerator() { return _Hashtable.Values.GetEnumerator(); } //public object Clone(){ // return new ProviderCollection(_Indices, _Values); //} //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// public void SetReadOnly() { if (_ReadOnly) return; _ReadOnly = true; } //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// public void Clear() { if (_ReadOnly) throw new NotSupportedException(SR.GetString(SR.CollectionReadOnly)); _Hashtable.Clear(); } //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// // ICollection interface public int Count { get { return _Hashtable.Count; }} public bool IsSynchronized { get { return false; } } public object SyncRoot { get { return this; } } public void CopyTo(ProviderBase[] array, int index) { ((ICollection) this).CopyTo(array, index); } void ICollection.CopyTo(Array array, int index) { _Hashtable.Values.CopyTo(array, index); } #if UNUSED_CODE ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// private ProviderCollection(Hashtable h) { _Hashtable = (Hashtable)h.Clone(); } #endif } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //[To be supplied.] ///// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Configuration.Provider { using System.Collections; using System.Collections.Specialized; using System.Runtime.Serialization; ////// public class ProviderCollection : IEnumerable, ICollection //, ICloneable { private Hashtable _Hashtable = null; private bool _ReadOnly = false; //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// public ProviderCollection() { _Hashtable = new Hashtable(10, StringComparer.OrdinalIgnoreCase); } //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// public virtual void Add(ProviderBase provider) { if (_ReadOnly) throw new NotSupportedException(SR.GetString(SR.CollectionReadOnly)); if (provider == null) throw new ArgumentNullException("provider"); if (provider.Name == null || provider.Name.Length < 1) throw new ArgumentException(SR.GetString(SR.Config_provider_name_null_or_empty)); _Hashtable.Add(provider.Name, provider); } //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// public void Remove(string name) { if (_ReadOnly) throw new NotSupportedException(SR.GetString(SR.CollectionReadOnly)); _Hashtable.Remove(name); } //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// public ProviderBase this[string name] { get { return _Hashtable[name] as ProviderBase; } } //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// public IEnumerator GetEnumerator() { return _Hashtable.Values.GetEnumerator(); } //public object Clone(){ // return new ProviderCollection(_Indices, _Values); //} //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// public void SetReadOnly() { if (_ReadOnly) return; _ReadOnly = true; } //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// public void Clear() { if (_ReadOnly) throw new NotSupportedException(SR.GetString(SR.CollectionReadOnly)); _Hashtable.Clear(); } //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// // ICollection interface public int Count { get { return _Hashtable.Count; }} public bool IsSynchronized { get { return false; } } public object SyncRoot { get { return this; } } public void CopyTo(ProviderBase[] array, int index) { ((ICollection) this).CopyTo(array, index); } void ICollection.CopyTo(Array array, int index) { _Hashtable.Values.CopyTo(array, index); } #if UNUSED_CODE ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// private ProviderCollection(Hashtable h) { _Hashtable = (Hashtable)h.Clone(); } #endif } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.[To be supplied.] ///
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- XmlSchemaSimpleContentExtension.cs
- CapiNative.cs
- ShutDownListener.cs
- Inline.cs
- StatusStrip.cs
- RuntimeHelpers.cs
- PackWebResponse.cs
- GridViewSortEventArgs.cs
- FormsAuthenticationConfiguration.cs
- DecoderExceptionFallback.cs
- OdbcInfoMessageEvent.cs
- TaiwanLunisolarCalendar.cs
- UpdateManifestForBrowserApplication.cs
- XmlSchemaValidationException.cs
- Compiler.cs
- InsufficientExecutionStackException.cs
- UnsignedPublishLicense.cs
- GlobalAllocSafeHandle.cs
- WindowsRebar.cs
- ApplicationFileCodeDomTreeGenerator.cs
- RuntimeWrappedException.cs
- DataViewManager.cs
- SubMenuStyleCollection.cs
- Int32Converter.cs
- SkewTransform.cs
- SymbolMethod.cs
- DataMemberConverter.cs
- AmbientProperties.cs
- DataViewSetting.cs
- followingsibling.cs
- DataGridCell.cs
- _NestedMultipleAsyncResult.cs
- EntityObject.cs
- ClientUIRequest.cs
- DataGridHeaderBorder.cs
- InkPresenter.cs
- TextDecorations.cs
- XPathNodePointer.cs
- EventProviderClassic.cs
- DataGridColumnStyleMappingNameEditor.cs
- ConnectionPointGlyph.cs
- HttpClientCertificate.cs
- CheckBoxField.cs
- CheckBoxDesigner.cs
- ProxyWebPartConnectionCollection.cs
- ControlPaint.cs
- Bits.cs
- HtmlInputImage.cs
- ImageSourceConverter.cs
- AttributeEmitter.cs
- XmlArrayItemAttributes.cs
- AutomationElementIdentifiers.cs
- GridErrorDlg.cs
- ComboBoxAutomationPeer.cs
- WorkflowOperationErrorHandler.cs
- RuleInfoComparer.cs
- BamlLocalizabilityResolver.cs
- ConnectionPoint.cs
- LayeredChannelFactory.cs
- UseLicense.cs
- MetadataArtifactLoaderComposite.cs
- ServiceOperation.cs
- ObjectItemCollectionAssemblyCacheEntry.cs
- UIElementPropertyUndoUnit.cs
- Geometry3D.cs
- DefaultHttpHandler.cs
- SimpleTypeResolver.cs
- DataPagerFieldCommandEventArgs.cs
- FileSystemWatcher.cs
- ListViewItem.cs
- HttpApplicationStateWrapper.cs
- Paragraph.cs
- ReadOnlyTernaryTree.cs
- PageRanges.cs
- StoragePropertyMapping.cs
- PointF.cs
- XmlEnumAttribute.cs
- FixedDSBuilder.cs
- WindowsScroll.cs
- HttpHandlerActionCollection.cs
- UserControl.cs
- _NetRes.cs
- FontUnit.cs
- HttpHandlersSection.cs
- PolicyManager.cs
- EntityProviderServices.cs
- AnnotationHelper.cs
- XmlParserContext.cs
- Label.cs
- FrameworkTemplate.cs
- CngKey.cs
- ZipPackagePart.cs
- ConfigurationValues.cs
- SmiEventSink_Default.cs
- KeyPullup.cs
- CodeMemberField.cs
- ObjectHandle.cs
- KeySpline.cs
- GZipDecoder.cs
- PlainXmlWriter.cs