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
- HttpWebRequest.cs
- RecognizedAudio.cs
- Wildcard.cs
- CultureTable.cs
- HorizontalAlignConverter.cs
- PeerApplicationLaunchInfo.cs
- SimpleWebHandlerParser.cs
- __FastResourceComparer.cs
- DocComment.cs
- TriggerCollection.cs
- BooleanProjectedSlot.cs
- HttpListenerResponse.cs
- XmlTextReaderImplHelpers.cs
- ConfigurationManagerHelperFactory.cs
- Vector3DAnimation.cs
- DirectionalAction.cs
- TextSelectionHighlightLayer.cs
- RealProxy.cs
- SafeNativeMethods.cs
- TraceContextRecord.cs
- ReaderOutput.cs
- DataRecordInfo.cs
- SecurityContextTokenValidationException.cs
- PlatformCulture.cs
- AssociationTypeEmitter.cs
- DataAdapter.cs
- DataGrid.cs
- QueryCacheManager.cs
- CapabilitiesSection.cs
- ExpressionBuilderCollection.cs
- TreeNode.cs
- InitializerFacet.cs
- loginstatus.cs
- FileSystemEventArgs.cs
- PreservationFileWriter.cs
- ControlCachePolicy.cs
- DependencyObjectType.cs
- FilterableAttribute.cs
- _FixedSizeReader.cs
- counter.cs
- SecurityAlgorithmSuiteConverter.cs
- EntityDataSourceDesigner.cs
- LocalTransaction.cs
- DataGridViewComboBoxColumn.cs
- ToolBarPanel.cs
- XmlAtomicValue.cs
- WindowsRebar.cs
- Vector3DAnimationUsingKeyFrames.cs
- PersistencePipeline.cs
- GroupQuery.cs
- CodeMethodReturnStatement.cs
- ExtenderControl.cs
- ClientConfigurationHost.cs
- ClientScriptManager.cs
- BitHelper.cs
- OracleDateTime.cs
- MatrixAnimationUsingPath.cs
- QilNode.cs
- HtmlSelectionListAdapter.cs
- XamlTreeBuilderBamlRecordWriter.cs
- SiteOfOriginContainer.cs
- ISessionStateStore.cs
- BufferAllocator.cs
- XPathScanner.cs
- MSAAWinEventWrap.cs
- SecurityContext.cs
- OleDbConnection.cs
- TcpDuplicateContext.cs
- ExpandCollapsePatternIdentifiers.cs
- DrawingDrawingContext.cs
- DiscoveryExceptionDictionary.cs
- Quaternion.cs
- XmlSiteMapProvider.cs
- ZipIOZip64EndOfCentralDirectoryBlock.cs
- QuestionEventArgs.cs
- util.cs
- EventHandlerList.cs
- ColorContext.cs
- UnmanagedHandle.cs
- EventLogPermission.cs
- SchemaNotation.cs
- RuntimeConfigLKG.cs
- HyperLinkField.cs
- Invariant.cs
- BrushMappingModeValidation.cs
- VisualProxy.cs
- TempFiles.cs
- DbSource.cs
- ConfigXmlWhitespace.cs
- FloaterBaseParaClient.cs
- WinCategoryAttribute.cs
- ListChangedEventArgs.cs
- StructuredTypeEmitter.cs
- Message.cs
- HttpCapabilitiesSectionHandler.cs
- MappingMetadataHelper.cs
- StreamWriter.cs
- CodeMethodReturnStatement.cs
- HttpFileCollection.cs
- _SslSessionsCache.cs