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
- DynamicDataRouteHandler.cs
- ChangePassword.cs
- InputScopeAttribute.cs
- EventLogPermissionEntry.cs
- MouseGesture.cs
- RtfControlWordInfo.cs
- FontFamily.cs
- PresentationTraceSources.cs
- _FtpDataStream.cs
- RequestCacheManager.cs
- BrowserPolicyValidator.cs
- BlobPersonalizationState.cs
- UIElementAutomationPeer.cs
- XmlSchemaSimpleContentRestriction.cs
- ScriptComponentDescriptor.cs
- WhitespaceRuleLookup.cs
- ControlPaint.cs
- JpegBitmapEncoder.cs
- TripleDES.cs
- ValidatingCollection.cs
- StylusPointProperty.cs
- DataServiceHostFactory.cs
- MenuEventArgs.cs
- XhtmlBasicLinkAdapter.cs
- TableCell.cs
- DataGridPagingPage.cs
- AssemblyNameProxy.cs
- XmlLanguage.cs
- HttpRequestWrapper.cs
- ViewPort3D.cs
- XmlSchemaSimpleTypeRestriction.cs
- CompensationDesigner.cs
- RewritingSimplifier.cs
- SoundPlayer.cs
- WebPartEditorOkVerb.cs
- RightsManagementPermission.cs
- XmlNodeReader.cs
- DataKeyArray.cs
- SpoolingTaskBase.cs
- WinEventWrap.cs
- DrawingState.cs
- remotingproxy.cs
- _ProxyChain.cs
- XamlParser.cs
- Comparer.cs
- PixelFormats.cs
- LinqDataSourceContextEventArgs.cs
- IsolatedStorageFile.cs
- LinqDataSourceInsertEventArgs.cs
- Parameter.cs
- InternalSendMessage.cs
- Util.cs
- CheckBoxField.cs
- MissingManifestResourceException.cs
- ReflectionUtil.cs
- SimpleRecyclingCache.cs
- PersonalizationStateInfoCollection.cs
- HelpExampleGenerator.cs
- LineBreak.cs
- ImageButton.cs
- DataColumnMapping.cs
- GraphicsPath.cs
- MessageBox.cs
- ColumnTypeConverter.cs
- BaseInfoTable.cs
- DataRelationCollection.cs
- XmlSchemaComplexType.cs
- UniformGrid.cs
- mediapermission.cs
- PopupEventArgs.cs
- FormattedText.cs
- ToolStripSeparatorRenderEventArgs.cs
- AccessorTable.cs
- TdsValueSetter.cs
- TableRow.cs
- COM2EnumConverter.cs
- IgnoreSectionHandler.cs
- RecognitionResult.cs
- CacheMode.cs
- ChangePassword.cs
- Brush.cs
- InkCanvasInnerCanvas.cs
- EndpointInfo.cs
- DataErrorValidationRule.cs
- XmlArrayItemAttributes.cs
- WeakReadOnlyCollection.cs
- SQLInt16.cs
- PrivilegedConfigurationManager.cs
- SessionPageStateSection.cs
- EventlogProvider.cs
- EncryptedXml.cs
- CodeConditionStatement.cs
- ListView.cs
- SurrogateSelector.cs
- ReadContentAsBinaryHelper.cs
- ComboBoxRenderer.cs
- HttpServerVarsCollection.cs
- WSHttpBindingBaseElement.cs
- ApplicationId.cs
- ProviderConnectionPoint.cs