Code:
/ 4.0 / 4.0 / untmp / 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- PrintEvent.cs
- SponsorHelper.cs
- TrailingSpaceComparer.cs
- CallbackHandler.cs
- assemblycache.cs
- IriParsingElement.cs
- ValueChangedEventManager.cs
- ValidationResult.cs
- SecurityImpersonationBehavior.cs
- SqlConnection.cs
- AttachedPropertyMethodSelector.cs
- BuildProviderCollection.cs
- RegionIterator.cs
- CompressEmulationStream.cs
- OpacityConverter.cs
- DotExpr.cs
- AsymmetricKeyExchangeFormatter.cs
- ServiceNameElement.cs
- AuthorizationContext.cs
- ClientRuntimeConfig.cs
- Rotation3DAnimation.cs
- DataSetMappper.cs
- ControlTemplate.cs
- Int64Storage.cs
- FrameworkPropertyMetadata.cs
- PriorityRange.cs
- BinaryObjectReader.cs
- SafeTokenHandle.cs
- DecodeHelper.cs
- PolyBezierSegment.cs
- ThrowHelper.cs
- DataColumnPropertyDescriptor.cs
- MasterPageParser.cs
- ConfigurationElementCollection.cs
- ipaddressinformationcollection.cs
- WsdlContractConversionContext.cs
- dbenumerator.cs
- LocalClientSecuritySettings.cs
- SqlCacheDependency.cs
- LinearKeyFrames.cs
- FixedPageProcessor.cs
- EndOfStreamException.cs
- EntityDataSourceSelectedEventArgs.cs
- ConstantSlot.cs
- ToolbarAUtomationPeer.cs
- XmlSchemaAnnotation.cs
- EventManager.cs
- complextypematerializer.cs
- ApplicationInfo.cs
- ColumnHeaderConverter.cs
- GlyphRun.cs
- DataGridTableStyleMappingNameEditor.cs
- DockingAttribute.cs
- Knowncolors.cs
- Encoding.cs
- Point3DAnimationUsingKeyFrames.cs
- TypeUnloadedException.cs
- LocalizationComments.cs
- TextHidden.cs
- ListItem.cs
- SizeAnimationUsingKeyFrames.cs
- TextBreakpoint.cs
- RangeEnumerable.cs
- TrackingServices.cs
- XDRSchema.cs
- StateItem.cs
- FullTextLine.cs
- User.cs
- CharKeyFrameCollection.cs
- UInt64Converter.cs
- NotCondition.cs
- ActivityExecutionContext.cs
- codemethodreferenceexpression.cs
- ExeContext.cs
- DataControlReference.cs
- Cursors.cs
- Hyperlink.cs
- XmlMemberMapping.cs
- DictionarySectionHandler.cs
- PhysicalAddress.cs
- SqlRecordBuffer.cs
- BufferModesCollection.cs
- Effect.cs
- MobileSysDescriptionAttribute.cs
- CodeCastExpression.cs
- WriteTimeStream.cs
- ElementFactory.cs
- PlaceHolder.cs
- FixedSOMTableRow.cs
- LabelLiteral.cs
- BaseTemplateBuildProvider.cs
- SparseMemoryStream.cs
- GlyphCache.cs
- SecurityTokenAuthenticator.cs
- RepeaterCommandEventArgs.cs
- Size3D.cs
- QilTypeChecker.cs
- EventDescriptorCollection.cs
- GridViewRowPresenterBase.cs
- InvalidateEvent.cs