Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Sys / System / Configuration / SettingsPropertyCollection.cs / 1305376 / 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, StringComparer.CurrentCultureIgnoreCase); } //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// 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, StringComparer.CurrentCultureIgnoreCase); } //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// 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
- CopyNodeSetAction.cs
- ResourcePermissionBase.cs
- ParallelTimeline.cs
- DataStreamFromComStream.cs
- FlowDocumentView.cs
- Visitors.cs
- EntityContainerEntitySetDefiningQuery.cs
- XmlDictionaryReaderQuotas.cs
- ReflectionTypeLoadException.cs
- DataControlFieldsEditor.cs
- WS2007HttpBinding.cs
- shaperfactoryquerycachekey.cs
- HttpNamespaceReservationInstallComponent.cs
- SkipStoryboardToFill.cs
- SafeNativeMethods.cs
- RootProfilePropertySettingsCollection.cs
- VBIdentifierTrimConverter.cs
- DataGridTextBoxColumn.cs
- WebPart.cs
- ClientConfigurationSystem.cs
- ResourceDescriptionAttribute.cs
- TableChangeProcessor.cs
- ListItemCollection.cs
- DefaultIfEmptyQueryOperator.cs
- FixedStringLookup.cs
- XmlTextReaderImpl.cs
- TableRow.cs
- UpdatePanel.cs
- OuterGlowBitmapEffect.cs
- SafeFileMapViewHandle.cs
- StatusStrip.cs
- ModelChangedEventArgsImpl.cs
- DataServiceEntityAttribute.cs
- OAVariantLib.cs
- SelectionBorderGlyph.cs
- Solver.cs
- TaskCanceledException.cs
- XmlHierarchicalEnumerable.cs
- SafeNativeMemoryHandle.cs
- RelatedEnd.cs
- IOException.cs
- Int16AnimationBase.cs
- ZipIOLocalFileHeader.cs
- CodeGen.cs
- WebHeaderCollection.cs
- StandardBindingElementCollection.cs
- MaxMessageSizeStream.cs
- StrokeRenderer.cs
- RuntimeConfigLKG.cs
- JsonStringDataContract.cs
- CharConverter.cs
- DesignerSerializationOptionsAttribute.cs
- Page.cs
- TreeNode.cs
- ExpressionBuilderContext.cs
- ExtentJoinTreeNode.cs
- DataGridRowAutomationPeer.cs
- QueryStringParameter.cs
- TextBounds.cs
- RemotingConfiguration.cs
- System.Data.OracleClient_BID.cs
- DelegatingTypeDescriptionProvider.cs
- DbgCompiler.cs
- InputLanguageManager.cs
- HttpHandlerActionCollection.cs
- ProfilePropertyNameValidator.cs
- SessionIDManager.cs
- Funcletizer.cs
- FileUtil.cs
- SubpageParaClient.cs
- ModulesEntry.cs
- XamlFigureLengthSerializer.cs
- PageAsyncTaskManager.cs
- WebBrowserSiteBase.cs
- FileLoadException.cs
- ColorDialog.cs
- Keyboard.cs
- BaseTemplateBuildProvider.cs
- XhtmlBasicValidatorAdapter.cs
- WorkflowTransactionService.cs
- NetworkInformationPermission.cs
- AutomationProperties.cs
- ErrorTableItemStyle.cs
- ProcessHostFactoryHelper.cs
- FixedSOMTable.cs
- FormViewCommandEventArgs.cs
- XmlObjectSerializerWriteContext.cs
- FileDialog_Vista.cs
- ChannelEndpointElementCollection.cs
- Point3D.cs
- KeyTimeConverter.cs
- UnsafeNetInfoNativeMethods.cs
- ScaleTransform3D.cs
- QilReplaceVisitor.cs
- QilParameter.cs
- XmlCountingReader.cs
- CaseDesigner.xaml.cs
- TraceContextEventArgs.cs
- ByteRangeDownloader.cs
- ValidateNames.cs