Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / ndp / fx / src / Sys / System / Configuration / SettingsPropertyCollection.cs / 1 / SettingsPropertyCollection.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Configuration { using System.Collections; using System.Collections.Specialized; using System.Runtime.Serialization; using System.Configuration.Provider; using System.Globalization; using System.IO; using System.Runtime.Serialization.Formatters.Binary; using System.Xml.Serialization; using System.ComponentModel; //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// public class SettingsPropertyCollection : IEnumerable, ICloneable, ICollection { private Hashtable _Hashtable = null; private bool _ReadOnly = false; //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// public SettingsPropertyCollection() { _Hashtable = new Hashtable(10, CaseInsensitiveHashCodeProvider.Default, CaseInsensitiveComparer.Default); } //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// public void Add(SettingsProperty property) { if (_ReadOnly) throw new NotSupportedException(); OnAdd(property); _Hashtable.Add(property.Name, property); try { OnAddComplete(property); } catch { _Hashtable.Remove(property.Name); throw; } } //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// public void Remove(string name) { if (_ReadOnly) throw new NotSupportedException(); SettingsProperty toRemove = (SettingsProperty)_Hashtable[name]; if (toRemove == null) return; OnRemove(toRemove); _Hashtable.Remove(name); try { OnRemoveComplete(toRemove); } catch { _Hashtable.Add(name, toRemove); throw; } } //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// public SettingsProperty this[string name] { get { return _Hashtable[name] as SettingsProperty; } } //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// public IEnumerator GetEnumerator() { return _Hashtable.Values.GetEnumerator(); } //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// public object Clone() { return new SettingsPropertyCollection(_Hashtable); } //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// public void SetReadOnly() { if (_ReadOnly) return; _ReadOnly = true; } //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// public void Clear() { if (_ReadOnly) throw new NotSupportedException(); OnClear(); _Hashtable.Clear(); OnClearComplete(); } //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// // On* Methods for deriving classes to override. These have // been modeled after the CollectionBase class but have // been stripped of their "index" parameters as there is no // visible index to this collection. protected virtual void OnAdd(SettingsProperty property) {} protected virtual void OnAddComplete(SettingsProperty property) {} protected virtual void OnClear() {} protected virtual void OnClearComplete() {} protected virtual void OnRemove(SettingsProperty property) {} protected virtual void OnRemoveComplete(SettingsProperty property) {} //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// // ICollection interface public int Count { get { return _Hashtable.Count; } } public bool IsSynchronized { get { return false; } } public object SyncRoot { get { return this; } } public void CopyTo(Array array, int index) { _Hashtable.Values.CopyTo(array, index); } ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// private SettingsPropertyCollection(Hashtable h) { _Hashtable = (Hashtable)h.Clone(); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Configuration { using System.Collections; using System.Collections.Specialized; using System.Runtime.Serialization; using System.Configuration.Provider; using System.Globalization; using System.IO; using System.Runtime.Serialization.Formatters.Binary; using System.Xml.Serialization; using System.ComponentModel; //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// public class SettingsPropertyCollection : IEnumerable, ICloneable, ICollection { private Hashtable _Hashtable = null; private bool _ReadOnly = false; //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// public SettingsPropertyCollection() { _Hashtable = new Hashtable(10, CaseInsensitiveHashCodeProvider.Default, CaseInsensitiveComparer.Default); } //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// public void Add(SettingsProperty property) { if (_ReadOnly) throw new NotSupportedException(); OnAdd(property); _Hashtable.Add(property.Name, property); try { OnAddComplete(property); } catch { _Hashtable.Remove(property.Name); throw; } } //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// public void Remove(string name) { if (_ReadOnly) throw new NotSupportedException(); SettingsProperty toRemove = (SettingsProperty)_Hashtable[name]; if (toRemove == null) return; OnRemove(toRemove); _Hashtable.Remove(name); try { OnRemoveComplete(toRemove); } catch { _Hashtable.Add(name, toRemove); throw; } } //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// public SettingsProperty this[string name] { get { return _Hashtable[name] as SettingsProperty; } } //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// public IEnumerator GetEnumerator() { return _Hashtable.Values.GetEnumerator(); } //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// public object Clone() { return new SettingsPropertyCollection(_Hashtable); } //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// public void SetReadOnly() { if (_ReadOnly) return; _ReadOnly = true; } //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// public void Clear() { if (_ReadOnly) throw new NotSupportedException(); OnClear(); _Hashtable.Clear(); OnClearComplete(); } //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// // On* Methods for deriving classes to override. These have // been modeled after the CollectionBase class but have // been stripped of their "index" parameters as there is no // visible index to this collection. protected virtual void OnAdd(SettingsProperty property) {} protected virtual void OnAddComplete(SettingsProperty property) {} protected virtual void OnClear() {} protected virtual void OnClearComplete() {} protected virtual void OnRemove(SettingsProperty property) {} protected virtual void OnRemoveComplete(SettingsProperty property) {} //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// // ICollection interface public int Count { get { return _Hashtable.Count; } } public bool IsSynchronized { get { return false; } } public object SyncRoot { get { return this; } } public void CopyTo(Array array, int index) { _Hashtable.Values.CopyTo(array, index); } ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// private SettingsPropertyCollection(Hashtable h) { _Hashtable = (Hashtable)h.Clone(); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- Schema.cs
- Command.cs
- DocumentXPathNavigator.cs
- TextServicesPropertyRanges.cs
- EnvelopedPkcs7.cs
- Variable.cs
- MessageLoggingElement.cs
- TemplateKey.cs
- Debug.cs
- QilIterator.cs
- UseAttributeSetsAction.cs
- ProviderSettingsCollection.cs
- ParserOptions.cs
- DataControlFieldCollection.cs
- PersonalizableAttribute.cs
- IItemContainerGenerator.cs
- SpellerHighlightLayer.cs
- DirectionalLight.cs
- ColumnTypeConverter.cs
- RectAnimation.cs
- SelectedDatesCollection.cs
- LexicalChunk.cs
- SectionUpdates.cs
- TriggerCollection.cs
- GridViewUpdateEventArgs.cs
- DesignConnectionCollection.cs
- LayoutDump.cs
- PathFigure.cs
- ObjectSerializerFactory.cs
- PlainXmlSerializer.cs
- FormViewPagerRow.cs
- ScrollItemPatternIdentifiers.cs
- TextContainerChangedEventArgs.cs
- RowCache.cs
- CountdownEvent.cs
- Int16AnimationBase.cs
- shaperfactoryquerycachekey.cs
- ObjectStateManagerMetadata.cs
- DataGridCommandEventArgs.cs
- XmlNamespaceMappingCollection.cs
- ColumnHeaderConverter.cs
- PassportPrincipal.cs
- TextTabProperties.cs
- KeyNotFoundException.cs
- EventProviderWriter.cs
- Point3D.cs
- EntityDataSourceView.cs
- RIPEMD160Managed.cs
- AuthStoreRoleProvider.cs
- RemoveStoryboard.cs
- InputScope.cs
- ConfigurationManager.cs
- ActiveXHost.cs
- PartialTrustVisibleAssembliesSection.cs
- BoundColumn.cs
- IPEndPointCollection.cs
- WebServiceClientProxyGenerator.cs
- Site.cs
- SqlBulkCopy.cs
- PackagePartCollection.cs
- QuestionEventArgs.cs
- ObjectListCommandCollection.cs
- RawStylusSystemGestureInputReport.cs
- DesignerTransactionCloseEvent.cs
- OdbcPermission.cs
- VolatileResourceManager.cs
- RelationshipDetailsCollection.cs
- NameTable.cs
- Argument.cs
- TextBlock.cs
- XmlDictionaryString.cs
- BamlResourceContent.cs
- BaseTemplateBuildProvider.cs
- SettingsPropertyNotFoundException.cs
- TextTreeTextNode.cs
- GenerateTemporaryTargetAssembly.cs
- ConsoleKeyInfo.cs
- UnsafePeerToPeerMethods.cs
- UnsafeNativeMethods.cs
- MatrixAnimationBase.cs
- EditingMode.cs
- ColumnWidthChangingEvent.cs
- CallSiteHelpers.cs
- AtomServiceDocumentSerializer.cs
- TypographyProperties.cs
- HealthMonitoringSectionHelper.cs
- HashUtility.cs
- WhileDesigner.cs
- FormatterConverter.cs
- EncoderParameters.cs
- ResourceDefaultValueAttribute.cs
- SymLanguageVendor.cs
- BindingGroup.cs
- AspCompat.cs
- ApplicationSecurityInfo.cs
- ValueOfAction.cs
- RayHitTestParameters.cs
- CaseInsensitiveOrdinalStringComparer.cs
- NetWebProxyFinder.cs
- RemoteCryptoTokenProvider.cs