Imported Upstream version 4.0.0~alpha1

Former-commit-id: 806294f5ded97629b74c85c09952f2a74fe182d9
This commit is contained in:
Jo Shields
2015-04-07 09:35:12 +01:00
parent 283343f570
commit 3c1f479b9d
22469 changed files with 2931443 additions and 869343 deletions

View File

@@ -0,0 +1,39 @@
//----------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------
namespace System.ServiceModel.Discovery.Configuration
{
using System.Configuration;
using System.Globalization;
using System.ServiceModel.Configuration;
[ConfigurationCollection(typeof(ChannelEndpointElement), AddItemName = ConfigurationStrings.Endpoint)]
public sealed class AnnouncementChannelEndpointElementCollection : ServiceModelConfigurationElementCollection<ChannelEndpointElement>
{
public AnnouncementChannelEndpointElementCollection()
{
this.AddElementName = ConfigurationStrings.Endpoint;
}
protected override object GetElementKey(ConfigurationElement element)
{
if (element == null)
{
throw FxTrace.Exception.ArgumentNull("element");
}
ChannelEndpointElement channelEndpointElement = (ChannelEndpointElement)element;
string address = channelEndpointElement.Address == null ? "" : channelEndpointElement.Address.ToString().ToUpperInvariant();
return string.Format(CultureInfo.InvariantCulture,
"kind:{0};endpointConfiguration:{1};address:{2};bindingConfiguration:{3};binding:{4};",
channelEndpointElement.Kind,
channelEndpointElement.EndpointConfiguration,
address,
channelEndpointElement.BindingConfiguration,
channelEndpointElement.Binding);
}
}
}

View File

@@ -0,0 +1,13 @@
//------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------
namespace System.ServiceModel.Discovery.Configuration
{
using System.ServiceModel.Configuration;
using System.ServiceModel.Discovery;
public class AnnouncementEndpointCollectionElement : StandardEndpointCollectionElement<AnnouncementEndpoint, AnnouncementEndpointElement>
{
}
}

View File

@@ -0,0 +1,140 @@
//------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------
namespace System.ServiceModel.Discovery.Configuration
{
using System;
using System.ComponentModel;
using System.Configuration;
using System.Diagnostics.CodeAnalysis;
using System.Runtime;
using System.ServiceModel.Configuration;
using System.ServiceModel.Description;
using SR2 = System.ServiceModel.Discovery.SR;
public class AnnouncementEndpointElement : StandardEndpointElement
{
ConfigurationPropertyCollection properties;
public AnnouncementEndpointElement()
: base()
{
}
[ConfigurationProperty(ConfigurationStrings.MaxAnnouncementDelay, DefaultValue = ConfigurationStrings.TimeSpanZero)]
[TypeConverter(typeof(TimeSpanOrInfiniteConverter))]
[ServiceModelTimeSpanValidator(MinValueString = ConfigurationStrings.TimeSpanZero)]
public TimeSpan MaxAnnouncementDelay
{
get
{
return (TimeSpan)base[ConfigurationStrings.MaxAnnouncementDelay];
}
set
{
base[ConfigurationStrings.MaxAnnouncementDelay] = value;
}
}
[ConfigurationProperty(ConfigurationStrings.DiscoveryVersion, DefaultValue = ProtocolStrings.VersionNameDefault)]
[TypeConverter(typeof(DiscoveryVersionConverter))]
[SuppressMessage(FxCop.Category.Configuration, FxCop.Rule.ConfigurationValidatorAttributeRule)]
public DiscoveryVersion DiscoveryVersion
{
get
{
return (DiscoveryVersion)base[ConfigurationStrings.DiscoveryVersion];
}
set
{
base[ConfigurationStrings.DiscoveryVersion] = value;
}
}
protected internal override Type EndpointType
{
get { return typeof(AnnouncementEndpoint); }
}
protected override ConfigurationPropertyCollection Properties
{
get
{
if (this.properties == null)
{
ConfigurationPropertyCollection properties = base.Properties;
properties.Add(
new ConfigurationProperty(
ConfigurationStrings.MaxAnnouncementDelay,
typeof(TimeSpan),
TimeSpan.Zero,
new TimeSpanOrInfiniteConverter(),
new TimeSpanOrInfiniteValidator(TimeSpan.Zero, TimeSpan.MaxValue),
ConfigurationPropertyOptions.None));
properties.Add(
new ConfigurationProperty(
ConfigurationStrings.DiscoveryVersion,
typeof(DiscoveryVersion),
DiscoveryVersion.DefaultDiscoveryVersion,
new DiscoveryVersionConverter(),
null,
ConfigurationPropertyOptions.None));
this.properties = properties;
}
return this.properties;
}
}
protected internal override ServiceEndpoint CreateServiceEndpoint(ContractDescription contractDescription)
{
return new AnnouncementEndpoint(this.DiscoveryVersion);
}
protected internal override void InitializeFrom(ServiceEndpoint endpoint)
{
base.InitializeFrom(endpoint);
AnnouncementEndpoint source = (AnnouncementEndpoint)endpoint;
this.MaxAnnouncementDelay = source.MaxAnnouncementDelay;
this.DiscoveryVersion = source.DiscoveryVersion;
}
protected override void OnInitializeAndValidate(ChannelEndpointElement channelEndpointElement)
{
if (!String.IsNullOrEmpty(channelEndpointElement.Contract))
{
throw FxTrace.Exception.AsError(new ConfigurationErrorsException(SR2.DiscoveryConfigContractSpecified(channelEndpointElement.Kind)));
}
}
protected override void OnInitializeAndValidate(ServiceEndpointElement serviceEndpointElement)
{
if (!String.IsNullOrEmpty(serviceEndpointElement.Contract))
{
throw FxTrace.Exception.AsError(new ConfigurationErrorsException(SR2.DiscoveryConfigContractSpecified(serviceEndpointElement.Kind)));
}
}
protected override void OnApplyConfiguration(ServiceEndpoint endpoint, ServiceEndpointElement serviceEndpointElement)
{
ApplyConfiguration(endpoint);
}
protected override void OnApplyConfiguration(ServiceEndpoint endpoint, ChannelEndpointElement serviceEndpointElement)
{
ApplyConfiguration(endpoint);
}
void ApplyConfiguration(ServiceEndpoint endpoint)
{
AnnouncementEndpoint announcementEndpoint = (AnnouncementEndpoint)endpoint;
announcementEndpoint.MaxAnnouncementDelay = this.MaxAnnouncementDelay;
}
}
}

