Code:
/ DotNET / DotNET / 8.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
- EnumBuilder.cs
- RequiredFieldValidator.cs
- ChtmlImageAdapter.cs
- DataRow.cs
- PriorityRange.cs
- ServiceModelPerformanceCounters.cs
- TemplateNameScope.cs
- SyntaxCheck.cs
- ExitEventArgs.cs
- GeneralTransform3DTo2D.cs
- VariableQuery.cs
- SubstitutionList.cs
- CollectionViewGroupInternal.cs
- CDSCollectionETWBCLProvider.cs
- Substitution.cs
- QilInvokeEarlyBound.cs
- DocumentViewerConstants.cs
- SetIterators.cs
- HostExecutionContextManager.cs
- HttpListenerRequest.cs
- ToolStripSplitStackLayout.cs
- MsmqIntegrationElement.cs
- PostBackTrigger.cs
- WebPartManager.cs
- RenderCapability.cs
- DropDownList.cs
- Win32.cs
- TypeBuilderInstantiation.cs
- ReadOnlyObservableCollection.cs
- QilIterator.cs
- UriTemplateClientFormatter.cs
- TypeReference.cs
- DataListCommandEventArgs.cs
- XsltArgumentList.cs
- ReadOnlyCollection.cs
- CompatibleIComparer.cs
- RectangleConverter.cs
- HyperLinkStyle.cs
- ThreadStartException.cs
- SafeCertificateContext.cs
- IntegerCollectionEditor.cs
- ZoneIdentityPermission.cs
- SystemNetworkInterface.cs
- RelatedImageListAttribute.cs
- CodeSnippetStatement.cs
- StagingAreaInputItem.cs
- CodeDOMProvider.cs
- Html32TextWriter.cs
- HashCryptoHandle.cs
- TouchesOverProperty.cs
- ToolZone.cs
- DataSourceConverter.cs
- RoutedEventArgs.cs
- RelatedEnd.cs
- AstTree.cs
- TimeoutHelper.cs
- DataServiceQueryOfT.cs
- AnnotationHighlightLayer.cs
- MenuCommands.cs
- PropertyPathConverter.cs
- ComponentCodeDomSerializer.cs
- SelectingProviderEventArgs.cs
- IfJoinedCondition.cs
- DataBoundControlActionList.cs
- DPCustomTypeDescriptor.cs
- UndoEngine.cs
- PlatformNotSupportedException.cs
- WebServiceReceiveDesigner.cs
- PeerInvitationResponse.cs
- SqlTopReducer.cs
- CroppedBitmap.cs
- RoutingEndpointTrait.cs
- LayoutTableCell.cs
- TransformProviderWrapper.cs
- WindowsUserNameSecurityTokenAuthenticator.cs
- ProxyHwnd.cs
- ResXResourceWriter.cs
- ExpanderAutomationPeer.cs
- TextTreeDeleteContentUndoUnit.cs
- NoneExcludedImageIndexConverter.cs
- Misc.cs
- BamlRecordWriter.cs
- CreateUserWizardStep.cs
- DrawListViewSubItemEventArgs.cs
- InputScopeManager.cs
- ContentDesigner.cs
- ISAPIWorkerRequest.cs
- KeyGestureConverter.cs
- TableParagraph.cs
- TempEnvironment.cs
- UrlPath.cs
- DockProviderWrapper.cs
- Size3D.cs
- FixedDocument.cs
- UnsafeNativeMethods.cs
- latinshape.cs
- ListManagerBindingsCollection.cs
- EllipseGeometry.cs
- SendingRequestEventArgs.cs
- PointLight.cs