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
- ControlCachePolicy.cs
- ResourceKey.cs
- QilName.cs
- TypeBuilder.cs
- TableLayoutColumnStyleCollection.cs
- UriScheme.cs
- MemoryFailPoint.cs
- ConfigurationElement.cs
- XamlFigureLengthSerializer.cs
- TextBoxView.cs
- ToolstripProfessionalRenderer.cs
- DataList.cs
- DataGridViewIntLinkedList.cs
- InputDevice.cs
- UpdatePanelTriggerCollection.cs
- UpdatableGenericsFeature.cs
- OverrideMode.cs
- ObjectParameter.cs
- GroupDescription.cs
- WindowsFormsSectionHandler.cs
- RuleSetReference.cs
- Point3DConverter.cs
- BamlRecordReader.cs
- UrlUtility.cs
- TdsParserSessionPool.cs
- ObjectDataSource.cs
- StylusPointPropertyInfoDefaults.cs
- InvokePattern.cs
- XmlEntityReference.cs
- FactoryMaker.cs
- SharedPerformanceCounter.cs
- PathNode.cs
- Material.cs
- ConstructorNeedsTagAttribute.cs
- ResourceFallbackManager.cs
- HistoryEventArgs.cs
- Switch.cs
- AbsoluteQuery.cs
- PermissionRequestEvidence.cs
- _ReceiveMessageOverlappedAsyncResult.cs
- DbConnectionStringCommon.cs
- BasicBrowserDialog.cs
- SqlDataSourceSelectingEventArgs.cs
- WorkflowIdleElement.cs
- AlternationConverter.cs
- WebConfigurationManager.cs
- XmlTextReader.cs
- FileUtil.cs
- TypeDescriptor.cs
- PeerResolverBindingElement.cs
- FormViewModeEventArgs.cs
- Documentation.cs
- DiscoveryClientRequestChannel.cs
- PageThemeCodeDomTreeGenerator.cs
- ObjectTypeMapping.cs
- StackSpiller.cs
- ISO2022Encoding.cs
- ISCIIEncoding.cs
- BindingCompleteEventArgs.cs
- Encoding.cs
- ApplicationDirectoryMembershipCondition.cs
- Baml2006ReaderSettings.cs
- ConstraintConverter.cs
- StandardBindingReliableSessionElement.cs
- ComEventsSink.cs
- CredentialCache.cs
- HttpPostedFile.cs
- FirstMatchCodeGroup.cs
- StylusCollection.cs
- ReturnEventArgs.cs
- AnonymousIdentificationSection.cs
- X509CertificateClaimSet.cs
- MultipartIdentifier.cs
- TextDecoration.cs
- ControlUtil.cs
- JsonMessageEncoderFactory.cs
- LogFlushAsyncResult.cs
- ServicePointManagerElement.cs
- BrowserInteropHelper.cs
- DataView.cs
- EventEntry.cs
- FormsIdentity.cs
- XPathQilFactory.cs
- ServiceDescription.cs
- CopyNodeSetAction.cs
- FormView.cs
- ExpressionBuilder.cs
- FusionWrap.cs
- RegexStringValidatorAttribute.cs
- XmlElementAttributes.cs
- SimpleColumnProvider.cs
- DataRowCollection.cs
- PageThemeCodeDomTreeGenerator.cs
- ActivationServices.cs
- ParallelActivityDesigner.cs
- CharStorage.cs
- SmtpReplyReader.cs
- XmlWrappingWriter.cs
- DataGridViewRowsRemovedEventArgs.cs
- OleDbRowUpdatingEvent.cs