View File

@@ -0,0 +1,69 @@
//----------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------
namespace System.ServiceModel.Discovery.Configuration
{
using System.Configuration;
using System.Runtime;
using System.ServiceModel.Configuration;
using System.ServiceModel.Description;
using SR2 = System.ServiceModel.Discovery.SR;
class ConfigurationDiscoveryEndpointProvider : DiscoveryEndpointProvider
{
readonly ChannelEndpointElement channelEndpointElement;
public ConfigurationDiscoveryEndpointProvider()
{
this.channelEndpointElement = ConfigurationUtility.GetDefaultDiscoveryEndpointElement();
}
public ConfigurationDiscoveryEndpointProvider(ChannelEndpointElement channelEndpointElement)
{
Fx.Assert(channelEndpointElement != null, "The channelEndpointElement parameter must be non null.");
ConfigurationDiscoveryEndpointProvider.ValidateAndGetDiscoveryEndpoint(channelEndpointElement);
this.channelEndpointElement = channelEndpointElement;
}
public override DiscoveryEndpoint GetDiscoveryEndpoint()
{
return ConfigurationDiscoveryEndpointProvider.ValidateAndGetDiscoveryEndpoint(this.channelEndpointElement);
}
static DiscoveryEndpoint ValidateAndGetDiscoveryEndpoint(ChannelEndpointElement channelEndpointElement)
{
if (string.IsNullOrEmpty(channelEndpointElement.Kind))
{
throw FxTrace.Exception.AsError(
new ConfigurationErrorsException(
SR2.DiscoveryConfigDiscoveryEndpointMissingKind(
typeof(DiscoveryEndpoint).FullName)));
}
ServiceEndpoint serviceEndpoint = ConfigLoader.LookupEndpoint(channelEndpointElement, null);
if (serviceEndpoint == null)
{
throw FxTrace.Exception.AsError(
new ConfigurationErrorsException(
SR2.DiscoveryConfigInvalidEndpointConfiguration(
channelEndpointElement.Kind)));
}
DiscoveryEndpoint discoveryEndpoint = serviceEndpoint as DiscoveryEndpoint;
if (discoveryEndpoint == null)
{
throw FxTrace.Exception.AsError(
new InvalidOperationException(
SR2.DiscoveryConfigInvalidDiscoveryEndpoint(
typeof(DiscoveryEndpoint).FullName,
channelEndpointElement.Kind,
serviceEndpoint.GetType().FullName)));
}
return discoveryEndpoint;
}
}
}

View File

@@ -0,0 +1,45 @@
//----------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------
namespace System.ServiceModel.Discovery.Configuration
{
static class ConfigurationStrings
{
public const string AnnouncementEndpoints = "announcementEndpoints";
public const string DiscoveryClient = "discoveryClient";
public const string DiscoveryClientSettings = "discoveryClientSettings";
public const string DiscoveryVersion = "discoveryVersion";
public const string Duration = "duration";
public const string Enabled = "enabled";
public const string Endpoint = "endpoint";
public const string Extensions = "extensions";
public const string FindCriteria = "findCriteria";
public const string IsSystemEndpoint = "isSystemEndpoint";
public const string MaxAnnouncementDelay = "maxAnnouncementDelay";
public const string MaxResponseDelay = "maxResponseDelay";
public const string MaxResults = "maxResults";
public const string MulticastAddress = "multicastAddress";
public const string Name = "name";
public const string Namespace = "namespace";
public const string DiscoveryMode = "discoveryMode";
public const string Scopes = "scopes";
public const string Scope = "scope";
public const string ScopeMatchBy = "scopeMatchBy";
public const string Types = "types";
public const string UdpDiscoveryEndpoint = "udpDiscoveryEndpoint";
// UDP transport settings
public const string TransportSettings = "transportSettings";
public const string DuplicateMessageHistoryLength = "duplicateMessageHistoryLength";
public const string MaxPendingMessageCount = "maxPendingMessageCount";
public const string MaxReceivedMessageSize = "maxReceivedMessageSize";
public const string MaxBufferPoolSize = "maxBufferPoolSize";
public const string MaxMulticastRetransmitCount = "maxMulticastRetransmitCount";
public const string MaxUnicastRetransmitCount = "maxUnicastRetransmitCount";
public const string MulticastInterfaceId = "multicastInterfaceId";
public const string SocketReceiveBufferSize = "socketReceiveBufferSize";
public const string TimeToLive = "timeToLive";
public const string TimeSpanZero = "00:00:00";
}
}

View File

