Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / 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
- CompressEmulationStream.cs
- XslNumber.cs
- DynamicExpression.cs
- DBCSCodePageEncoding.cs
- InstanceDescriptor.cs
- FaultDesigner.cs
- ObjectCloneHelper.cs
- AnimatedTypeHelpers.cs
- SrgsRule.cs
- GeneralTransform3D.cs
- JsonDeserializer.cs
- ListControlActionList.cs
- SecondaryIndexList.cs
- ValidationHelper.cs
- DataControlImageButton.cs
- TypeSystemProvider.cs
- InstanceDataCollectionCollection.cs
- FocusTracker.cs
- OrderedDictionary.cs
- TextMarkerSource.cs
- Main.cs
- TraceContextEventArgs.cs
- FrameworkContentElement.cs
- FormatPage.cs
- DocumentOrderComparer.cs
- ComNativeDescriptor.cs
- BitmapSource.cs
- CustomCategoryAttribute.cs
- TableChangeProcessor.cs
- EmbeddedMailObjectsCollection.cs
- EncodingDataItem.cs
- OLEDB_Enum.cs
- BaseTemplateCodeDomTreeGenerator.cs
- RuleProcessor.cs
- SchemaMapping.cs
- ObjectDisposedException.cs
- HttpListenerRequest.cs
- SqlInfoMessageEvent.cs
- ReadOnlyObservableCollection.cs
- HttpResponseBase.cs
- CuspData.cs
- OracleDataReader.cs
- AddressHeaderCollection.cs
- TimeSpanConverter.cs
- Hash.cs
- ListenerElementsCollection.cs
- Sentence.cs
- ObjectKeyFrameCollection.cs
- EdmItemCollection.OcAssemblyCache.cs
- CheckoutException.cs
- HScrollProperties.cs
- FixedSOMSemanticBox.cs
- Binding.cs
- CodeCommentStatement.cs
- Attachment.cs
- SolidBrush.cs
- GPStream.cs
- GeneralTransform.cs
- WeakHashtable.cs
- ExtenderHelpers.cs
- DataPagerCommandEventArgs.cs
- ProvidersHelper.cs
- ParameterBuilder.cs
- ServiceBusyException.cs
- DataGridViewElement.cs
- ObjectMemberMapping.cs
- XmlArrayItemAttribute.cs
- SolidColorBrush.cs
- DiscreteKeyFrames.cs
- UInt32Converter.cs
- UpdateManifestForBrowserApplication.cs
- SqlCaseSimplifier.cs
- ToolStripControlHost.cs
- GenericEnumerator.cs
- XPathEmptyIterator.cs
- ObjectViewFactory.cs
- XmlSchemaObjectCollection.cs
- DefaultHttpHandler.cs
- ActivityDesigner.cs
- GeometryGroup.cs
- OutOfMemoryException.cs
- MarkupExtensionParser.cs
- PageThemeParser.cs
- WebControlParameterProxy.cs
- CreateUserErrorEventArgs.cs
- FrugalMap.cs
- SourceElementsCollection.cs
- MultipartContentParser.cs
- HttpCapabilitiesEvaluator.cs
- SqlNodeAnnotation.cs
- SerialErrors.cs
- SortedDictionary.cs
- CssTextWriter.cs
- WebOperationContext.cs
- DefaultValueConverter.cs
- MsmqIntegrationElement.cs
- XamlPointCollectionSerializer.cs
- XmlAttributeHolder.cs
- TableDetailsRow.cs
- PrivilegeNotHeldException.cs