Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / 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(); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// 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(); } } } // 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
- X509CertificateValidationMode.cs
- BinaryReader.cs
- EnumUnknown.cs
- SchemaImporter.cs
- SimpleBitVector32.cs
- MetaColumn.cs
- PropagatorResult.cs
- StoragePropertyMapping.cs
- HitTestDrawingContextWalker.cs
- Setter.cs
- RoleManagerSection.cs
- Selection.cs
- DataGridViewLinkColumn.cs
- CodeCompileUnit.cs
- TableItemStyle.cs
- ComponentCommands.cs
- Message.cs
- RelationshipEntry.cs
- HitTestFilterBehavior.cs
- FusionWrap.cs
- TerminateSequence.cs
- XPathPatternParser.cs
- BaseCodePageEncoding.cs
- EncryptedReference.cs
- SqlDataAdapter.cs
- Events.cs
- DefaultBinder.cs
- Label.cs
- ProvidePropertyAttribute.cs
- XslUrlEditor.cs
- SupportingTokenListenerFactory.cs
- MemberNameValidator.cs
- UrlMappingsSection.cs
- LocalFileSettingsProvider.cs
- HtmlInputText.cs
- InitializerFacet.cs
- PeerMaintainer.cs
- StylusPointPropertyInfoDefaults.cs
- DynamicHyperLink.cs
- ImpersonateTokenRef.cs
- ConfigurationSectionCollection.cs
- BindingNavigator.cs
- EntitySqlQueryCacheKey.cs
- ContainerVisual.cs
- DataBoundLiteralControl.cs
- TimeSpan.cs
- CalendarDataBindingHandler.cs
- ServiceChannelProxy.cs
- ContextMenu.cs
- TraceContextRecord.cs
- MenuItemBinding.cs
- FlowDocumentScrollViewer.cs
- JumpTask.cs
- AuthorizationSection.cs
- AttributeConverter.cs
- EventDrivenDesigner.cs
- BigIntegerStorage.cs
- DataGridViewCheckBoxColumn.cs
- AnimationTimeline.cs
- DrawingVisual.cs
- DecimalConstantAttribute.cs
- GeometryGroup.cs
- PrivateFontCollection.cs
- Number.cs
- ZipIOExtraField.cs
- ConfigurationHandlersInstallComponent.cs
- MissingMemberException.cs
- FunctionUpdateCommand.cs
- DataRelation.cs
- SoapMessage.cs
- DataGridItem.cs
- OraclePermissionAttribute.cs
- SchemaCreator.cs
- SkinBuilder.cs
- VolatileEnlistmentMultiplexing.cs
- WorkflowViewElement.cs
- Geometry3D.cs
- BamlRecords.cs
- RegexStringValidatorAttribute.cs
- WebInvokeAttribute.cs
- ImpersonateTokenRef.cs
- HttpCachePolicy.cs
- DrawTreeNodeEventArgs.cs
- PropertyIDSet.cs
- FilteredAttributeCollection.cs
- DataTemplateSelector.cs
- ComponentRenameEvent.cs
- EraserBehavior.cs
- LocalBuilder.cs
- ExpandableObjectConverter.cs
- MessageBuffer.cs
- AspNetPartialTrustHelpers.cs
- RayMeshGeometry3DHitTestResult.cs
- TimerEventSubscription.cs
- StateMachineSubscriptionManager.cs
- FileDialogCustomPlace.cs
- ClientApiGenerator.cs
- _WebProxyDataBuilder.cs
- SQLChars.cs
- SqlRowUpdatingEvent.cs