@@ -0,0 +1,124 @@
//----------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------
namespace System.ServiceModel.Discovery.Configuration
{
using System.Configuration;
using System.Runtime;
using System.ServiceModel.Configuration;
using System.ServiceModel.Description;
using SR2 = System.ServiceModel.Discovery.SR;
class ConfigurationUtility
{
public static ChannelEndpointElement GetDefaultDiscoveryEndpointElement()
{
return new ChannelEndpointElement() { Kind = ConfigurationStrings.UdpDiscoveryEndpoint };
}
public static T LookupEndpoint<T>(ChannelEndpointElement channelEndpointElement) where T : ServiceEndpoint
{
Fx.Assert(channelEndpointElement != null, "The parameter channelEndpointElement must be non null.");
Fx.Assert(!string.IsNullOrEmpty(channelEndpointElement.Kind), "The Kind property of the specified channelEndpointElement parameter cannot be null or empty.");
return ConfigLoader.LookupEndpoint(channelEndpointElement, null) as T;
}
internal static void InitializeAndValidateUdpChannelEndpointElement(ChannelEndpointElement channelEndpointElement)
{
if (!(channelEndpointElement.Address == null || String.IsNullOrEmpty(channelEndpointElement.Address.ToString())))
{
throw FxTrace.Exception.AsError(new ConfigurationErrorsException(SR2.DiscoveryConfigAddressSpecifiedForUdpDiscoveryEndpoint(channelEndpointElement.Kind)));
}
channelEndpointElement.Address = null;
}
internal static void InitializeAndValidateUdpServiceEndpointElement(ServiceEndpointElement serviceEndpointElement)
{
if (!(serviceEndpointElement.Address == null || String.IsNullOrEmpty(serviceEndpointElement.Address.ToString())))
{
throw FxTrace.Exception.AsError(new ConfigurationErrorsException(SR2.DiscoveryConfigAddressSpecifiedForUdpDiscoveryEndpoint(serviceEndpointElement.Kind)));
}
serviceEndpointElement.Address = null;
if (serviceEndpointElement.ListenUri != null)
{
throw FxTrace.Exception.AsError(new ConfigurationErrorsException(SR2.DiscoveryConfigListenUriSpecifiedForUdpDiscoveryEndpoint(serviceEndpointElement.Kind)));
}
}
internal static TEndpoint LookupEndpointFromClientSection<TEndpoint>(string endpointConfigurationName) where TEndpoint : ServiceEndpoint
{
Fx.Assert(endpointConfigurationName != null, "The endpointConfigurationName parameter must be non null.");
TEndpoint retval = default(TEndpoint);
bool wildcard = string.Equals(endpointConfigurationName, "*", StringComparison.Ordinal);
ClientSection clientSection = ClientSection.GetSection();
foreach (ChannelEndpointElement channelEndpointElement in clientSection.Endpoints)
{
if (string.IsNullOrEmpty(channelEndpointElement.Kind))
{
continue;
}
if (endpointConfigurationName == channelEndpointElement.Name || wildcard)
{
TEndpoint endpoint = LookupEndpoint<TEndpoint>(channelEndpointElement);
if (endpoint != null)
{
if (retval != null)
{
if (wildcard)
{
throw FxTrace.Exception.AsError(
new InvalidOperationException(
SR2.DiscoveryConfigMultipleEndpointsMatchWildcard(
typeof(TEndpoint).FullName,
clientSection.SectionInformation.SectionName)));
}
else
{
throw FxTrace.Exception.AsError(
new InvalidOperationException(
SR2.DiscoveryConfigMultipleEndpointsMatch(
typeof(TEndpoint).FullName,
endpointConfigurationName,
clientSection.SectionInformation.SectionName)));
}
}
else
{
retval = endpoint;
}
}
}
}
if (retval == null)
{
if (wildcard)
{
throw FxTrace.Exception.AsError(
new InvalidOperationException(
SR2.DiscoveryConfigNoEndpointsMatchWildcard(
typeof(TEndpoint).FullName,
clientSection.SectionInformation.SectionName)));
}
else
{
throw FxTrace.Exception.AsError(
new InvalidOperationException(
SR2.DiscoveryConfigNoEndpointsMatch(
typeof(TEndpoint).FullName,
endpointConfigurationName,
clientSection.SectionInformation.SectionName)));
}
}
return retval;
}
}
}

View File

@@ -0,0 +1,90 @@
//----------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------
namespace System.ServiceModel.Discovery.Configuration
{
using System.Configuration;
using System.Diagnostics.CodeAnalysis;
using System.Runtime;
using System.ServiceModel.Description;
[Fx.Tag.XamlVisible(false)]
public sealed class ContractTypeNameElement : ConfigurationElement
{
ConfigurationPropertyCollection properties;
public ContractTypeNameElement()
{
}
public ContractTypeNameElement(string name, string ns)
{
this.Name = name;
this.Namespace = ns;
}
[ConfigurationProperty(ConfigurationStrings.Namespace, DefaultValue = NamingHelper.DefaultNamespace, Options = ConfigurationPropertyOptions.IsKey)]
[SuppressMessage(FxCop.Category.Configuration, FxCop.Rule.ConfigurationValidatorAttributeRule, Justification = "Validator not requiered")]
public string Namespace
{
get
{
return (string)base[ConfigurationStrings.Namespace];
}
set
{
base[ConfigurationStrings.Namespace] = value;
}
}
[ConfigurationProperty(ConfigurationStrings.Name, Options = ConfigurationPropertyOptions.IsKey | ConfigurationPropertyOptions.IsRequired)]
[StringValidator(MinLength = 1)]
public string Name
{
get
{
return (string)base[ConfigurationStrings.Name];
}
set
{
base[ConfigurationStrings.Name] = value;
}
}
protected override ConfigurationPropertyCollection Properties
{
get
{
if (this.properties == null)
{
ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection();
properties.Add(
new ConfigurationProperty(
ConfigurationStrings.Namespace,
typeof(string),
NamingHelper.DefaultNamespace,
null,
null,
System.Configuration.ConfigurationPropertyOptions.IsKey));
properties.Add(
new ConfigurationProperty(
ConfigurationStrings.Name,
typeof(string),
null,
null,
new StringValidator(1),
System.Configuration.ConfigurationPropertyOptions.IsKey |
System.Configuration.ConfigurationPropertyOptions.IsRequired));
this.properties = properties;
}
return this.properties;
}
}
}
}

View File

@@ -0,0 +1,20 @@
//----------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------
namespace System.ServiceModel.Discovery.Configuration
{
using System.Configuration;
using System.ServiceModel.Configuration;
using System.Xml;
[ConfigurationCollection(typeof(ContractTypeNameElement))]
public sealed class ContractTypeNameElementCollection : ServiceModelConfigurationElementCollection<ContractTypeNameElement>
{
protected override object GetElementKey(ConfigurationElement element)
{
ContractTypeNameElement contractTypeNameElement = (ContractTypeNameElement)element;
return new XmlQualifiedName(contractTypeNameElement.Name, contractTypeNameElement.Namespace);
}
}
}

View File

