Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WCF / Serialization / System / Runtime / Serialization / Configuration / DeclaredTypeElementCollection.cs / 1305376 / DeclaredTypeElementCollection.cs
//------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
namespace System.Runtime.Serialization.Configuration
{
using System;
using System.Configuration;
using System.Globalization;
[ConfigurationCollection(typeof(DeclaredTypeElement))]
public sealed class DeclaredTypeElementCollection : ConfigurationElementCollection
{
public DeclaredTypeElementCollection()
{
}
public DeclaredTypeElement this[int index]
{
get
{
DeclaredTypeElement retval = (DeclaredTypeElement)BaseGet(index);
return retval;
}
set
{
// Only validate input if config is not Read-Only, otherwise
// let BaseAdd throw appropriate exception
if (!this.IsReadOnly())
{
if (value == null)
{
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("value");
}
if (BaseGet(index) != null)
{
BaseRemoveAt(index);
}
}
BaseAdd(index, value);
}
}
public new DeclaredTypeElement this[string typeName]
{
get
{
if (String.IsNullOrEmpty(typeName))
{
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("typeName");
}
DeclaredTypeElement retval = (DeclaredTypeElement)BaseGet(typeName);
return retval;
}
set
{
// Only validate input if config is not Read-Only, otherwise
// let Add throw appropriate exception
if (!this.IsReadOnly())
{
if (String.IsNullOrEmpty(typeName))
{
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("typeName");
}
if (value == null)
{
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("value");
}
if (BaseGet(typeName) != null)
{
BaseRemove(typeName);
}
else
{
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new IndexOutOfRangeException(SR.GetString(SR.ConfigIndexOutOfRange,
typeName)));
}
}
Add(value);
}
}
public void Add(DeclaredTypeElement element)
{
// Only validate input if config is not Read-Only, otherwise
// let BaseAdd throw appropriate exception
if (!this.IsReadOnly())
{
if (element == null)
{
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("element");
}
}
BaseAdd(element);
}
public void Clear()
{
BaseClear();
}
public bool Contains(string typeName)
{
if (String.IsNullOrEmpty(typeName))
{
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("typeName");
}
return this.BaseGet(typeName) != null;
}
protected override ConfigurationElement CreateNewElement()
{
DeclaredTypeElement retval = new DeclaredTypeElement();
return retval;
}
protected override Object GetElementKey(ConfigurationElement element)
{
if (element == null)
{
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("element");
}
return ((DeclaredTypeElement)element).Type;
}
public int IndexOf(DeclaredTypeElement element)
{
if (element == null)
{
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("element");
}
return BaseIndexOf(element);
}
public void Remove(DeclaredTypeElement element)
{
// Only validate input if config is not Read-Only, otherwise
// let BaseRemove throw appropriate exception
if (!this.IsReadOnly())
{
if (element == null)
{
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("element");
}
}
BaseRemove(this.GetElementKey(element));
}
public void Remove(string typeName)
{
// Only validate input if config is not Read-Only, otherwise
// let BaseRemove throw appropriate exception
if (!this.IsReadOnly())
{
if (String.IsNullOrEmpty(typeName))
{
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("typeName");
}
}
BaseRemove(typeName);
}
public void RemoveAt(int index)
{
BaseRemoveAt(index);
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
namespace System.Runtime.Serialization.Configuration
{
using System;
using System.Configuration;
using System.Globalization;
[ConfigurationCollection(typeof(DeclaredTypeElement))]
public sealed class DeclaredTypeElementCollection : ConfigurationElementCollection
{
public DeclaredTypeElementCollection()
{
}
public DeclaredTypeElement this[int index]
{
get
{
DeclaredTypeElement retval = (DeclaredTypeElement)BaseGet(index);
return retval;
}
set
{
// Only validate input if config is not Read-Only, otherwise
// let BaseAdd throw appropriate exception
if (!this.IsReadOnly())
{
if (value == null)
{
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("value");
}
if (BaseGet(index) != null)
{
BaseRemoveAt(index);
}
}
BaseAdd(index, value);
}
}
public new DeclaredTypeElement this[string typeName]
{
get
{
if (String.IsNullOrEmpty(typeName))
{
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("typeName");
}
DeclaredTypeElement retval = (DeclaredTypeElement)BaseGet(typeName);
return retval;
}
set
{
// Only validate input if config is not Read-Only, otherwise
// let Add throw appropriate exception
if (!this.IsReadOnly())
{
if (String.IsNullOrEmpty(typeName))
{
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("typeName");
}
if (value == null)
{
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("value");
}
if (BaseGet(typeName) != null)
{
BaseRemove(typeName);
}
else
{
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new IndexOutOfRangeException(SR.GetString(SR.ConfigIndexOutOfRange,
typeName)));
}
}
Add(value);
}
}
public void Add(DeclaredTypeElement element)
{
// Only validate input if config is not Read-Only, otherwise
// let BaseAdd throw appropriate exception
if (!this.IsReadOnly())
{
if (element == null)
{
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("element");
}
}
BaseAdd(element);
}
public void Clear()
{
BaseClear();
}
public bool Contains(string typeName)
{
if (String.IsNullOrEmpty(typeName))
{
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("typeName");
}
return this.BaseGet(typeName) != null;
}
protected override ConfigurationElement CreateNewElement()
{
DeclaredTypeElement retval = new DeclaredTypeElement();
return retval;
}
protected override Object GetElementKey(ConfigurationElement element)
{
if (element == null)
{
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("element");
}
return ((DeclaredTypeElement)element).Type;
}
public int IndexOf(DeclaredTypeElement element)
{
if (element == null)
{
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("element");
}
return BaseIndexOf(element);
}
public void Remove(DeclaredTypeElement element)
{
// Only validate input if config is not Read-Only, otherwise
// let BaseRemove throw appropriate exception
if (!this.IsReadOnly())
{
if (element == null)
{
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("element");
}
}
BaseRemove(this.GetElementKey(element));
}
public void Remove(string typeName)
{
// Only validate input if config is not Read-Only, otherwise
// let BaseRemove throw appropriate exception
if (!this.IsReadOnly())
{
if (String.IsNullOrEmpty(typeName))
{
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("typeName");
}
}
BaseRemove(typeName);
}
public void RemoveAt(int index)
{
BaseRemoveAt(index);
}
}
}
// 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
- TaskFactory.cs
- DebugController.cs
- Nullable.cs
- TraceLog.cs
- ChannelManager.cs
- FamilyCollection.cs
- TextBox.cs
- MetadataArtifactLoaderCompositeFile.cs
- TailPinnedEventArgs.cs
- DESCryptoServiceProvider.cs
- XmlToDatasetMap.cs
- StylusCaptureWithinProperty.cs
- ISO2022Encoding.cs
- ModelFunction.cs
- ZoneMembershipCondition.cs
- FileRecordSequenceCompletedAsyncResult.cs
- SchemaImporter.cs
- Selection.cs
- AttachedPropertyMethodSelector.cs
- ProgressBar.cs
- DataGridAddNewRow.cs
- SignatureHelper.cs
- CompiledXpathExpr.cs
- FormattedText.cs
- ProcessModelInfo.cs
- MetadataCacheItem.cs
- XmlUtil.cs
- XmlMembersMapping.cs
- XmlObjectSerializerReadContext.cs
- MessagePartDescription.cs
- TableLayoutStyle.cs
- DefaultMemberAttribute.cs
- CompilerGlobalScopeAttribute.cs
- Buffer.cs
- CursorInteropHelper.cs
- ProtocolsConfigurationEntry.cs
- FacetDescriptionElement.cs
- RegexParser.cs
- XamlToRtfWriter.cs
- RootBrowserWindowAutomationPeer.cs
- AttachedPropertyBrowsableForTypeAttribute.cs
- TextProperties.cs
- Util.cs
- XpsTokenContext.cs
- DataControlImageButton.cs
- ApplicationSecurityInfo.cs
- CompatibleComparer.cs
- FlowLayout.cs
- DataMemberConverter.cs
- SoapParser.cs
- AssemblyFilter.cs
- GridViewColumnHeader.cs
- _DomainName.cs
- documentsequencetextview.cs
- XmlStreamedByteStreamReader.cs
- TextTreeTextBlock.cs
- CodeGenerator.cs
- ObjectAnimationUsingKeyFrames.cs
- ReaderWriterLock.cs
- PeerTransportElement.cs
- DateRangeEvent.cs
- IsolatedStorageFilePermission.cs
- TableHeaderCell.cs
- MessagePartDescriptionCollection.cs
- DataRelationCollection.cs
- PersistChildrenAttribute.cs
- SafeBuffer.cs
- ToolStripSeparator.cs
- GridViewEditEventArgs.cs
- ExtensibleClassFactory.cs
- XPathPatternParser.cs
- ScriptResourceInfo.cs
- PolyLineSegment.cs
- HtmlEmptyTagControlBuilder.cs
- _BaseOverlappedAsyncResult.cs
- ClosableStream.cs
- RepeaterItemEventArgs.cs
- EnumerableCollectionView.cs
- LinqDataSourceStatusEventArgs.cs
- CornerRadiusConverter.cs
- EdmToObjectNamespaceMap.cs
- RtfNavigator.cs
- BrushValueSerializer.cs
- XmlReader.cs
- ItemCollectionEditor.cs
- SystemNetHelpers.cs
- MetadataArtifactLoaderFile.cs
- EditorZone.cs
- StringUtil.cs
- safelinkcollection.cs
- ConfigurationPermission.cs
- ConversionValidationRule.cs
- HostProtectionPermission.cs
- BitmapEffectDrawing.cs
- PermissionListSet.cs
- XmlChildEnumerator.cs
- DataGridViewRowHeaderCell.cs
- OleStrCAMarshaler.cs
- StringUtil.cs
- Stroke.cs