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
- LicenseManager.cs
- ListParagraph.cs
- PersonalizationProviderHelper.cs
- SkewTransform.cs
- ThreadStartException.cs
- SmiConnection.cs
- ExeConfigurationFileMap.cs
- UnmanagedMemoryStreamWrapper.cs
- TripleDESCryptoServiceProvider.cs
- SiteMapNodeItem.cs
- SqlGenericUtil.cs
- TextDecorationCollectionConverter.cs
- ScriptingProfileServiceSection.cs
- EntityStoreSchemaGenerator.cs
- ConstraintStruct.cs
- XmlNamespaceDeclarationsAttribute.cs
- PointCollectionValueSerializer.cs
- UserNameSecurityTokenAuthenticator.cs
- XPathConvert.cs
- AudioFormatConverter.cs
- ManagementException.cs
- UpdateTranslator.cs
- OletxDependentTransaction.cs
- HighlightVisual.cs
- WebBrowserContainer.cs
- XmlILConstructAnalyzer.cs
- InstanceLockLostException.cs
- ResponseBodyWriter.cs
- DrawingImage.cs
- WindowsFormsHost.cs
- ProcessModelInfo.cs
- CheckedPointers.cs
- AssemblyInfo.cs
- AlphabeticalEnumConverter.cs
- COM2ICategorizePropertiesHandler.cs
- SweepDirectionValidation.cs
- FormsIdentity.cs
- CroppedBitmap.cs
- Trigger.cs
- FilterElement.cs
- AttachedPropertyMethodSelector.cs
- DrawingAttributeSerializer.cs
- ExclusiveCanonicalizationTransform.cs
- StorageAssociationTypeMapping.cs
- AnnotationHelper.cs
- SafeRightsManagementHandle.cs
- ZipIOCentralDirectoryBlock.cs
- ConditionalAttribute.cs
- CodeAttributeDeclarationCollection.cs
- EntityViewContainer.cs
- ConditionalAttribute.cs
- CacheSection.cs
- XPathMessageFilterElement.cs
- BitmapSource.cs
- InstanceOwnerQueryResult.cs
- ColumnWidthChangingEvent.cs
- RemotingConfigParser.cs
- ListChangedEventArgs.cs
- FixedPageAutomationPeer.cs
- RequestResizeEvent.cs
- ComplexLine.cs
- NetworkInformationException.cs
- DataViewSettingCollection.cs
- LogWriteRestartAreaAsyncResult.cs
- Enum.cs
- HtmlGenericControl.cs
- PersonalizablePropertyEntry.cs
- DashStyle.cs
- IntPtr.cs
- XMLDiffLoader.cs
- BoundField.cs
- EditorZone.cs
- AnnotationHighlightLayer.cs
- DatePickerAutomationPeer.cs
- PersistencePipeline.cs
- _ChunkParse.cs
- Win32SafeHandles.cs
- filewebrequest.cs
- ExportException.cs
- PerspectiveCamera.cs
- MultiBinding.cs
- ContainsRowNumberChecker.cs
- TransportationConfigurationTypeInstallComponent.cs
- RegexWriter.cs
- WebPartDeleteVerb.cs
- ValidationError.cs
- translator.cs
- BehaviorService.cs
- CustomValidator.cs
- HMAC.cs
- OleDbPropertySetGuid.cs
- InlineUIContainer.cs
- FileSystemEnumerable.cs
- FutureFactory.cs
- DbConnectionPoolOptions.cs
- StylusEditingBehavior.cs
- ConstNode.cs
- StringTraceRecord.cs
- ProxyWebPartManager.cs
- InputLangChangeEvent.cs