@@ -0,0 +1,132 @@
//----------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------
namespace System.ServiceModel.Discovery.Configuration
{
using System.Configuration;
using System.Diagnostics.CodeAnalysis;
using System.Runtime;
using System.ServiceModel.Channels;
using System.ServiceModel.Configuration;
using SR2 = System.ServiceModel.Discovery.SR;
[Fx.Tag.XamlVisible(false)]
public sealed class DiscoveryClientElement : BindingElementExtensionElement
{
ConfigurationPropertyCollection properties;
[ConfigurationProperty(ConfigurationStrings.Endpoint)]
[SuppressMessage(
FxCop.Category.Configuration,
FxCop.Rule.ConfigurationPropertyNameRule,
Justification = "The configuration name for this element is 'endpoint'.")]
public ChannelEndpointElement DiscoveryEndpoint
{
get
{
return (ChannelEndpointElement)base[ConfigurationStrings.Endpoint];
}
}
[ConfigurationProperty(ConfigurationStrings.FindCriteria)]
public FindCriteriaElement FindCriteria
{
get
{
return (FindCriteriaElement)base[ConfigurationStrings.FindCriteria];
}
}
[SuppressMessage(
FxCop.Category.Configuration,
FxCop.Rule.ConfigurationPropertyAttributeRule,
Justification = "This property only overrides the base property.")]
public override Type BindingElementType
{
get { return typeof(DiscoveryClientBindingElement); }
}
protected override ConfigurationPropertyCollection Properties
{
get
{
if (this.properties == null)
{
ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection();
properties.Add(
new ConfigurationProperty(
ConfigurationStrings.Endpoint,
typeof(ChannelEndpointElement),
null,
null,
null,
ConfigurationPropertyOptions.None));
properties.Add(
new ConfigurationProperty(
ConfigurationStrings.FindCriteria,
typeof(FindCriteriaElement),
null,
null,
null,
ConfigurationPropertyOptions.None));
this.properties = properties;
}
return this.properties;
}
}
public override void ApplyConfiguration(BindingElement bindingElement)
{
base.ApplyConfiguration(bindingElement);
DiscoveryClientBindingElement discoveryClientBindingElement = (DiscoveryClientBindingElement)bindingElement;
if (PropertyValueOrigin.Default == this.ElementInformation.Properties[ConfigurationStrings.Endpoint].ValueOrigin)
{
discoveryClientBindingElement.DiscoveryEndpointProvider = new ConfigurationDiscoveryEndpointProvider();
}
else
{
discoveryClientBindingElement.DiscoveryEndpointProvider = new ConfigurationDiscoveryEndpointProvider(this.DiscoveryEndpoint);
}
this.FindCriteria.ApplyConfiguration(discoveryClientBindingElement.FindCriteria);
}
public override void CopyFrom(ServiceModelExtensionElement from)
{
base.CopyFrom(from);
DiscoveryClientElement source = (DiscoveryClientElement)from;
if (PropertyValueOrigin.Default == this.ElementInformation.Properties[ConfigurationStrings.Endpoint].ValueOrigin)
{
ChannelEndpointElement udpChannelEndpointElement = ConfigurationUtility.GetDefaultDiscoveryEndpointElement();
udpChannelEndpointElement.Copy(source.DiscoveryEndpoint);
}
else
{
this.DiscoveryEndpoint.Copy(source.DiscoveryEndpoint);
}
this.FindCriteria.CopyFrom(source.FindCriteria);
}
protected internal override BindingElement CreateBindingElement()
{
DiscoveryClientBindingElement discoveryClientBindingElement = new DiscoveryClientBindingElement();
this.ApplyConfiguration(discoveryClientBindingElement);
return discoveryClientBindingElement;
}
protected internal override void InitializeFrom(BindingElement bindingElement)
{
throw FxTrace.Exception.AsError(
new NotSupportedException(SR2.DiscoveryConfigInitializeFromNotSupported));
}
}
}

View File

@@ -0,0 +1,73 @@
//------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------
namespace System.ServiceModel.Discovery.Configuration
{
using System.Configuration;
using System.Diagnostics.CodeAnalysis;
using System.Runtime;
using System.ServiceModel.Configuration;
[Fx.Tag.XamlVisible(false)]
public sealed class DiscoveryClientSettingsElement : ConfigurationElement
{
ConfigurationPropertyCollection properties;
[ConfigurationProperty(ConfigurationStrings.Endpoint)]
[SuppressMessage(
FxCop.Category.Configuration,
FxCop.Rule.ConfigurationPropertyNameRule,
Justification = "The configuration name for this element is 'endpoint'.")]
public ChannelEndpointElement DiscoveryEndpoint
{
get
{
return (ChannelEndpointElement)base[ConfigurationStrings.Endpoint];
}
}
[ConfigurationProperty(ConfigurationStrings.FindCriteria)]
public FindCriteriaElement FindCriteria
{
get
{
return (FindCriteriaElement)base[ConfigurationStrings.FindCriteria];
}
}
protected override ConfigurationPropertyCollection Properties
{
get
{
if (this.properties == null)
{
ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection();
properties.Add(
new ConfigurationProperty(
ConfigurationStrings.Endpoint,
typeof(ChannelEndpointElement),
null,
null,
null,
ConfigurationPropertyOptions.None));
properties.Add(
new ConfigurationProperty(
ConfigurationStrings.FindCriteria,
typeof(FindCriteriaElement),
null,
null,
null,
ConfigurationPropertyOptions.None));
this.properties = properties;
}
return this.properties;
}
}
}
}

View File

@@ -0,0 +1,13 @@
//------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------
namespace System.ServiceModel.Discovery.Configuration
{
using System.ServiceModel.Configuration;
using System.ServiceModel.Discovery;
public class DiscoveryEndpointCollectionElement : StandardEndpointCollectionElement<DiscoveryEndpoint, DiscoveryEndpointElement>
{
}
}

View File

