Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Configuration / ExtensionElementCollection.cs / 1 / ExtensionElementCollection.cs
//------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
namespace System.ServiceModel.Configuration
{
using System;
using System.Configuration;
[ConfigurationCollection(typeof(ExtensionElement), CollectionType = ConfigurationElementCollectionType.BasicMap)]
public class ExtensionElementCollection : ServiceModelConfigurationElementCollection
{
public ExtensionElementCollection()
: base(ConfigurationElementCollectionType.BasicMap, ConfigurationStrings.Add)
{
}
protected override void BaseAdd(ConfigurationElement element)
{
this.EnforceUniqueElement((ExtensionElement)element);
base.BaseAdd(element);
}
protected override void BaseAdd(int index, ConfigurationElement element)
{
this.EnforceUniqueElement((ExtensionElement)element);
base.BaseAdd(index, element);
}
protected override object GetElementKey(ConfigurationElement element)
{
if (null == element)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("element");
}
ExtensionElement configElementKey = (ExtensionElement) element;
return configElementKey.Name;
}
void EnforceUniqueElement(ExtensionElement element)
{
Type elementType = Type.GetType(element.Type, false);
foreach (ExtensionElement extension in this)
{
if (element.Name.Equals(extension.Name, StringComparison.Ordinal))
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ConfigurationErrorsException(
SR.GetString(SR.ConfigDuplicateExtensionName, element.Name)));
}
if (null != elementType)
{
if (elementType.Equals(Type.GetType(extension.Type, false)))
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ConfigurationErrorsException(
SR.GetString(SR.ConfigDuplicateExtensionType, element.Type)));
}
}
else
{
if (element.Type.Equals(extension.Type, StringComparison.OrdinalIgnoreCase))
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ConfigurationErrorsException(
SR.GetString(SR.ConfigDuplicateExtensionType, element.Type)));
}
}
}
}
protected override bool ThrowOnDuplicate
{
get
{
return true;
}
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- EmbeddedObject.cs
- PropertyChangedEventArgs.cs
- AppDomainManager.cs
- XmlEventCache.cs
- TextCompositionEventArgs.cs
- XmlSchemaObjectTable.cs
- ProxyGenerationError.cs
- FileLogRecordHeader.cs
- DSACryptoServiceProvider.cs
- Stacktrace.cs
- GridViewSortEventArgs.cs
- UserInitiatedRoutedEventPermission.cs
- OdbcException.cs
- BaseTemplateBuildProvider.cs
- RectangleConverter.cs
- CombinedHttpChannel.cs
- VariantWrapper.cs
- EditorAttribute.cs
- AlternateViewCollection.cs
- DelegateHelpers.Generated.cs
- EntityCollection.cs
- CredentialCache.cs
- Renderer.cs
- EventLogPermissionAttribute.cs
- Screen.cs
- SafeTokenHandle.cs
- CustomErrorCollection.cs
- DataServices.cs
- EntityDataSourceEntityTypeFilterConverter.cs
- SQLGuid.cs
- PenThreadPool.cs
- Annotation.cs
- WebPartPersonalization.cs
- _SslSessionsCache.cs
- MappingMetadataHelper.cs
- HtmlLiteralTextAdapter.cs
- Activator.cs
- XmlSchemaExporter.cs
- BlockCollection.cs
- ViewUtilities.cs
- PropertyPathWorker.cs
- ExtensionSimplifierMarkupObject.cs
- Parser.cs
- IndexOutOfRangeException.cs
- Accessible.cs
- DesignerOptionService.cs
- SqlBooleanMismatchVisitor.cs
- CacheMemory.cs
- EditingMode.cs
- SystemEvents.cs
- SectionUpdates.cs
- IArgumentProvider.cs
- ColumnBinding.cs
- NavigationService.cs
- ToolboxItemFilterAttribute.cs
- RightsManagementEncryptionTransform.cs
- XamlSerializerUtil.cs
- PhonemeConverter.cs
- ToolboxItem.cs
- TraceHandler.cs
- LinkButton.cs
- EventNotify.cs
- DrawItemEvent.cs
- PropertiesTab.cs
- TypeResolvingOptions.cs
- IIS7WorkerRequest.cs
- TextEndOfLine.cs
- BitmapSourceSafeMILHandle.cs
- DataShape.cs
- ColorEditor.cs
- TextTreeNode.cs
- ToolStripRenderer.cs
- StylusPointCollection.cs
- JobStaple.cs
- SubclassTypeValidatorAttribute.cs
- SequenceQuery.cs
- TaiwanCalendar.cs
- SystemIPv6InterfaceProperties.cs
- Binding.cs
- StopRoutingHandler.cs
- UnmanagedMarshal.cs
- DataRecordInternal.cs
- VersionValidator.cs
- SqlCommandBuilder.cs
- EntitySetBaseCollection.cs
- Point4DValueSerializer.cs
- JavaScriptObjectDeserializer.cs
- ParallelLoopState.cs
- CustomUserNameSecurityTokenAuthenticator.cs
- WebPartsSection.cs
- SpotLight.cs
- EventData.cs
- DataTableExtensions.cs
- ObjectCloneHelper.cs
- FileLogRecord.cs
- WindowInteractionStateTracker.cs
- TraceSection.cs
- CultureTableRecord.cs
- MouseButton.cs
- ParserOptions.cs