Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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
- CookieProtection.cs
- TextCollapsingProperties.cs
- EntityDataSourceContextCreatedEventArgs.cs
- CuspData.cs
- elementinformation.cs
- PersonalizationProviderCollection.cs
- DataControlImageButton.cs
- VoiceObjectToken.cs
- HexParser.cs
- HealthMonitoringSectionHelper.cs
- DbParameterCollectionHelper.cs
- RegexBoyerMoore.cs
- ManipulationDelta.cs
- InstanceHandle.cs
- DataGridColumnHeaderCollection.cs
- RecordManager.cs
- ProxyWebPart.cs
- SQLByte.cs
- _ScatterGatherBuffers.cs
- XPathParser.cs
- TransformGroup.cs
- TargetControlTypeAttribute.cs
- ComplexLine.cs
- SafeArchiveContext.cs
- _Rfc2616CacheValidators.cs
- ProcessModuleDesigner.cs
- WindowsToolbarAsMenu.cs
- RegexCapture.cs
- TcpAppDomainProtocolHandler.cs
- IdleTimeoutMonitor.cs
- UnsafeMethods.cs
- NativeMethods.cs
- InfoCardRequestException.cs
- WebColorConverter.cs
- CompiledScopeCriteria.cs
- ProxyGenerator.cs
- SafePEFileHandle.cs
- PriorityItem.cs
- SearchExpression.cs
- BitmapSizeOptions.cs
- WebPartZoneCollection.cs
- UIPermission.cs
- Pts.cs
- LineGeometry.cs
- TypeProvider.cs
- HtmlInputRadioButton.cs
- UrlPath.cs
- SpellerHighlightLayer.cs
- DatePickerAutomationPeer.cs
- Stylus.cs
- SqlConnectionStringBuilder.cs
- ClassImporter.cs
- _UncName.cs
- ZipIOBlockManager.cs
- NamespaceList.cs
- ApplicationHost.cs
- ParallelEnumerableWrapper.cs
- EntityContainer.cs
- SymbolMethod.cs
- Int64KeyFrameCollection.cs
- OdbcCommand.cs
- SymmetricAlgorithm.cs
- RegexCapture.cs
- XmlAnyElementAttributes.cs
- PropertyRef.cs
- SoapSchemaMember.cs
- SelectionListComponentEditor.cs
- XmlLangPropertyAttribute.cs
- RemoteX509AsymmetricSecurityKey.cs
- HtmlHead.cs
- CounterCreationDataCollection.cs
- EntityClassGenerator.cs
- SID.cs
- ColorDialog.cs
- MasterPageBuildProvider.cs
- DataGridViewDesigner.cs
- SystemIPGlobalStatistics.cs
- XmlBinaryReaderSession.cs
- XmlKeywords.cs
- Lease.cs
- FormViewDeleteEventArgs.cs
- EventListener.cs
- SatelliteContractVersionAttribute.cs
- DockPattern.cs
- TextChangedEventArgs.cs
- SmiRequestExecutor.cs
- BeginStoryboard.cs
- _MultipleConnectAsync.cs
- MdiWindowListStrip.cs
- ImageFormat.cs
- SurrogateSelector.cs
- GridViewUpdateEventArgs.cs
- SqlXmlStorage.cs
- HtmlTitle.cs
- TableLayoutStyle.cs
- elementinformation.cs
- DrawingState.cs
- ResolvedKeyFrameEntry.cs
- securestring.cs
- CodeSubDirectoriesCollection.cs