@@ -0,0 +1,169 @@
//------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------
namespace System.ServiceModel.Discovery.Configuration
{
using System;
using System.ComponentModel;
using System.Configuration;
using System.Diagnostics.CodeAnalysis;
using System.Runtime;
using System.ServiceModel.Configuration;
using System.ServiceModel.Description;
using SR2 = System.ServiceModel.Discovery.SR;
public class DiscoveryEndpointElement : StandardEndpointElement
{
ConfigurationPropertyCollection properties;
public DiscoveryEndpointElement() : base()
{
}
[ConfigurationProperty(ConfigurationStrings.MaxResponseDelay, DefaultValue = ConfigurationStrings.TimeSpanZero)]
[TypeConverter(typeof(TimeSpanOrInfiniteConverter))]
[ServiceModelTimeSpanValidator(MinValueString = ConfigurationStrings.TimeSpanZero)]
public TimeSpan MaxResponseDelay
{
get
{
return (TimeSpan)base[ConfigurationStrings.MaxResponseDelay];
}
set
{
base[ConfigurationStrings.MaxResponseDelay] = value;
}
}
[ConfigurationProperty(ConfigurationStrings.DiscoveryMode, DefaultValue = ServiceDiscoveryMode.Managed)]
[SuppressMessage(FxCop.Category.Configuration, FxCop.Rule.ConfigurationValidatorAttributeRule)]
public ServiceDiscoveryMode DiscoveryMode
{
get
{
return (ServiceDiscoveryMode)base[ConfigurationStrings.DiscoveryMode];
}
set
{
base[ConfigurationStrings.DiscoveryMode] = value;
}
}
[ConfigurationProperty(ConfigurationStrings.DiscoveryVersion, DefaultValue = ProtocolStrings.VersionNameDefault)]
[TypeConverter(typeof(DiscoveryVersionConverter))]
[SuppressMessage(FxCop.Category.Configuration, FxCop.Rule.ConfigurationValidatorAttributeRule)]
public DiscoveryVersion DiscoveryVersion
{
get
{
return (DiscoveryVersion)base[ConfigurationStrings.DiscoveryVersion];
}
set
{
base[ConfigurationStrings.DiscoveryVersion] = value;
}
}
protected internal override Type EndpointType
{
get { return typeof(DiscoveryEndpoint); }
}
protected override ConfigurationPropertyCollection Properties
{
get
{
if (this.properties == null)
{
ConfigurationPropertyCollection properties = base.Properties;
properties.Add(
new ConfigurationProperty(
ConfigurationStrings.MaxResponseDelay,
typeof(TimeSpan),
TimeSpan.Zero,
new TimeSpanOrInfiniteConverter(),
new TimeSpanOrInfiniteValidator(TimeSpan.Zero, TimeSpan.MaxValue),
ConfigurationPropertyOptions.None));
properties.Add(
new ConfigurationProperty(
ConfigurationStrings.DiscoveryVersion,
typeof(DiscoveryVersion),
DiscoveryVersion.DefaultDiscoveryVersion,
new DiscoveryVersionConverter(),
null,
ConfigurationPropertyOptions.None));
properties.Add(
new ConfigurationProperty(
ConfigurationStrings.DiscoveryMode,
typeof(ServiceDiscoveryMode),
ServiceDiscoveryMode.Managed,
null,
null,
ConfigurationPropertyOptions.None));
this.properties = properties;
}
return this.properties;
}
}
protected internal override ServiceEndpoint CreateServiceEndpoint(ContractDescription contractDescription)
{
return new DiscoveryEndpoint(this.DiscoveryVersion, this.DiscoveryMode);
}
protected internal override void InitializeFrom(ServiceEndpoint endpoint)
{
base.InitializeFrom(endpoint);
DiscoveryEndpoint source = (DiscoveryEndpoint)endpoint;
this.MaxResponseDelay = source.MaxResponseDelay;
this.DiscoveryVersion = source.DiscoveryVersion;
this.DiscoveryMode = source.DiscoveryMode;
}
protected override void OnInitializeAndValidate(ChannelEndpointElement channelEndpointElement)
{
if (!String.IsNullOrEmpty(channelEndpointElement.Contract))
{
throw FxTrace.Exception.AsError(new ConfigurationErrorsException(SR2.DiscoveryConfigContractSpecified(channelEndpointElement.Kind)));
}
}
protected override void OnInitializeAndValidate(ServiceEndpointElement serviceEndpointElement)
{
if (!String.IsNullOrEmpty(serviceEndpointElement.Contract))
{
throw FxTrace.Exception.AsError(new ConfigurationErrorsException(SR2.DiscoveryConfigContractSpecified(serviceEndpointElement.Kind)));
}
if (PropertyValueOrigin.Default == serviceEndpointElement.ElementInformation.Properties[ConfigurationStrings.IsSystemEndpoint].ValueOrigin)
{
serviceEndpointElement.IsSystemEndpoint = true;
}
}
protected override void OnApplyConfiguration(ServiceEndpoint endpoint, ServiceEndpointElement serviceEndpointElement)
{
ApplyConfiguration(endpoint);
}
protected override void OnApplyConfiguration(ServiceEndpoint endpoint, ChannelEndpointElement serviceEndpointElement)
{
ApplyConfiguration(endpoint);
}
void ApplyConfiguration(ServiceEndpoint endpoint)
{
DiscoveryEndpoint discoveryEndpoint = (DiscoveryEndpoint)endpoint;
discoveryEndpoint.MaxResponseDelay = this.MaxResponseDelay;
}
}
}

View File

@@ -0,0 +1,57 @@
//----------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------
namespace System.ServiceModel.Discovery.Configuration
{
using System.ComponentModel;
using System.ComponentModel.Design.Serialization;
using System.Globalization;
public class DiscoveryVersionConverter : TypeConverter
{
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
if (typeof(string) == sourceType)
{
return true;
}
return base.CanConvertFrom(context, sourceType);
}
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
{
if (typeof(InstanceDescriptor) == destinationType)
{
return true;
}
return base.CanConvertTo(context, destinationType);
}
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
{
if (value is string)
{
return DiscoveryVersion.FromName((string)value);
}
else
{
return base.ConvertFrom(context, culture, value);
}
}
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
if (typeof(string) == destinationType && value is DiscoveryVersion)
{
return ((DiscoveryVersion)value).Name;
}
else
{
return base.ConvertTo(context, culture, value, destinationType);
}
}
}
}

View File

@@ -0,0 +1,13 @@
//------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------
namespace System.ServiceModel.Discovery.Configuration
{
using System.ServiceModel.Configuration;
using System.ServiceModel.Discovery;
public class DynamicEndpointCollectionElement : StandardEndpointCollectionElement<DynamicEndpoint, DynamicEndpointElement>
{
}
}

View File

