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
- RotateTransform3D.cs
- RowUpdatedEventArgs.cs
- RuntimeConfig.cs
- Int32RectValueSerializer.cs
- MDIClient.cs
- SqlStream.cs
- SafeHandles.cs
- BamlLocalizerErrorNotifyEventArgs.cs
- DataGridViewCellLinkedList.cs
- ElementNotEnabledException.cs
- SQLInt64Storage.cs
- TcpProcessProtocolHandler.cs
- XmlUtf8RawTextWriter.cs
- ImplicitInputBrush.cs
- CommandPlan.cs
- XmlSchemaSet.cs
- ArrayItemReference.cs
- ConfigurationValues.cs
- FrugalList.cs
- ResourceDescriptionAttribute.cs
- basecomparevalidator.cs
- StatusBar.cs
- SaveFileDialog.cs
- FileDialogCustomPlace.cs
- BinaryCommonClasses.cs
- CircleHotSpot.cs
- StringFunctions.cs
- WmlValidationSummaryAdapter.cs
- FixedDocumentPaginator.cs
- PackagePartCollection.cs
- XslException.cs
- GeneralTransform3D.cs
- SingleObjectCollection.cs
- FilteredXmlReader.cs
- ResXResourceWriter.cs
- CheckBoxAutomationPeer.cs
- ListBoxDesigner.cs
- TextTrailingCharacterEllipsis.cs
- PartialToken.cs
- DesignerHelpers.cs
- ColorConverter.cs
- RequestBringIntoViewEventArgs.cs
- MsmqHostedTransportManager.cs
- BoolExpressionVisitors.cs
- SymmetricAlgorithm.cs
- isolationinterop.cs
- SequenceDesigner.cs
- Calendar.cs
- RefType.cs
- TriState.cs
- HtmlInputHidden.cs
- TextParaClient.cs
- SessionPageStateSection.cs
- contentDescriptor.cs
- RemoveFromCollection.cs
- ProcessHostMapPath.cs
- FileReservationCollection.cs
- TimeoutException.cs
- serverconfig.cs
- UniqueSet.cs
- XmlSchemaObject.cs
- ValidationSummary.cs
- CodeDOMUtility.cs
- NegatedCellConstant.cs
- SqlDataSource.cs
- XmlAttributeAttribute.cs
- DSACryptoServiceProvider.cs
- BinaryCommonClasses.cs
- WorkflowValidationFailedException.cs
- MatrixTransform3D.cs
- PackageDigitalSignatureManager.cs
- storepermissionattribute.cs
- DatePickerTextBox.cs
- StorageComplexTypeMapping.cs
- Config.cs
- TaskHelper.cs
- UnmanagedMemoryStreamWrapper.cs
- UnmanagedBitmapWrapper.cs
- WaitingCursor.cs
- EntityModelSchemaGenerator.cs
- MenuItemCollectionEditor.cs
- SystemIPGlobalProperties.cs
- ISAPIRuntime.cs
- ContentDesigner.cs
- EntityUtil.cs
- PropertyMapper.cs
- CompilerState.cs
- CustomPopupPlacement.cs
- TextDecoration.cs
- DSASignatureFormatter.cs
- BuildProvider.cs
- ChannelHandler.cs
- DBSchemaRow.cs
- OleDbParameterCollection.cs
- OutputScopeManager.cs
- TreeNodeCollection.cs
- Line.cs
- MatrixCamera.cs
- IdnMapping.cs
- ToolStripItemDesigner.cs