Files
mono/mcs/class/referencesource/System.ServiceModel/System/ServiceModel/Configuration/ServiceBehaviorElement.cs
T
dotnet-bot adf899c629 Adding System.Data..., System.ServiceModel..., and System.Web...
Adding reference source for
System.Data
System.Data.DataSetExtensions
System.Data.Entity
System.Data.Entity.Design
System.Data.Linq
System.Data.SqlXml
System.ServiceModel
System.ServiceModel.Activation
System.ServiceModel.Activities
System.ServiceModel.Channels
System.ServiceModel.Discovery
System.ServiceModel.Internals
System.ServiceModel.Routing
System.ServiceModel.WasHosting
System.ServiceModel.Web
System.Web
System.Web.ApplicationServices
System.Web.DynamicData
System.Web.Entity
System.Web.Entity.Design
System.Web.Extensions
System.Web.Mobile
System.Web.Routing
System.Web.Services
System.Xml
System.Xml.Linq
2016-05-03 00:07:37 +02:00

84 lines
3.3 KiB
C#

//-----------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
namespace System.ServiceModel.Configuration
{
using System;
using System.ServiceModel;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Globalization;
using System.Xml;
public partial class ServiceBehaviorElement : NamedServiceModelExtensionCollectionElement<BehaviorExtensionElement>
{
public ServiceBehaviorElement()
: this(null)
{
}
public ServiceBehaviorElement(string name)
: base(ConfigurationStrings.BehaviorExtensions, name)
{
}
// Verify that the behavior being added implements IServiceBehavior
public override void Add(BehaviorExtensionElement element)
{
// If element is null, let base.Add() throw for consistency reasons
if (null != element)
{
if (element is ClearBehaviorElement || element is RemoveBehaviorElement)
{
base.AddItem(element);
return;
}
if (!typeof(System.ServiceModel.Description.IServiceBehavior).IsAssignableFrom(element.BehaviorType))
{
#pragma warning disable 56506 //[....]; element.ElementInformation is guaranteed to be non-null(System.Configuration)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ConfigurationErrorsException(SR.GetString(SR.ConfigInvalidServiceBehaviorType,
element.ConfigurationElementName,
this.Name),
element.ElementInformation.Source,
element.ElementInformation.LineNumber));
#pragma warning restore
}
}
base.Add(element);
}
// Verify that the behavior being added implements IServiceBehavior
public override bool CanAdd(BehaviorExtensionElement element)
{
// If element is null, let base.CanAdd() throw for consistency reasons
if (null != element)
{
if (element is ClearBehaviorElement || element is RemoveBehaviorElement)
{
return true;
}
if (!typeof(System.ServiceModel.Description.IServiceBehavior).IsAssignableFrom(element.BehaviorType))
{
#pragma warning disable 56506 //[....]; element.ElementInformation is guaranteed to be non-null(System.Configuration)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ConfigurationErrorsException(SR.GetString(SR.ConfigInvalidServiceBehaviorType,
element.ConfigurationElementName,
this.Name),
element.ElementInformation.Source,
element.ElementInformation.LineNumber));
#pragma warning restore
}
}
return base.CanAdd(element);
}
protected override void DeserializeElement(XmlReader reader, bool serializeCollectionKey)
{
base.DeserializeElement(reader, serializeCollectionKey);
}
}
}