@@ -0,0 +1,123 @@
//------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------
namespace System.ServiceModel.Discovery.Configuration
{
using System;
using System.Configuration;
using System.Diagnostics.CodeAnalysis;
using System.Runtime;
using System.ServiceModel.Channels;
using System.ServiceModel.Configuration;
using System.ServiceModel.Description;
using System.Xml;
[Fx.Tag.XamlVisible(false)]
public sealed class DynamicEndpointElement : StandardEndpointElement
{
ConfigurationPropertyCollection properties;
[ConfigurationProperty(ConfigurationStrings.DiscoveryClientSettings)]
[SuppressMessage(FxCop.Category.Configuration, FxCop.Rule.ConfigurationValidatorAttributeRule, Justification = "No validator requiered.")]
public DiscoveryClientSettingsElement DiscoveryClientSettings
{
get
{
return (DiscoveryClientSettingsElement)base[ConfigurationStrings.DiscoveryClientSettings];
}
}
protected internal override Type EndpointType
{
get { return typeof(DynamicEndpoint); }
}
protected override ConfigurationPropertyCollection Properties
{
get
{
if (this.properties == null)
{
ConfigurationPropertyCollection properties = base.Properties;
properties.Add(
new ConfigurationProperty(
ConfigurationStrings.DiscoveryClientSettings,
typeof(DiscoveryClientSettingsElement),
null,
null,
null,
ConfigurationPropertyOptions.None));
this.properties = properties;
}
return this.properties;
}
}
protected internal override ServiceEndpoint CreateServiceEndpoint(ContractDescription contractDescription)
{
return new DynamicEndpoint(contractDescription);
}
protected override void OnInitializeAndValidate(ChannelEndpointElement channelEndpointElement)
{
if (string.IsNullOrEmpty(channelEndpointElement.Contract))
{
throw FxTrace.Exception.AsError(
new ConfigurationErrorsException(
SR.DiscoveryConfigContractNotSpecified(channelEndpointElement.Kind)));
}
if (channelEndpointElement.Address != null && !channelEndpointElement.Address.Equals(DiscoveryClientBindingElement.DiscoveryEndpointAddress.Uri))
{
throw FxTrace.Exception.AsError(
new ConfigurationErrorsException(
SR.DiscoveryEndpointAddressIncorrect(
"address",
channelEndpointElement.Address,
DiscoveryClientBindingElement.DiscoveryEndpointAddress.Uri)));
}
}
protected override void OnInitializeAndValidate(ServiceEndpointElement serviceEndpointElement)
{
throw FxTrace.Exception.AsError(
new InvalidOperationException(
SR.DiscoveryConfigDynamicEndpointInService(serviceEndpointElement.Kind)));
}
protected override void OnApplyConfiguration(ServiceEndpoint endpoint, ServiceEndpointElement serviceEndpointElement)
{
}
protected override void OnApplyConfiguration(ServiceEndpoint endpoint, ChannelEndpointElement serviceEndpointElement)
{
DynamicEndpoint dynamicEndpoint = (DynamicEndpoint)endpoint;
if (!dynamicEndpoint.ValidateAndInsertDiscoveryClientBindingElement(dynamicEndpoint.Binding))
{
throw FxTrace.Exception.AsError(new ConfigurationErrorsException(SR.DiscoveryClientBindingElementPresentInDynamicEndpoint));
}
if (PropertyValueOrigin.Default == this.DiscoveryClientSettings.ElementInformation.Properties[ConfigurationStrings.Endpoint].ValueOrigin)
{
dynamicEndpoint.DiscoveryEndpointProvider = new ConfigurationDiscoveryEndpointProvider();
}
else
{
dynamicEndpoint.DiscoveryEndpointProvider = new ConfigurationDiscoveryEndpointProvider(this.DiscoveryClientSettings.DiscoveryEndpoint);
}
this.DiscoveryClientSettings.FindCriteria.ApplyConfiguration(dynamicEndpoint.FindCriteria);
if (dynamicEndpoint.FindCriteria.ContractTypeNames.Count == 0)
{
dynamicEndpoint.FindCriteria.ContractTypeNames.Add(
new XmlQualifiedName(dynamicEndpoint.Contract.Name, dynamicEndpoint.Contract.Namespace));
}
}
}
}

View File

@@ -0,0 +1,160 @@
//----------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------
namespace System.ServiceModel.Discovery.Configuration
{
using System.Configuration;
using System.Diagnostics.CodeAnalysis;
using System.Runtime;
using System.ServiceModel.Configuration;
using System.Xml.Linq;
using System.Xml;
public sealed class EndpointDiscoveryElement : BehaviorExtensionElement
{
ConfigurationPropertyCollection properties;
public EndpointDiscoveryElement()
{
}
[SuppressMessage(FxCop.Category.Configuration, FxCop.Rule.ConfigurationPropertyAttributeRule,
Justification = "This property is defined by the base class to determine the type of the behavior.")]
public override Type BehaviorType
{
get
{
return typeof(EndpointDiscoveryBehavior);
}
}
[ConfigurationProperty(ConfigurationStrings.Enabled, DefaultValue = true)]
public bool Enabled
{
get
{
return (bool)base[ConfigurationStrings.Enabled];
}
set
{
base[ConfigurationStrings.Enabled] = value;
}
}
[ConfigurationProperty(ConfigurationStrings.Types)]
[SuppressMessage(
FxCop.Category.Configuration,
FxCop.Rule.ConfigurationPropertyNameRule,
Justification = "The configuration name for this element is 'types'.")]
public ContractTypeNameElementCollection ContractTypeNames
{
get
{
return (ContractTypeNameElementCollection)base[ConfigurationStrings.Types];
}
}
[ConfigurationProperty(ConfigurationStrings.Scopes)]
public ScopeElementCollection Scopes
{
get
{
return (ScopeElementCollection)base[ConfigurationStrings.Scopes];
}
}
[ConfigurationProperty(ConfigurationStrings.Extensions)]
public XmlElementElementCollection Extensions
{
get
{
return (XmlElementElementCollection)base[ConfigurationStrings.Extensions];
}
}
protected override ConfigurationPropertyCollection Properties
{
get
{
if (this.properties == null)
{
ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection();
properties.Add(
new ConfigurationProperty(
ConfigurationStrings.Enabled,
typeof(Boolean),
true,
null,
null,
ConfigurationPropertyOptions.None));
properties.Add(
new ConfigurationProperty(
ConfigurationStrings.Types,
typeof(ContractTypeNameElementCollection),
null,
null,
null,
ConfigurationPropertyOptions.None));
properties.Add(
new ConfigurationProperty(
ConfigurationStrings.Scopes,
typeof(ScopeElementCollection),
null,
null,
null,
ConfigurationPropertyOptions.None));
properties.Add(
new ConfigurationProperty(
ConfigurationStrings.Extensions,
typeof(XmlElementElementCollection),
null,
null,
null,
ConfigurationPropertyOptions.None));
this.properties = properties;
}
return this.properties;
}
}
protected internal override object CreateBehavior()
{
EndpointDiscoveryBehavior behavior = new EndpointDiscoveryBehavior();
behavior.Enabled = Enabled;
if ((Scopes != null) && (Scopes.Count > 0))
{
foreach (ScopeElement scopeElement in Scopes)
{
behavior.Scopes.Add(scopeElement.Scope);
}
}
if (ContractTypeNames != null)
{
foreach (ContractTypeNameElement contractTypeNameElement in ContractTypeNames)
{
behavior.ContractTypeNames.Add(
new XmlQualifiedName(contractTypeNameElement.Name, contractTypeNameElement.Namespace));
}
}
if ((Extensions != null) && (Extensions.Count > 0))
{
foreach (XmlElementElement xmlElement in Extensions)
{
behavior.Extensions.Add(XElement.Parse(xmlElement.XmlElement.OuterXml));
}
}
return behavior;
}
}
}

