Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Sys / System / Configuration / SettingsPropertyCollection.cs / 1305376 / 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, StringComparer.CurrentCultureIgnoreCase); } //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// 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(); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- _CookieModule.cs
- RuleSettings.cs
- XmlIlGenerator.cs
- MsmqIntegrationChannelListener.cs
- ModelItemExtensions.cs
- FormatterServicesNoSerializableCheck.cs
- ExpressionEditorSheet.cs
- ElementMarkupObject.cs
- FilterQueryOptionExpression.cs
- DataGridToolTip.cs
- XPathParser.cs
- DesignerDeviceConfig.cs
- InsufficientMemoryException.cs
- ListSurrogate.cs
- HttpProfileBase.cs
- DataGridViewRowCancelEventArgs.cs
- Stylesheet.cs
- columnmapfactory.cs
- LayoutSettings.cs
- SqlRowUpdatedEvent.cs
- XsltContext.cs
- QilXmlWriter.cs
- ISCIIEncoding.cs
- TaskDesigner.cs
- SafeFileMappingHandle.cs
- ArgumentsParser.cs
- SqlInternalConnectionTds.cs
- EnlistmentState.cs
- SharedConnectionListener.cs
- ColumnResult.cs
- TabPage.cs
- RequestResizeEvent.cs
- UrlMappingsSection.cs
- Parser.cs
- PopOutPanel.cs
- RawContentTypeMapper.cs
- WebBaseEventKeyComparer.cs
- FilterableAttribute.cs
- SoapTypeAttribute.cs
- WebPartTransformerAttribute.cs
- DragDrop.cs
- MergeFilterQuery.cs
- MetadataPropertyCollection.cs
- XmlSchemaInclude.cs
- DefaultWorkflowSchedulerService.cs
- HashMembershipCondition.cs
- configsystem.cs
- xmlglyphRunInfo.cs
- OleDbCommandBuilder.cs
- MergePropertyDescriptor.cs
- RpcCryptoRequest.cs
- FixedDocument.cs
- SessionIDManager.cs
- _FixedSizeReader.cs
- UInt16Converter.cs
- XmlDocument.cs
- SocketInformation.cs
- RegistryKey.cs
- ArgumentValidation.cs
- XmlTextAttribute.cs
- SqlCaseSimplifier.cs
- SystemIPAddressInformation.cs
- MouseCaptureWithinProperty.cs
- GridViewDeleteEventArgs.cs
- TypeSource.cs
- _DisconnectOverlappedAsyncResult.cs
- TreeViewAutomationPeer.cs
- ParallelTimeline.cs
- FlowLayoutPanel.cs
- SecurityException.cs
- ConfigUtil.cs
- HttpHandlersSection.cs
- HttpPostClientProtocol.cs
- StrokeNodeOperations.cs
- AssemblyBuilder.cs
- TypeToken.cs
- DrawingServices.cs
- SHA384CryptoServiceProvider.cs
- FormViewPageEventArgs.cs
- ProfilePropertyNameValidator.cs
- DataGridRow.cs
- HttpClientCertificate.cs
- ResponseStream.cs
- ObjectListDesigner.cs
- TransformGroup.cs
- BStrWrapper.cs
- TextTreeFixupNode.cs
- RecognizerInfo.cs
- ObjectTag.cs
- RestHandlerFactory.cs
- CodeSubDirectoriesCollection.cs
- CalendarDesigner.cs
- CheckBoxPopupAdapter.cs
- Tablet.cs
- ManagedWndProcTracker.cs
- CultureData.cs
- ResourcePermissionBase.cs
- MatrixIndependentAnimationStorage.cs
- MissingManifestResourceException.cs
- XmlArrayItemAttribute.cs