Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / 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(); } } }
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DataControlPagerLinkButton.cs
- HMACSHA384.cs
- TextEndOfSegment.cs
- DataGridViewElement.cs
- PointHitTestParameters.cs
- RefreshEventArgs.cs
- PersianCalendar.cs
- SettingsContext.cs
- Object.cs
- ManagementPath.cs
- XmlAnyAttributeAttribute.cs
- SqlSelectStatement.cs
- HtmlForm.cs
- WriteTimeStream.cs
- NativeRecognizer.cs
- hresults.cs
- SamlAssertionDirectKeyIdentifierClause.cs
- CodeExpressionCollection.cs
- PersonalizableAttribute.cs
- DriveInfo.cs
- HostProtectionPermission.cs
- SafeWaitHandle.cs
- COM2ColorConverter.cs
- TargetFrameworkUtil.cs
- PropertyItemInternal.cs
- ToolStripDropDownDesigner.cs
- DoubleLinkList.cs
- Misc.cs
- OdbcException.cs
- ShaderRenderModeValidation.cs
- RangeValuePattern.cs
- DetailsViewInsertEventArgs.cs
- SettingsAttributes.cs
- SqlTypeConverter.cs
- ToolStripControlHost.cs
- SqlMultiplexer.cs
- HwndSourceParameters.cs
- XamlRtfConverter.cs
- PolicyFactory.cs
- CaseInsensitiveComparer.cs
- StringReader.cs
- AbsoluteQuery.cs
- PeerConnector.cs
- CorrelationActionMessageFilter.cs
- ServiceOperationInvoker.cs
- SerializationIncompleteException.cs
- InheritanceRules.cs
- HtmlProps.cs
- RawStylusInputCustomDataList.cs
- ProfileService.cs
- securitymgrsite.cs
- TableRowCollection.cs
- WCFBuildProvider.cs
- TargetInvocationException.cs
- Typeface.cs
- ComplexTypeEmitter.cs
- PkcsUtils.cs
- MemoryResponseElement.cs
- SkipStoryboardToFill.cs
- LayoutInformation.cs
- RegularExpressionValidator.cs
- Timer.cs
- CacheSection.cs
- XPathMultyIterator.cs
- TextElementAutomationPeer.cs
- InputBinding.cs
- Array.cs
- HtmlEmptyTagControlBuilder.cs
- _emptywebproxy.cs
- ResourceAttributes.cs
- PropertyFilterAttribute.cs
- TranslateTransform.cs
- AsymmetricKeyExchangeFormatter.cs
- ControlAdapter.cs
- TextBoxAutomationPeer.cs
- sortedlist.cs
- CanonicalizationDriver.cs
- TextTabProperties.cs
- DataObjectAttribute.cs
- MarshalDirectiveException.cs
- DesignSurfaceManager.cs
- SqlTypeSystemProvider.cs
- DataGridViewRowPrePaintEventArgs.cs
- PersonalizationProvider.cs
- CompModSwitches.cs
- PeerEndPoint.cs
- Int64Storage.cs
- SqlCacheDependencySection.cs
- ValidatedControlConverter.cs
- DesignerCategoryAttribute.cs
- DrawingBrush.cs
- ReceiveContext.cs
- Composition.cs
- ProfileServiceManager.cs
- EditorPart.cs
- SynchronousChannel.cs
- _UncName.cs
- Literal.cs
- AssemblyFilter.cs
- MoveSizeWinEventHandler.cs