View File

@@ -0,0 +1,216 @@
//----------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------
namespace System.ServiceModel.Discovery.Configuration
{
using System.ComponentModel;
using System.Configuration;
using System.Diagnostics.CodeAnalysis;
using System.Runtime;
using System.ServiceModel.Configuration;
using System.Xml;
using System.Xml.Linq;
[Fx.Tag.XamlVisible(false)]
public sealed class FindCriteriaElement : ConfigurationElement
{
ConfigurationPropertyCollection properties;
[ConfigurationProperty(ConfigurationStrings.Types)]
[SuppressMessage(
FxCop.Category.Configuration,
FxCop.Rule.ConfigurationPropertyNameRule,
Justification = "The configuration name for this element is 'types'.")]
public ContractTypeNameElementCollection ContractTypeNames
{
get
{
return (ContractTypeNameElementCollection)base[ConfigurationStrings.Types];
}
}
[ConfigurationProperty(ConfigurationStrings.Scopes)]
public ScopeElementCollection Scopes
{
get
{
return (ScopeElementCollection)base[ConfigurationStrings.Scopes];
}
}
[ConfigurationProperty(ConfigurationStrings.ScopeMatchBy)]
[SuppressMessage(FxCop.Category.Configuration, FxCop.Rule.ConfigurationValidatorAttributeRule, Justification = "No validation requiered.")]
public Uri ScopeMatchBy
{
get
{
return (Uri)base[ConfigurationStrings.ScopeMatchBy];
}
set
{
if (value == null)
{
throw FxTrace.Exception.ArgumentNull("value");
}
base[ConfigurationStrings.ScopeMatchBy] = value;
}
}
[ConfigurationProperty(ConfigurationStrings.Extensions)]
public XmlElementElementCollection Extensions
{
get
{
return (XmlElementElementCollection)base[ConfigurationStrings.Extensions];
}
}
[ConfigurationProperty(ConfigurationStrings.Duration, DefaultValue = DiscoveryDefaults.DiscoveryOperationDurationString)]
[TypeConverter(typeof(TimeSpanOrInfiniteConverter))]
[ServiceModelTimeSpanValidator(MinValueString = "00:00:00.001")]
public TimeSpan Duration
{
get
{
return (TimeSpan)base[ConfigurationStrings.Duration];
}
set
{
base[ConfigurationStrings.Duration] = value;
}
}
[ConfigurationProperty(ConfigurationStrings.MaxResults, DefaultValue = int.MaxValue)]
[IntegerValidator(MinValue = 1, MaxValue = int.MaxValue)]
public int MaxResults
{
get
{
return (int)base[ConfigurationStrings.MaxResults];
}
set
{
base[ConfigurationStrings.MaxResults] = value;
}
}
protected override ConfigurationPropertyCollection Properties
{
get
{
if (this.properties == null)
{
ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection();
properties.Add(
new ConfigurationProperty(
ConfigurationStrings.Types,
typeof(ContractTypeNameElementCollection),
null,
null,
null,
ConfigurationPropertyOptions.None));
properties.Add(
new ConfigurationProperty(
ConfigurationStrings.ScopeMatchBy,
typeof(Uri),
DiscoveryDefaults.ScopeMatchBy,
null,
null,
ConfigurationPropertyOptions.None));
properties.Add(
new ConfigurationProperty(
ConfigurationStrings.Scopes,
typeof(ScopeElementCollection),
null,
null,
null,
ConfigurationPropertyOptions.None));
properties.Add(
new ConfigurationProperty(
ConfigurationStrings.Extensions,
typeof(XmlElementElementCollection),
null,
null,
null,
ConfigurationPropertyOptions.None));
properties.Add(
new ConfigurationProperty(
ConfigurationStrings.Duration,
typeof(TimeSpan),
TimeSpan.FromSeconds(20),
new TimeSpanOrInfiniteConverter(),
new TimeSpanOrInfiniteValidator(TimeSpan.FromMilliseconds(1), TimeSpan.MaxValue),
ConfigurationPropertyOptions.None));
properties.Add(
new ConfigurationProperty(
ConfigurationStrings.MaxResults,
typeof(int),
int.MaxValue,
null,
new IntegerValidator(1, int.MaxValue),
ConfigurationPropertyOptions.None));
this.properties = properties;
}
return this.properties;
}
}
internal void ApplyConfiguration(FindCriteria findCriteria)
{
foreach (ContractTypeNameElement contractTypeNameElement in this.ContractTypeNames)
{
findCriteria.ContractTypeNames.Add(
new XmlQualifiedName(
contractTypeNameElement.Name,
contractTypeNameElement.Namespace));
}
foreach (ScopeElement scopeElement in this.Scopes)
{
findCriteria.Scopes.Add(scopeElement.Scope);
}
foreach (XmlElementElement xmlElement in this.Extensions)
{
findCriteria.Extensions.Add(XElement.Parse(xmlElement.XmlElement.OuterXml));
}
findCriteria.ScopeMatchBy = this.ScopeMatchBy;
findCriteria.Duration = this.Duration;
findCriteria.MaxResults = this.MaxResults;
}
internal void CopyFrom(FindCriteriaElement source)
{
foreach (ContractTypeNameElement contractTypeNameElement in source.ContractTypeNames)
{
this.ContractTypeNames.Add(contractTypeNameElement);
}
foreach (ScopeElement scopeElement in source.Scopes)
{
this.Scopes.Add(scopeElement);
}
foreach (XmlElementElement extensionElement in source.Extensions)
{
this.Extensions.Add(extensionElement);
}
this.ScopeMatchBy = source.ScopeMatchBy;
this.Duration = source.Duration;
this.MaxResults = source.MaxResults;
}
}
}

