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
![Network programming in C#, Network Programming in VB.NET, Network Programming in .NET](/images/book.jpg)
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- TheQuery.cs
- SqlRowUpdatedEvent.cs
- DataSourceExpressionCollection.cs
- UnSafeCharBuffer.cs
- MetadataUtilsSmi.cs
- HideDisabledControlAdapter.cs
- ChannelBinding.cs
- PeerNameResolver.cs
- HandlerWithFactory.cs
- ProfileGroupSettingsCollection.cs
- DetailsViewCommandEventArgs.cs
- DrawListViewColumnHeaderEventArgs.cs
- IisTraceListener.cs
- RootNamespaceAttribute.cs
- Baml2006KnownTypes.cs
- ListCollectionView.cs
- BuildManager.cs
- Size3DValueSerializer.cs
- StringPropertyBuilder.cs
- newinstructionaction.cs
- DesignerCategoryAttribute.cs
- PersonalizationProvider.cs
- DocumentViewerHelper.cs
- ServiceParser.cs
- MsmqIntegrationProcessProtocolHandler.cs
- Win32.cs
- UIInitializationException.cs
- ping.cs
- PointAnimationBase.cs
- UnsafePeerToPeerMethods.cs
- WsiProfilesElement.cs
- ProcessHostFactoryHelper.cs
- HttpContextWrapper.cs
- TimeoutHelper.cs
- InvokeGenerator.cs
- RadioButtonList.cs
- InvalidOleVariantTypeException.cs
- ServerReliableChannelBinder.cs
- RawAppCommandInputReport.cs
- SqlCachedBuffer.cs
- SpnegoTokenAuthenticator.cs
- SqlPersonalizationProvider.cs
- ResourcesChangeInfo.cs
- BuildProvider.cs
- ContentIterators.cs
- GridPattern.cs
- LayoutTableCell.cs
- ThreadStartException.cs
- BrowserCapabilitiesCodeGenerator.cs
- PaintValueEventArgs.cs
- LineServices.cs
- NotSupportedException.cs
- ContentType.cs
- NullRuntimeConfig.cs
- PathGeometry.cs
- DynamicDiscoSearcher.cs
- XmlSigningNodeWriter.cs
- FloaterParaClient.cs
- Socket.cs
- SqlDataSource.cs
- DelayedRegex.cs
- LassoHelper.cs
- TraceUtility.cs
- PropertyNames.cs
- SerializationInfo.cs
- HeaderCollection.cs
- MenuItemBinding.cs
- SqlDataSourceRefreshSchemaForm.cs
- ListItemViewAttribute.cs
- securitycriticaldata.cs
- CommentEmitter.cs
- GlobalizationAssembly.cs
- EventMap.cs
- Proxy.cs
- NetSectionGroup.cs
- FrugalMap.cs
- UnsafeNativeMethods.cs
- CheckableControlBaseAdapter.cs
- ApplicationDirectory.cs
- MissingFieldException.cs
- Effect.cs
- FactoryGenerator.cs
- LayoutDump.cs
- StandardCommands.cs
- Exception.cs
- RoutedEventArgs.cs
- CodeTypeReferenceExpression.cs
- TemplatedMailWebEventProvider.cs
- OptimizedTemplateContent.cs
- ServiceTimeoutsElement.cs
- ConfigurationCollectionAttribute.cs
- HitTestParameters.cs
- ServiceDescriptionImporter.cs
- VariableQuery.cs
- ProgressBar.cs
- StringInfo.cs
- LongValidatorAttribute.cs
- SQLMoneyStorage.cs
- RSACryptoServiceProvider.cs
- Soap.cs