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
- StructuralObject.cs
- ErrorHandlerModule.cs
- SerializationTrace.cs
- DataGridrowEditEndingEventArgs.cs
- TrackPointCollection.cs
- UDPClient.cs
- LabelDesigner.cs
- ObjectAssociationEndMapping.cs
- TagNameToTypeMapper.cs
- TextDecorationCollection.cs
- ProviderBase.cs
- Pkcs7Signer.cs
- FileEnumerator.cs
- SecuritySessionClientSettings.cs
- CellParaClient.cs
- ScrollBar.cs
- ServiceOperationDetailViewControl.cs
- SendMailErrorEventArgs.cs
- PingOptions.cs
- BasicExpressionVisitor.cs
- CompilationSection.cs
- SqlConnectionHelper.cs
- _RegBlobWebProxyDataBuilder.cs
- WebPartChrome.cs
- CodeConstructor.cs
- BitmapMetadata.cs
- SamlDoNotCacheCondition.cs
- ActivationServices.cs
- CounterCreationData.cs
- TrackBarRenderer.cs
- ImportException.cs
- ListCollectionView.cs
- DataTableCollection.cs
- SchemaImporterExtensionsSection.cs
- XsdBuilder.cs
- SafeNativeMethods.cs
- MarkupCompilePass2.cs
- HttpInputStream.cs
- VersionUtil.cs
- ConsoleKeyInfo.cs
- BindingsCollection.cs
- MimeMapping.cs
- XPathDocumentNavigator.cs
- AtomicFile.cs
- BinaryFormatterWriter.cs
- Timer.cs
- ReflectionTypeLoadException.cs
- XmlElement.cs
- CLSCompliantAttribute.cs
- MarshalByRefObject.cs
- DateTimeUtil.cs
- ToolStripProfessionalLowResolutionRenderer.cs
- ImageCodecInfoPrivate.cs
- StringFunctions.cs
- DataDocumentXPathNavigator.cs
- BitVector32.cs
- QuarticEase.cs
- PtsCache.cs
- DataGridViewButtonColumn.cs
- MetadataHelper.cs
- DataObjectMethodAttribute.cs
- XPathNodeList.cs
- ParameterCollection.cs
- ListViewPagedDataSource.cs
- GeometryGroup.cs
- CompatibleIComparer.cs
- ApplicationInfo.cs
- X509InitiatorCertificateClientElement.cs
- DoubleAnimationClockResource.cs
- EdgeProfileValidation.cs
- DataBoundControlAdapter.cs
- __ConsoleStream.cs
- RightsManagementPermission.cs
- Function.cs
- ParseHttpDate.cs
- MachineKeySection.cs
- SqlBulkCopyColumnMapping.cs
- Expressions.cs
- DBCommand.cs
- ResourceContainerWrapper.cs
- StrongNameKeyPair.cs
- DataGridCellItemAutomationPeer.cs
- StorageEndPropertyMapping.cs
- EditorBrowsableAttribute.cs
- RouteTable.cs
- Schema.cs
- DataGridViewSelectedRowCollection.cs
- PerfCounterSection.cs
- FilterException.cs
- HitTestParameters.cs
- ConnectionProviderAttribute.cs
- XmlDownloadManager.cs
- PixelFormatConverter.cs
- JsonServiceDocumentSerializer.cs
- IItemContainerGenerator.cs
- CodeFieldReferenceExpression.cs
- TemplatingOptionsDialog.cs
- ItemAutomationPeer.cs
- WorkflowMarkupSerializerMapping.cs
- SchemaImporterExtension.cs