Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WCF / Serialization / System / Runtime / Serialization / Configuration / TypeElementCollection.cs / 1305376 / TypeElementCollection.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.Runtime.Serialization.Configuration { using System; using System.Configuration; using System.Globalization; [ConfigurationCollection(typeof(TypeElement), CollectionType = ConfigurationElementCollectionType.BasicMap)] public sealed class TypeElementCollection : ConfigurationElementCollection { public TypeElementCollection() { } public TypeElement this[int index] { get { TypeElement retval = (TypeElement)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 void Add(TypeElement 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 override ConfigurationElementCollectionType CollectionType { get { return ConfigurationElementCollectionType.BasicMap; } } protected override ConfigurationElement CreateNewElement() { TypeElement retval = new TypeElement(); return retval; } protected override string ElementName { get { return TypeElementCollection.KnownTypeConfig; } } protected override Object GetElementKey(ConfigurationElement element) { if (element == null) { throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("element"); } return ((TypeElement)element).Key; } public int IndexOf(TypeElement element) { if (element == null) { throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("element"); } return BaseIndexOf(element); } public void Remove(TypeElement 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 RemoveAt(int index) { BaseRemoveAt(index); } const string KnownTypeConfig = "knownType"; } } // 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(TypeElement), CollectionType = ConfigurationElementCollectionType.BasicMap)] public sealed class TypeElementCollection : ConfigurationElementCollection { public TypeElementCollection() { } public TypeElement this[int index] { get { TypeElement retval = (TypeElement)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 void Add(TypeElement 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 override ConfigurationElementCollectionType CollectionType { get { return ConfigurationElementCollectionType.BasicMap; } } protected override ConfigurationElement CreateNewElement() { TypeElement retval = new TypeElement(); return retval; } protected override string ElementName { get { return TypeElementCollection.KnownTypeConfig; } } protected override Object GetElementKey(ConfigurationElement element) { if (element == null) { throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("element"); } return ((TypeElement)element).Key; } public int IndexOf(TypeElement element) { if (element == null) { throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("element"); } return BaseIndexOf(element); } public void Remove(TypeElement 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 RemoveAt(int index) { BaseRemoveAt(index); } const string KnownTypeConfig = "knownType"; } } // 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
- BufferedReadStream.cs
- XmlIgnoreAttribute.cs
- SignatureDescription.cs
- UserControlAutomationPeer.cs
- WindowsListViewSubItem.cs
- DescendantOverDescendantQuery.cs
- VideoDrawing.cs
- ReadWriteObjectLock.cs
- RelOps.cs
- TableLayoutColumnStyleCollection.cs
- AppSettingsSection.cs
- fixedPageContentExtractor.cs
- BitmapEffectInput.cs
- Partitioner.cs
- ArraySet.cs
- DefaultMemberAttribute.cs
- Scheduling.cs
- InvalidEnumArgumentException.cs
- DeviceContexts.cs
- WebConfigurationHost.cs
- _UriSyntax.cs
- CssStyleCollection.cs
- GeometryModel3D.cs
- FrameDimension.cs
- HtmlElement.cs
- XmlSchemaSimpleContent.cs
- GcHandle.cs
- CodeMemberEvent.cs
- RepeatBehaviorConverter.cs
- OdbcCommandBuilder.cs
- Column.cs
- DataFieldCollectionEditor.cs
- MetadataCollection.cs
- NamespaceDecl.cs
- ProviderSettings.cs
- NamespaceInfo.cs
- ChannelManagerHelpers.cs
- DesignerSerializationOptionsAttribute.cs
- ObjectSerializerFactory.cs
- DesignerSerializerAttribute.cs
- ResizeGrip.cs
- OperatingSystem.cs
- MarshalDirectiveException.cs
- MaskedTextProvider.cs
- FillBehavior.cs
- ExceptionHandler.cs
- PrimitiveCodeDomSerializer.cs
- ArrangedElement.cs
- MatrixAnimationUsingKeyFrames.cs
- PackagePartCollection.cs
- NativeMethods.cs
- TextServicesDisplayAttribute.cs
- CodeTypeReferenceExpression.cs
- LocalizationComments.cs
- FormViewUpdatedEventArgs.cs
- XmlnsDictionary.cs
- CodeMethodReturnStatement.cs
- DiscoveryClientReferences.cs
- Matrix3DStack.cs
- ValueType.cs
- Journal.cs
- ConstNode.cs
- RadioButtonPopupAdapter.cs
- RequestTimeoutManager.cs
- NumericExpr.cs
- DataFieldConverter.cs
- control.ime.cs
- UdpDiscoveryMessageFilter.cs
- TitleStyle.cs
- _MultipleConnectAsync.cs
- GB18030Encoding.cs
- NumericUpDownAccelerationCollection.cs
- AspNetPartialTrustHelpers.cs
- SqlAggregateChecker.cs
- PropertyEmitter.cs
- DocumentReferenceCollection.cs
- StyleModeStack.cs
- DBSchemaRow.cs
- Oid.cs
- PositiveTimeSpanValidatorAttribute.cs
- NewArray.cs
- DataGridViewSelectedCellCollection.cs
- WorkflowMessageEventArgs.cs
- ReadOnlyCollectionBase.cs
- HWStack.cs
- figurelengthconverter.cs
- WebPartUserCapability.cs
- WorkflowServiceHost.cs
- XsltLoader.cs
- ConstraintConverter.cs
- WhitespaceRuleLookup.cs
- GeneralTransformGroup.cs
- DataObjectCopyingEventArgs.cs
- OdbcConnectionOpen.cs
- CodeFieldReferenceExpression.cs
- ListSortDescription.cs
- FlowchartDesigner.Helpers.cs
- ServicesUtilities.cs
- MemberMaps.cs
- securestring.cs