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
- ObjectListField.cs
- Expression.cs
- BrowserCapabilitiesCompiler.cs
- RuleSettingsCollection.cs
- ListViewUpdateEventArgs.cs
- BitArray.cs
- RequestCache.cs
- UpdatableGenericsFeature.cs
- XhtmlCssHandler.cs
- GeometryDrawing.cs
- FieldBuilder.cs
- XmlSchemaObjectCollection.cs
- WebPartConnectionsCancelVerb.cs
- RegionInfo.cs
- ResourceCodeDomSerializer.cs
- ProcessHostServerConfig.cs
- RayHitTestParameters.cs
- TailPinnedEventArgs.cs
- uribuilder.cs
- LambdaCompiler.Address.cs
- XAMLParseException.cs
- FieldNameLookup.cs
- WebScriptClientGenerator.cs
- RotationValidation.cs
- ComponentChangedEvent.cs
- OperationSelectorBehavior.cs
- CapabilitiesAssignment.cs
- HScrollBar.cs
- ImmComposition.cs
- XmlUtil.cs
- ConstraintStruct.cs
- MetabaseServerConfig.cs
- GridProviderWrapper.cs
- AudioLevelUpdatedEventArgs.cs
- PKCS1MaskGenerationMethod.cs
- MaskInputRejectedEventArgs.cs
- DriveInfo.cs
- SkipQueryOptionExpression.cs
- PhysicalOps.cs
- DataList.cs
- PackWebResponse.cs
- DesignerImageAdapter.cs
- RenderData.cs
- Composition.cs
- ProcessHostConfigUtils.cs
- SelectionItemPattern.cs
- TextParagraphProperties.cs
- CodeConstructor.cs
- MouseEventArgs.cs
- BindingWorker.cs
- SplitterEvent.cs
- UpDownBase.cs
- _OSSOCK.cs
- SplayTreeNode.cs
- ConstructorExpr.cs
- DesignerUtils.cs
- MemberHolder.cs
- PictureBox.cs
- DesignerActionUIService.cs
- MarkedHighlightComponent.cs
- FunctionNode.cs
- LinkTarget.cs
- ToolStripButton.cs
- WebPartEditorApplyVerb.cs
- ZipFileInfoCollection.cs
- ToolboxItemAttribute.cs
- JoinTreeNode.cs
- ProfilePropertySettingsCollection.cs
- ModelUIElement3D.cs
- Token.cs
- ImageList.cs
- NegotiationTokenAuthenticatorStateCache.cs
- OracleString.cs
- Hashtable.cs
- JoinCqlBlock.cs
- GraphicsPath.cs
- ConfigXmlSignificantWhitespace.cs
- AnnotationResourceChangedEventArgs.cs
- ExecutorLocksHeldException.cs
- CompoundFileReference.cs
- ListViewAutomationPeer.cs
- WorkflowServiceInstance.cs
- ISCIIEncoding.cs
- GridToolTip.cs
- unsafenativemethodsother.cs
- UnconditionalPolicy.cs
- OperationInvokerTrace.cs
- TextParaClient.cs
- WebSysDisplayNameAttribute.cs
- Rfc2898DeriveBytes.cs
- WebHostScriptMappingsInstallComponent.cs
- PartitionedStreamMerger.cs
- MetadataItemEmitter.cs
- TrustLevel.cs
- FormatterConverter.cs
- ToolStripDropDown.cs
- SafeSecurityHelper.cs
- DataError.cs
- XmlIgnoreAttribute.cs
- HandlerFactoryCache.cs