View File

@@ -0,0 +1,62 @@
//----------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------
namespace System.ServiceModel.Discovery.Configuration
{
using System.Configuration;
using System.Runtime;
using SR2 = System.ServiceModel.Discovery.SR;
[Fx.Tag.XamlVisible(false)]
public sealed class ScopeElement : ConfigurationElement
{
ConfigurationPropertyCollection properties;
[ConfigurationProperty(ConfigurationStrings.Scope, Options = ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey)]
[CallbackValidator(CallbackMethodName = "ScopeValidatorCallback", Type = typeof(ScopeElement))]
public Uri Scope
{
get
{
return (Uri)base[ConfigurationStrings.Scope];
}
set
{
base[ConfigurationStrings.Scope] = value;
}
}
protected override ConfigurationPropertyCollection Properties
{
get
{
if (this.properties == null)
{
ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection();
properties.Add(
new ConfigurationProperty(
ConfigurationStrings.Scope,
typeof(Uri),
null,
null,
new CallbackValidator(typeof(Uri), new ValidatorCallback(ScopeElement.ScopeValidatorCallback)),
System.Configuration.ConfigurationPropertyOptions.IsRequired | System.Configuration.ConfigurationPropertyOptions.IsKey));
this.properties = properties;
}
return this.properties;
}
}
internal static void ScopeValidatorCallback(object scope)
{
if ((scope != null) && !((Uri)scope).IsAbsoluteUri)
{
throw FxTrace.Exception.AsError(new ArgumentException(SR2.DiscoveryConfigInvalidScopeUri(scope)));
}
}
}
}

View File

@@ -0,0 +1,23 @@
//----------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------
namespace System.ServiceModel.Discovery.Configuration
{
using System.Configuration;
using System.ServiceModel.Configuration;
[ConfigurationCollection(typeof(ScopeElement))]
public sealed class ScopeElementCollection : ServiceModelConfigurationElementCollection<ScopeElement>
{
protected override object GetElementKey(ConfigurationElement element)
{
if (element == null)
{
throw FxTrace.Exception.ArgumentNull("element");
}
return ((ScopeElement)element).Scope;
}
}
}

View File

@@ -0,0 +1,105 @@
//----------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------
namespace System.ServiceModel.Discovery.Configuration
{
using System.Configuration;
using System.Diagnostics.CodeAnalysis;
using System.Runtime;
using System.ServiceModel.Configuration;
using System.ServiceModel.Description;
using SR2 = System.ServiceModel.Discovery.SR;
public sealed class ServiceDiscoveryElement : BehaviorExtensionElement
{
ConfigurationPropertyCollection properties;
public ServiceDiscoveryElement()
{
}
[ConfigurationProperty(ConfigurationStrings.AnnouncementEndpoints)]
public AnnouncementChannelEndpointElementCollection AnnouncementEndpoints
{
get
{
return (AnnouncementChannelEndpointElementCollection)base[ConfigurationStrings.AnnouncementEndpoints];
}
}
[SuppressMessage(FxCop.Category.Configuration, FxCop.Rule.ConfigurationPropertyAttributeRule,
Justification = "This property is defined by the base class to determine the type of the behavior.")]
public override Type BehaviorType
{
get
{
return typeof(ServiceDiscoveryBehavior);
}
}
protected override ConfigurationPropertyCollection Properties
{
get
{
if (this.properties == null)
{
ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection();
properties.Add(
new ConfigurationProperty(
ConfigurationStrings.AnnouncementEndpoints,
typeof(AnnouncementChannelEndpointElementCollection),
null,
null,
null,
ConfigurationPropertyOptions.None));
this.properties = properties;
}
return this.properties;
}
}
protected internal override object CreateBehavior()
{
ServiceDiscoveryBehavior serviceDiscoveryBehavior = new ServiceDiscoveryBehavior();
AnnouncementEndpoint announcementEndpoint;
foreach (ChannelEndpointElement channelEndpointElement in this.AnnouncementEndpoints)
{
if (string.IsNullOrEmpty(channelEndpointElement.Kind))
{
throw FxTrace.Exception.AsError(
new ConfigurationErrorsException(
SR2.DiscoveryConfigAnnouncementEndpointMissingKind(
typeof(AnnouncementEndpoint).FullName)));
}
ServiceEndpoint serviceEndpoint = ConfigLoader.LookupEndpoint(channelEndpointElement, null);
if (serviceEndpoint == null)
{
throw FxTrace.Exception.AsError(
new ConfigurationErrorsException(
SR2.DiscoveryConfigInvalidEndpointConfiguration(
channelEndpointElement.Kind)));
}
announcementEndpoint = serviceEndpoint as AnnouncementEndpoint;
if (announcementEndpoint == null)
{
throw FxTrace.Exception.AsError(
new InvalidOperationException(
SR2.DiscoveryConfigInvalidAnnouncementEndpoint(
channelEndpointElement.Kind,
serviceEndpoint.GetType().FullName,
typeof(AnnouncementEndpoint).FullName)));
}
serviceDiscoveryBehavior.AnnouncementEndpoints.Add(announcementEndpoint);
}
return serviceDiscoveryBehavior;
}
}
}

Some files were not shown because too many files have changed in this diff Show More