You've already forked linux-packaging-mono
Imported Upstream version 4.0.0~alpha1
Former-commit-id: 806294f5ded97629b74c85c09952f2a74fe182d9
This commit is contained in:
@ -0,0 +1,78 @@
|
||||
// <copyright>
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
|
||||
namespace System.ServiceModel.Web.Configuration
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Specialized;
|
||||
using System.Configuration;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime;
|
||||
using System.Security.Permissions;
|
||||
|
||||
internal static class AppSettings
|
||||
{
|
||||
private const string EnableAutomaticEndpointsCompatabilityString = "wcf:webservicehost:enableautomaticendpointscompatability";
|
||||
private const string DisableHtmlErrorPageExceptionHtmlEncodingString = "wcf:web:HtmlErrorPage:DisableExceptionMessageHtmlEncoding";
|
||||
private static readonly object appSettingsLock = new object();
|
||||
private static bool enableAutomaticEndpointCompat = false;
|
||||
private static bool disableHtmlErrorPageExceptionHtmlEncoding = false;
|
||||
private static volatile bool settingsInitialized = false;
|
||||
|
||||
public static bool EnableAutomaticEndpointsCompatibility
|
||||
{
|
||||
get
|
||||
{
|
||||
EnsureSettingsLoaded();
|
||||
return enableAutomaticEndpointCompat;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool DisableHtmlErrorPageExceptionHtmlEncoding
|
||||
{
|
||||
get
|
||||
{
|
||||
EnsureSettingsLoaded();
|
||||
return disableHtmlErrorPageExceptionHtmlEncoding;
|
||||
}
|
||||
}
|
||||
|
||||
[SuppressMessage(FxCop.Category.ReliabilityBasic, "Reliability104:CaughtAndHandledExceptionsRule",
|
||||
Justification = "Handle the configuration exceptions here to avoid regressions on customer's existing scenarios")]
|
||||
private static void EnsureSettingsLoaded()
|
||||
{
|
||||
if (!settingsInitialized)
|
||||
{
|
||||
lock (appSettingsLock)
|
||||
{
|
||||
if (!settingsInitialized)
|
||||
{
|
||||
NameValueCollection appSettingsSection = null;
|
||||
try
|
||||
{
|
||||
appSettingsSection = ConfigurationManager.AppSettings;
|
||||
}
|
||||
catch (ConfigurationErrorsException)
|
||||
{
|
||||
}
|
||||
finally
|
||||
{
|
||||
if ((appSettingsSection == null) || !bool.TryParse(appSettingsSection[EnableAutomaticEndpointsCompatabilityString], out enableAutomaticEndpointCompat))
|
||||
{
|
||||
enableAutomaticEndpointCompat = false;
|
||||
}
|
||||
|
||||
if ((appSettingsSection == null) || !bool.TryParse(appSettingsSection[DisableHtmlErrorPageExceptionHtmlEncodingString], out disableHtmlErrorPageExceptionHtmlEncoding))
|
||||
{
|
||||
disableHtmlErrorPageExceptionHtmlEncoding = false;
|
||||
}
|
||||
|
||||
settingsInitialized = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace System.ServiceModel.Configuration
|
||||
{
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Configuration;
|
||||
using System.Reflection;
|
||||
using System.ServiceModel.Channels;
|
||||
|
||||
internal class InternalEnumValidator : ConfigurationValidatorBase
|
||||
{
|
||||
Type enumHelperType;
|
||||
MethodInfo isDefined;
|
||||
|
||||
public InternalEnumValidator(Type enumHelperType)
|
||||
{
|
||||
this.enumHelperType = enumHelperType;
|
||||
this.isDefined = this.enumHelperType.GetMethod("IsDefined", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public);
|
||||
}
|
||||
|
||||
public override bool CanValidate(Type type)
|
||||
{
|
||||
return (this.isDefined != null);
|
||||
}
|
||||
|
||||
public override void Validate(object value)
|
||||
{
|
||||
bool retVal = (bool) this.isDefined.Invoke(null, new object[] { value });
|
||||
|
||||
if (!retVal)
|
||||
{
|
||||
ParameterInfo[] isDefinedParameters = this.isDefined.GetParameters();
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidEnumArgumentException("value", (int) value, isDefinedParameters[0].ParameterType));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace System.ServiceModel.Configuration
|
||||
{
|
||||
using System;
|
||||
using System.Configuration;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Property)]
|
||||
internal sealed class InternalEnumValidatorAttribute : ConfigurationValidatorAttribute
|
||||
{
|
||||
Type enumHelperType;
|
||||
|
||||
public InternalEnumValidatorAttribute(Type enumHelperType)
|
||||
{
|
||||
this.EnumHelperType = enumHelperType;
|
||||
}
|
||||
|
||||
public Type EnumHelperType
|
||||
{
|
||||
get { return this.enumHelperType; }
|
||||
set { this.enumHelperType = value; }
|
||||
}
|
||||
|
||||
public override ConfigurationValidatorBase ValidatorInstance
|
||||
{
|
||||
get { return new InternalEnumValidator(enumHelperType); }
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------------------------
|
||||
namespace System.ServiceModel.Configuration
|
||||
{
|
||||
using System;
|
||||
using System.ServiceModel.Channels;
|
||||
using System.ServiceModel;
|
||||
using System.ServiceModel.Dispatcher;
|
||||
using System.ServiceModel.Description;
|
||||
using System.Configuration;
|
||||
using System.Globalization;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.ServiceModel.Diagnostics;
|
||||
|
||||
internal static class WebConfigurationStrings
|
||||
{
|
||||
internal const string DefaultBodyStyle = "defaultBodyStyle";
|
||||
internal const string HelpEnabled = "helpEnabled";
|
||||
internal const string DefaultOutgoingResponseFormat = "defaultOutgoingResponseFormat";
|
||||
internal const string AutomaticFormatSelectionEnabled = "automaticFormatSelectionEnabled";
|
||||
internal const string ContentTypeMapper = "contentTypeMapper";
|
||||
internal const string CrossDomainScriptAccessEnabled = "crossDomainScriptAccessEnabled";
|
||||
internal const string FaultExceptionEnabled = "faultExceptionEnabled";
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
namespace System.ServiceModel.Configuration
|
||||
{
|
||||
using System;
|
||||
using System.Configuration;
|
||||
using System.ServiceModel.Channels;
|
||||
using System.Text;
|
||||
|
||||
class WebEncodingValidator : ConfigurationValidatorBase
|
||||
{
|
||||
public override bool CanValidate(Type type)
|
||||
{
|
||||
return type == typeof(Encoding);
|
||||
}
|
||||
|
||||
public override void Validate(object value)
|
||||
{
|
||||
Encoding encoding = value as Encoding;
|
||||
if ((encoding == null) ||
|
||||
// utf-8 case. EncodingConverter generates TextEncoderDefaults.Encoding for utf-8, different from System.Text.Encoding.UTF8
|
||||
((encoding.WebName != Encoding.UTF8.WebName) &&
|
||||
(encoding.WebName != Encoding.Unicode.WebName) &&
|
||||
(encoding.WebName != Encoding.BigEndianUnicode.WebName)))
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("value", SR2.GetString(SR2.JsonEncodingNotSupported));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
namespace System.ServiceModel.Configuration
|
||||
{
|
||||
using System;
|
||||
using System.Configuration;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Property)]
|
||||
sealed class WebEncodingValidatorAttribute : ConfigurationValidatorAttribute
|
||||
{
|
||||
public WebEncodingValidatorAttribute()
|
||||
{
|
||||
}
|
||||
|
||||
public override ConfigurationValidatorBase ValidatorInstance
|
||||
{
|
||||
get { return new WebEncodingValidator(); }
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace System.ServiceModel.Configuration
|
||||
{
|
||||
using System.ServiceModel;
|
||||
using System.ServiceModel.Activation;
|
||||
using System.ServiceModel.Channels;
|
||||
|
||||
public partial class WebHttpBindingCollectionElement : StandardBindingCollectionElement<WebHttpBinding, WebHttpBindingElement>
|
||||
{
|
||||
|
||||
protected internal override Binding GetDefault()
|
||||
{
|
||||
return new WebHttpBinding();
|
||||
}
|
||||
|
||||
internal static WebHttpBindingCollectionElement GetBindingCollectionElement()
|
||||
{
|
||||
string sectionPath = "system.serviceModel/bindings";
|
||||
|
||||
BindingsSection bindings = (BindingsSection)AspNetEnvironment.Current.GetConfigurationSection(sectionPath);
|
||||
|
||||
return (WebHttpBindingCollectionElement)bindings[WebHttpBinding.WebHttpBindingConfigurationStrings.WebHttpBindingCollectionElementName];
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,307 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace System.ServiceModel.Configuration
|
||||
{
|
||||
using System.ComponentModel;
|
||||
using System.Configuration;
|
||||
using System.ServiceModel;
|
||||
using System.ServiceModel.Channels;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
public partial class WebHttpBindingElement : StandardBindingElement
|
||||
{
|
||||
static readonly Type WebContentTypeMapperType = typeof(WebContentTypeMapper);
|
||||
|
||||
ConfigurationPropertyCollection properties;
|
||||
|
||||
public WebHttpBindingElement(string name)
|
||||
: base(name)
|
||||
{
|
||||
}
|
||||
|
||||
public WebHttpBindingElement()
|
||||
: this(null)
|
||||
{
|
||||
}
|
||||
|
||||
[ConfigurationProperty(ConfigurationStrings.AllowCookies, DefaultValue = HttpTransportDefaults.AllowCookies)]
|
||||
public bool AllowCookies
|
||||
{
|
||||
get { return (bool)base[ConfigurationStrings.AllowCookies]; }
|
||||
set { base[ConfigurationStrings.AllowCookies] = value; }
|
||||
|
||||
}
|
||||
|
||||
[ConfigurationProperty(ConfigurationStrings.BypassProxyOnLocal, DefaultValue = HttpTransportDefaults.BypassProxyOnLocal)]
|
||||
public bool BypassProxyOnLocal
|
||||
{
|
||||
get { return (bool)base[ConfigurationStrings.BypassProxyOnLocal]; }
|
||||
set { base[ConfigurationStrings.BypassProxyOnLocal] = value; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(ConfigurationStrings.HostNameComparisonMode, DefaultValue = HttpTransportDefaults.HostNameComparisonMode)]
|
||||
[ServiceModelEnumValidator(typeof(HostNameComparisonModeHelper))]
|
||||
public HostNameComparisonMode HostNameComparisonMode
|
||||
{
|
||||
get { return (HostNameComparisonMode)base[ConfigurationStrings.HostNameComparisonMode]; }
|
||||
set { base[ConfigurationStrings.HostNameComparisonMode] = value; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(ConfigurationStrings.MaxBufferPoolSize, DefaultValue = TransportDefaults.MaxBufferPoolSize)]
|
||||
[LongValidator(MinValue = 0)]
|
||||
public long MaxBufferPoolSize
|
||||
{
|
||||
get { return (long)base[ConfigurationStrings.MaxBufferPoolSize]; }
|
||||
set { base[ConfigurationStrings.MaxBufferPoolSize] = value; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(ConfigurationStrings.MaxBufferSize, DefaultValue = TransportDefaults.MaxBufferSize)]
|
||||
[IntegerValidator(MinValue = 1)]
|
||||
public int MaxBufferSize
|
||||
{
|
||||
get { return (int)base[ConfigurationStrings.MaxBufferSize]; }
|
||||
set { base[ConfigurationStrings.MaxBufferSize] = value; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(ConfigurationStrings.MaxReceivedMessageSize, DefaultValue = TransportDefaults.MaxReceivedMessageSize)]
|
||||
[LongValidator(MinValue = 1)]
|
||||
public long MaxReceivedMessageSize
|
||||
{
|
||||
get { return (long)base[ConfigurationStrings.MaxReceivedMessageSize]; }
|
||||
set { base[ConfigurationStrings.MaxReceivedMessageSize] = value; }
|
||||
}
|
||||
|
||||
[SuppressMessage("Configuration", "Configuration104:ConfigurationValidatorAttributeRule", MessageId = "System.ServiceModel.Configuration.WebHttpBindingElement.ProxyAddress", Justification = "The configuration system converts the config string to a Uri and vice versa")]
|
||||
[ConfigurationProperty(ConfigurationStrings.ProxyAddress, DefaultValue = HttpTransportDefaults.ProxyAddress)]
|
||||
public Uri ProxyAddress
|
||||
{
|
||||
get { return (Uri)base[ConfigurationStrings.ProxyAddress]; }
|
||||
set { base[ConfigurationStrings.ProxyAddress] = value; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(ConfigurationStrings.ReaderQuotas)]
|
||||
public XmlDictionaryReaderQuotasElement ReaderQuotas
|
||||
{
|
||||
get { return (XmlDictionaryReaderQuotasElement)base[ConfigurationStrings.ReaderQuotas]; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(ConfigurationStrings.Security)]
|
||||
public WebHttpSecurityElement Security
|
||||
{
|
||||
get { return (WebHttpSecurityElement)base[ConfigurationStrings.Security]; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(ConfigurationStrings.TransferMode, DefaultValue = WebHttpBindingDefaults.TransferMode)]
|
||||
[ServiceModelEnumValidator(typeof(TransferModeHelper))]
|
||||
public TransferMode TransferMode
|
||||
{
|
||||
get { return (TransferMode)base[ConfigurationStrings.TransferMode]; }
|
||||
set { base[ConfigurationStrings.TransferMode] = value; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(ConfigurationStrings.UseDefaultWebProxy, DefaultValue = HttpTransportDefaults.UseDefaultWebProxy)]
|
||||
public bool UseDefaultWebProxy
|
||||
{
|
||||
get { return (bool)base[ConfigurationStrings.UseDefaultWebProxy]; }
|
||||
set { base[ConfigurationStrings.UseDefaultWebProxy] = value; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(ConfigurationStrings.WriteEncoding, DefaultValue = TextEncoderDefaults.EncodingString)]
|
||||
[TypeConverter(typeof(EncodingConverter))]
|
||||
[WebEncodingValidator]
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Configuration", "Configuration104:ConfigurationValidatorAttributeRule", MessageId = "System.ServiceModel.Configuration.WebHttpBindingElement.WriteEncoding",
|
||||
Justification = "Bug with internal FxCop assembly flags this property as not having a validator.")]
|
||||
public Encoding WriteEncoding
|
||||
{
|
||||
get { return (Encoding)base[ConfigurationStrings.WriteEncoding]; }
|
||||
set { base[ConfigurationStrings.WriteEncoding] = value; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(WebConfigurationStrings.ContentTypeMapper, DefaultValue = "")]
|
||||
[StringValidator(MinLength = 0)]
|
||||
public string ContentTypeMapper
|
||||
{
|
||||
get { return (string)base[WebConfigurationStrings.ContentTypeMapper]; }
|
||||
set
|
||||
{
|
||||
if (String.IsNullOrEmpty(value))
|
||||
{
|
||||
value = String.Empty;
|
||||
}
|
||||
base[WebConfigurationStrings.ContentTypeMapper] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[ConfigurationProperty(WebConfigurationStrings.CrossDomainScriptAccessEnabled, DefaultValue = false)]
|
||||
public bool CrossDomainScriptAccessEnabled
|
||||
{
|
||||
get { return (bool)base[WebConfigurationStrings.CrossDomainScriptAccessEnabled]; }
|
||||
set
|
||||
{
|
||||
base[WebConfigurationStrings.CrossDomainScriptAccessEnabled] = value;
|
||||
}
|
||||
}
|
||||
|
||||
protected override Type BindingElementType
|
||||
{
|
||||
get { return typeof(WebHttpBinding); }
|
||||
}
|
||||
|
||||
protected override ConfigurationPropertyCollection Properties
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.properties == null)
|
||||
{
|
||||
ConfigurationPropertyCollection properties = base.Properties;
|
||||
properties.Add(new ConfigurationProperty("allowCookies", typeof(System.Boolean), false, null, null, System.Configuration.ConfigurationPropertyOptions.None));
|
||||
properties.Add(new ConfigurationProperty("bypassProxyOnLocal", typeof(System.Boolean), false, null, null, System.Configuration.ConfigurationPropertyOptions.None));
|
||||
properties.Add(new ConfigurationProperty("hostNameComparisonMode", typeof(System.ServiceModel.HostNameComparisonMode), System.ServiceModel.HostNameComparisonMode.StrongWildcard, null, new System.ServiceModel.Configuration.ServiceModelEnumValidator(typeof(System.ServiceModel.HostNameComparisonModeHelper)), System.Configuration.ConfigurationPropertyOptions.None));
|
||||
properties.Add(new ConfigurationProperty("maxBufferSize", typeof(System.Int32), 65536, null, new System.Configuration.IntegerValidator(1, 2147483647, false), System.Configuration.ConfigurationPropertyOptions.None));
|
||||
properties.Add(new ConfigurationProperty("maxBufferPoolSize", typeof(System.Int64), (long)524288, null, new System.Configuration.LongValidator(0, 9223372036854775807, false), System.Configuration.ConfigurationPropertyOptions.None));
|
||||
properties.Add(new ConfigurationProperty("maxReceivedMessageSize", typeof(System.Int64), (long)65536, null, new System.Configuration.LongValidator(1, 9223372036854775807, false), System.Configuration.ConfigurationPropertyOptions.None));
|
||||
properties.Add(new ConfigurationProperty("proxyAddress", typeof(System.Uri), HttpTransportDefaults.ProxyAddress, null, null, System.Configuration.ConfigurationPropertyOptions.None));
|
||||
properties.Add(new ConfigurationProperty("readerQuotas", typeof(System.ServiceModel.Configuration.XmlDictionaryReaderQuotasElement), null, null, null, System.Configuration.ConfigurationPropertyOptions.None));
|
||||
properties.Add(new ConfigurationProperty("security", typeof(System.ServiceModel.Configuration.WebHttpSecurityElement), null, null, null, System.Configuration.ConfigurationPropertyOptions.None));
|
||||
properties.Add(new ConfigurationProperty("writeEncoding", typeof(System.Text.Encoding), "utf-8", new System.ServiceModel.Configuration.EncodingConverter(), null, System.Configuration.ConfigurationPropertyOptions.None));
|
||||
properties.Add(new ConfigurationProperty("transferMode", typeof(System.ServiceModel.TransferMode), System.ServiceModel.TransferMode.Buffered, null, new System.ServiceModel.Configuration.ServiceModelEnumValidator(typeof(System.ServiceModel.TransferModeHelper)), System.Configuration.ConfigurationPropertyOptions.None));
|
||||
properties.Add(new ConfigurationProperty("useDefaultWebProxy", typeof(System.Boolean), true, null, null, System.Configuration.ConfigurationPropertyOptions.None));
|
||||
properties.Add(new ConfigurationProperty("contentTypeMapper", typeof(string), string.Empty, null, new System.Configuration.StringValidator(0), System.Configuration.ConfigurationPropertyOptions.None));
|
||||
properties.Add(new ConfigurationProperty(WebConfigurationStrings.CrossDomainScriptAccessEnabled, typeof(System.Boolean), false, null, null, System.Configuration.ConfigurationPropertyOptions.None));
|
||||
this.properties = properties;
|
||||
}
|
||||
return this.properties;
|
||||
}
|
||||
}
|
||||
|
||||
internal protected override void InitializeFrom(Binding binding)
|
||||
{
|
||||
base.InitializeFrom(binding);
|
||||
WebHttpBinding webBinding = (WebHttpBinding)binding;
|
||||
|
||||
SetPropertyValueIfNotDefaultValue(ConfigurationStrings.BypassProxyOnLocal, webBinding.BypassProxyOnLocal);
|
||||
SetPropertyValueIfNotDefaultValue(ConfigurationStrings.HostNameComparisonMode, webBinding.HostNameComparisonMode);
|
||||
SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MaxBufferSize, webBinding.MaxBufferSize);
|
||||
SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MaxBufferPoolSize, webBinding.MaxBufferPoolSize);
|
||||
SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MaxReceivedMessageSize, webBinding.MaxReceivedMessageSize);
|
||||
if (webBinding.ProxyAddress != null)
|
||||
{
|
||||
SetPropertyValueIfNotDefaultValue(ConfigurationStrings.ProxyAddress, webBinding.ProxyAddress);
|
||||
}
|
||||
SetPropertyValueIfNotDefaultValue(ConfigurationStrings.WriteEncoding, webBinding.WriteEncoding);
|
||||
SetPropertyValueIfNotDefaultValue(ConfigurationStrings.TransferMode, webBinding.TransferMode);
|
||||
SetPropertyValueIfNotDefaultValue(ConfigurationStrings.UseDefaultWebProxy, webBinding.UseDefaultWebProxy);
|
||||
SetPropertyValueIfNotDefaultValue(ConfigurationStrings.AllowCookies, webBinding.AllowCookies);
|
||||
this.Security.InitializeFrom(webBinding.Security);
|
||||
this.InitializeReaderQuotas(webBinding.ReaderQuotas);
|
||||
SetPropertyValueIfNotDefaultValue(WebConfigurationStrings.CrossDomainScriptAccessEnabled, webBinding.CrossDomainScriptAccessEnabled);
|
||||
}
|
||||
|
||||
internal void InitializeReaderQuotas(XmlDictionaryReaderQuotas readerQuotas)
|
||||
{
|
||||
if (readerQuotas == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("readerQuotas");
|
||||
}
|
||||
XmlDictionaryReaderQuotasElement thisQuotas = this.ReaderQuotas;
|
||||
|
||||
// Can't call thisQuotas.InitializeFrom() because it's internal to System.ServiceModel.dll, so we duplicate the logic
|
||||
if (readerQuotas.MaxDepth != EncoderDefaults.MaxDepth && readerQuotas.MaxDepth != 0)
|
||||
{
|
||||
thisQuotas.MaxDepth = readerQuotas.MaxDepth;
|
||||
}
|
||||
if (readerQuotas.MaxStringContentLength != EncoderDefaults.MaxStringContentLength && readerQuotas.MaxStringContentLength != 0)
|
||||
{
|
||||
thisQuotas.MaxStringContentLength = readerQuotas.MaxStringContentLength;
|
||||
}
|
||||
if (readerQuotas.MaxArrayLength != EncoderDefaults.MaxArrayLength && readerQuotas.MaxArrayLength != 0)
|
||||
{
|
||||
thisQuotas.MaxArrayLength = readerQuotas.MaxArrayLength;
|
||||
}
|
||||
if (readerQuotas.MaxBytesPerRead != EncoderDefaults.MaxBytesPerRead && readerQuotas.MaxBytesPerRead != 0)
|
||||
{
|
||||
thisQuotas.MaxBytesPerRead = readerQuotas.MaxBytesPerRead;
|
||||
}
|
||||
if (readerQuotas.MaxNameTableCharCount != EncoderDefaults.MaxNameTableCharCount && readerQuotas.MaxNameTableCharCount != 0)
|
||||
{
|
||||
thisQuotas.MaxNameTableCharCount = readerQuotas.MaxNameTableCharCount;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnApplyConfiguration(Binding binding)
|
||||
{
|
||||
WebHttpBinding webBinding = (WebHttpBinding)binding;
|
||||
|
||||
webBinding.BypassProxyOnLocal = this.BypassProxyOnLocal;
|
||||
webBinding.HostNameComparisonMode = this.HostNameComparisonMode;
|
||||
webBinding.MaxBufferPoolSize = this.MaxBufferPoolSize;
|
||||
webBinding.MaxReceivedMessageSize = this.MaxReceivedMessageSize;
|
||||
|
||||
webBinding.WriteEncoding = this.WriteEncoding;
|
||||
webBinding.TransferMode = this.TransferMode;
|
||||
webBinding.UseDefaultWebProxy = this.UseDefaultWebProxy;
|
||||
webBinding.AllowCookies = this.AllowCookies;
|
||||
if (this.ProxyAddress != null)
|
||||
{
|
||||
webBinding.ProxyAddress = this.ProxyAddress;
|
||||
}
|
||||
PropertyInformationCollection propertyInfo = this.ElementInformation.Properties;
|
||||
if (propertyInfo[ConfigurationStrings.MaxBufferSize].ValueOrigin != PropertyValueOrigin.Default)
|
||||
{
|
||||
webBinding.MaxBufferSize = this.MaxBufferSize;
|
||||
}
|
||||
webBinding.ContentTypeMapper = GetContentTypeMapper(this.ContentTypeMapper);
|
||||
webBinding.CrossDomainScriptAccessEnabled = this.CrossDomainScriptAccessEnabled;
|
||||
this.Security.ApplyConfiguration(webBinding.Security);
|
||||
ApplyReaderQuotasConfiguration(webBinding.ReaderQuotas, this.ReaderQuotas);
|
||||
}
|
||||
|
||||
internal static WebContentTypeMapper GetContentTypeMapper(string contentTypeMapperType)
|
||||
{
|
||||
WebContentTypeMapper contentTypeMapper = null;
|
||||
if (!string.IsNullOrEmpty(contentTypeMapperType))
|
||||
{
|
||||
Type type = System.Type.GetType(contentTypeMapperType, true);
|
||||
if (!WebContentTypeMapperType.IsAssignableFrom(type))
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ConfigurationErrorsException(
|
||||
SR2.GetString(SR2.ConfigInvalidWebContentTypeMapperType, contentTypeMapperType, WebContentTypeMapperType.ToString())));
|
||||
}
|
||||
contentTypeMapper = (WebContentTypeMapper)Activator.CreateInstance(type);
|
||||
}
|
||||
return contentTypeMapper;
|
||||
}
|
||||
|
||||
internal static void ApplyReaderQuotasConfiguration(XmlDictionaryReaderQuotas webBindingReaderQuotas, XmlDictionaryReaderQuotasElement elementReaderQuotas)
|
||||
{
|
||||
if (webBindingReaderQuotas == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("webBindingReaderQuotas");
|
||||
}
|
||||
if (elementReaderQuotas.MaxDepth != 0)
|
||||
{
|
||||
webBindingReaderQuotas.MaxDepth = elementReaderQuotas.MaxDepth;
|
||||
}
|
||||
if (elementReaderQuotas.MaxStringContentLength != 0)
|
||||
{
|
||||
webBindingReaderQuotas.MaxStringContentLength = elementReaderQuotas.MaxStringContentLength;
|
||||
}
|
||||
if (elementReaderQuotas.MaxArrayLength != 0)
|
||||
{
|
||||
webBindingReaderQuotas.MaxArrayLength = elementReaderQuotas.MaxArrayLength;
|
||||
}
|
||||
if (elementReaderQuotas.MaxBytesPerRead != 0)
|
||||
{
|
||||
webBindingReaderQuotas.MaxBytesPerRead = elementReaderQuotas.MaxBytesPerRead;
|
||||
}
|
||||
if (elementReaderQuotas.MaxNameTableCharCount != 0)
|
||||
{
|
||||
webBindingReaderQuotas.MaxNameTableCharCount = elementReaderQuotas.MaxNameTableCharCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace System.ServiceModel.Configuration
|
||||
{
|
||||
using System.Configuration;
|
||||
using System.ServiceModel.Description;
|
||||
using System.ServiceModel.Web;
|
||||
|
||||
public sealed partial class WebHttpElement : BehaviorExtensionElement
|
||||
{
|
||||
ConfigurationPropertyCollection properties;
|
||||
|
||||
public WebHttpElement()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
[ConfigurationProperty(WebConfigurationStrings.HelpEnabled)]
|
||||
public bool HelpEnabled
|
||||
{
|
||||
get { return (bool)base[WebConfigurationStrings.HelpEnabled]; }
|
||||
set { base[WebConfigurationStrings.HelpEnabled] = value; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(WebConfigurationStrings.DefaultBodyStyle)]
|
||||
[InternalEnumValidator(typeof(WebMessageBodyStyleHelper))]
|
||||
public WebMessageBodyStyle DefaultBodyStyle
|
||||
{
|
||||
get { return (WebMessageBodyStyle)base[WebConfigurationStrings.DefaultBodyStyle]; }
|
||||
set { base[WebConfigurationStrings.DefaultBodyStyle] = value; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(WebConfigurationStrings.DefaultOutgoingResponseFormat)]
|
||||
[InternalEnumValidator(typeof(WebMessageFormatHelper))]
|
||||
public WebMessageFormat DefaultOutgoingResponseFormat
|
||||
{
|
||||
get { return (WebMessageFormat)base[WebConfigurationStrings.DefaultOutgoingResponseFormat]; }
|
||||
set { base[WebConfigurationStrings.DefaultOutgoingResponseFormat] = value; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(WebConfigurationStrings.AutomaticFormatSelectionEnabled)]
|
||||
public bool AutomaticFormatSelectionEnabled
|
||||
{
|
||||
get { return (bool)base[WebConfigurationStrings.AutomaticFormatSelectionEnabled]; }
|
||||
set { base[WebConfigurationStrings.AutomaticFormatSelectionEnabled] = value; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(WebConfigurationStrings.FaultExceptionEnabled)]
|
||||
public bool FaultExceptionEnabled
|
||||
{
|
||||
get { return (bool)base[WebConfigurationStrings.FaultExceptionEnabled]; }
|
||||
set { base[WebConfigurationStrings.FaultExceptionEnabled] = value; }
|
||||
}
|
||||
|
||||
protected override ConfigurationPropertyCollection Properties
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.properties == null)
|
||||
{
|
||||
ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection();
|
||||
properties.Add(new ConfigurationProperty(WebConfigurationStrings.HelpEnabled, typeof(bool), false, null, null, System.Configuration.ConfigurationPropertyOptions.None));
|
||||
properties.Add(new ConfigurationProperty(WebConfigurationStrings.DefaultBodyStyle, typeof(System.ServiceModel.Web.WebMessageBodyStyle), System.ServiceModel.Web.WebMessageBodyStyle.Bare, null, new System.ServiceModel.Configuration.InternalEnumValidator(typeof(System.ServiceModel.Web.WebMessageBodyStyleHelper)), System.Configuration.ConfigurationPropertyOptions.None));
|
||||
properties.Add(new ConfigurationProperty(WebConfigurationStrings.DefaultOutgoingResponseFormat, typeof(System.ServiceModel.Web.WebMessageFormat), System.ServiceModel.Web.WebMessageFormat.Xml, null, new System.ServiceModel.Configuration.InternalEnumValidator(typeof(System.ServiceModel.Web.WebMessageFormatHelper)), System.Configuration.ConfigurationPropertyOptions.None));
|
||||
properties.Add(new ConfigurationProperty(WebConfigurationStrings.AutomaticFormatSelectionEnabled, typeof(bool), false, null, null, System.Configuration.ConfigurationPropertyOptions.None));
|
||||
properties.Add(new ConfigurationProperty(WebConfigurationStrings.FaultExceptionEnabled, typeof(bool), false, null, null, System.Configuration.ConfigurationPropertyOptions.None));
|
||||
this.properties = properties;
|
||||
}
|
||||
return this.properties;
|
||||
}
|
||||
}
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Configuration", "Configuration102:ConfigurationPropertyAttributeRule", MessageId = "System.ServiceModel.Configuration.WebHttpElement.BehaviorType", Justification = "Not a configurable property; a property that had to be overridden from abstract parent class")]
|
||||
public override Type BehaviorType
|
||||
{
|
||||
get { return typeof(WebHttpBehavior); }
|
||||
}
|
||||
|
||||
internal protected override object CreateBehavior()
|
||||
{
|
||||
return new WebHttpBehavior()
|
||||
{
|
||||
HelpEnabled = this.HelpEnabled,
|
||||
DefaultBodyStyle = this.DefaultBodyStyle,
|
||||
DefaultOutgoingResponseFormat = this.DefaultOutgoingResponseFormat,
|
||||
AutomaticFormatSelectionEnabled = this.AutomaticFormatSelectionEnabled,
|
||||
FaultExceptionEnabled = this.FaultExceptionEnabled,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
namespace System.ServiceModel.Configuration
|
||||
{
|
||||
using System.ServiceModel.Description;
|
||||
|
||||
public class WebHttpEndpointCollectionElement : StandardEndpointCollectionElement<WebHttpEndpoint, WebHttpEndpointElement>
|
||||
{
|
||||
}
|
||||
}
|
@ -0,0 +1,277 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
namespace System.ServiceModel.Configuration
|
||||
{
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.ServiceModel;
|
||||
using System.ServiceModel.Dispatcher;
|
||||
using System.ServiceModel.Channels;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.ServiceModel.Web;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using System.ServiceModel.Description;
|
||||
using System.Configuration;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime;
|
||||
|
||||
public class WebHttpEndpointElement : StandardEndpointElement
|
||||
{
|
||||
ConfigurationPropertyCollection properties;
|
||||
|
||||
public WebHttpEndpointElement() : base() { }
|
||||
|
||||
protected internal override Type EndpointType
|
||||
{
|
||||
get { return typeof(WebHttpEndpoint); }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(ConfigurationStrings.HostNameComparisonMode, DefaultValue = HttpTransportDefaults.HostNameComparisonMode)]
|
||||
[ServiceModelEnumValidator(typeof(HostNameComparisonModeHelper))]
|
||||
public HostNameComparisonMode HostNameComparisonMode
|
||||
{
|
||||
get { return (HostNameComparisonMode)base[ConfigurationStrings.HostNameComparisonMode]; }
|
||||
set { base[ConfigurationStrings.HostNameComparisonMode] = value; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(ConfigurationStrings.MaxBufferPoolSize, DefaultValue = TransportDefaults.MaxBufferPoolSize)]
|
||||
[LongValidator(MinValue = 0)]
|
||||
public long MaxBufferPoolSize
|
||||
{
|
||||
get { return (long)base[ConfigurationStrings.MaxBufferPoolSize]; }
|
||||
set { base[ConfigurationStrings.MaxBufferPoolSize] = value; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(ConfigurationStrings.MaxBufferSize, DefaultValue = TransportDefaults.MaxBufferSize)]
|
||||
[IntegerValidator(MinValue = 1)]
|
||||
public int MaxBufferSize
|
||||
{
|
||||
get { return (int)base[ConfigurationStrings.MaxBufferSize]; }
|
||||
set { base[ConfigurationStrings.MaxBufferSize] = value; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(ConfigurationStrings.MaxReceivedMessageSize, DefaultValue = TransportDefaults.MaxReceivedMessageSize)]
|
||||
[LongValidator(MinValue = 1)]
|
||||
public long MaxReceivedMessageSize
|
||||
{
|
||||
get { return (long)base[ConfigurationStrings.MaxReceivedMessageSize]; }
|
||||
set { base[ConfigurationStrings.MaxReceivedMessageSize] = value; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(ConfigurationStrings.ReaderQuotas)]
|
||||
public XmlDictionaryReaderQuotasElement ReaderQuotas
|
||||
{
|
||||
get { return (XmlDictionaryReaderQuotasElement)base[ConfigurationStrings.ReaderQuotas]; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(ConfigurationStrings.Security)]
|
||||
public WebHttpSecurityElement Security
|
||||
{
|
||||
get { return (WebHttpSecurityElement)base[ConfigurationStrings.Security]; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(ConfigurationStrings.TransferMode, DefaultValue = WebHttpBindingDefaults.TransferMode)]
|
||||
[ServiceModelEnumValidator(typeof(TransferModeHelper))]
|
||||
public TransferMode TransferMode
|
||||
{
|
||||
get { return (TransferMode)base[ConfigurationStrings.TransferMode]; }
|
||||
set { base[ConfigurationStrings.TransferMode] = value; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(ConfigurationStrings.WriteEncoding, DefaultValue = TextEncoderDefaults.EncodingString)]
|
||||
[TypeConverter(typeof(EncodingConverter))]
|
||||
[WebEncodingValidator]
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Configuration", "Configuration104:ConfigurationValidatorAttributeRule", MessageId = "System.ServiceModel.Configuration.WebHttpBindingElement.WriteEncoding",
|
||||
Justification = "Bug with internal FxCop assembly flags this property as not having a validator.")]
|
||||
public Encoding WriteEncoding
|
||||
{
|
||||
get { return (Encoding)base[ConfigurationStrings.WriteEncoding]; }
|
||||
set { base[ConfigurationStrings.WriteEncoding] = value; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(WebConfigurationStrings.ContentTypeMapper, DefaultValue = "")]
|
||||
[StringValidator(MinLength = 0)]
|
||||
public string ContentTypeMapper
|
||||
{
|
||||
get { return (string)base[WebConfigurationStrings.ContentTypeMapper]; }
|
||||
set
|
||||
{
|
||||
if (String.IsNullOrEmpty(value))
|
||||
{
|
||||
value = String.Empty;
|
||||
}
|
||||
base[WebConfigurationStrings.ContentTypeMapper] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[ConfigurationProperty(WebConfigurationStrings.HelpEnabled, DefaultValue = false)]
|
||||
public bool HelpEnabled
|
||||
{
|
||||
get { return (bool)base[WebConfigurationStrings.HelpEnabled]; }
|
||||
set { base[WebConfigurationStrings.HelpEnabled] = value; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(WebConfigurationStrings.FaultExceptionEnabled, DefaultValue = false)]
|
||||
public bool FaultExceptionEnabled
|
||||
{
|
||||
get { return (bool)base[WebConfigurationStrings.FaultExceptionEnabled]; }
|
||||
set { base[WebConfigurationStrings.FaultExceptionEnabled] = value; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(WebConfigurationStrings.DefaultOutgoingResponseFormat, DefaultValue = WebMessageFormat.Xml)]
|
||||
[InternalEnumValidator(typeof(WebMessageFormatHelper))]
|
||||
public WebMessageFormat DefaultOutgoingResponseFormat
|
||||
{
|
||||
get { return (WebMessageFormat)base[WebConfigurationStrings.DefaultOutgoingResponseFormat]; }
|
||||
set { base[WebConfigurationStrings.DefaultOutgoingResponseFormat] = value; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(WebConfigurationStrings.AutomaticFormatSelectionEnabled, DefaultValue = false)]
|
||||
public bool AutomaticFormatSelectionEnabled
|
||||
{
|
||||
get { return (bool)base[WebConfigurationStrings.AutomaticFormatSelectionEnabled]; }
|
||||
set { base[WebConfigurationStrings.AutomaticFormatSelectionEnabled] = value; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(WebConfigurationStrings.CrossDomainScriptAccessEnabled, DefaultValue = false)]
|
||||
public bool CrossDomainScriptAccessEnabled
|
||||
{
|
||||
get { return (bool)base[WebConfigurationStrings.CrossDomainScriptAccessEnabled]; }
|
||||
set { base[WebConfigurationStrings.CrossDomainScriptAccessEnabled] = value; }
|
||||
}
|
||||
|
||||
protected override ConfigurationPropertyCollection Properties
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.properties == null)
|
||||
{
|
||||
ConfigurationPropertyCollection properties = base.Properties;
|
||||
properties.Add(new ConfigurationProperty(ConfigurationStrings.HostNameComparisonMode, typeof(System.ServiceModel.HostNameComparisonMode), System.ServiceModel.HostNameComparisonMode.StrongWildcard, null, new System.ServiceModel.Configuration.ServiceModelEnumValidator(typeof(System.ServiceModel.HostNameComparisonModeHelper)), System.Configuration.ConfigurationPropertyOptions.None));
|
||||
properties.Add(new ConfigurationProperty(ConfigurationStrings.MaxBufferSize, typeof(System.Int32), 65536, null, new System.Configuration.IntegerValidator(1, 2147483647, false), System.Configuration.ConfigurationPropertyOptions.None));
|
||||
properties.Add(new ConfigurationProperty(ConfigurationStrings.MaxBufferPoolSize, typeof(System.Int64), (long)524288, null, new System.Configuration.LongValidator(0, 9223372036854775807, false), System.Configuration.ConfigurationPropertyOptions.None));
|
||||
properties.Add(new ConfigurationProperty(ConfigurationStrings.MaxReceivedMessageSize, typeof(System.Int64), (long)65536, null, new System.Configuration.LongValidator(1, 9223372036854775807, false), System.Configuration.ConfigurationPropertyOptions.None));
|
||||
properties.Add(new ConfigurationProperty(ConfigurationStrings.ReaderQuotas, typeof(System.ServiceModel.Configuration.XmlDictionaryReaderQuotasElement), null, null, null, System.Configuration.ConfigurationPropertyOptions.None));
|
||||
properties.Add(new ConfigurationProperty(ConfigurationStrings.Security, typeof(System.ServiceModel.Configuration.WebHttpSecurityElement), null, null, null, System.Configuration.ConfigurationPropertyOptions.None));
|
||||
properties.Add(new ConfigurationProperty(ConfigurationStrings.WriteEncoding, typeof(System.Text.Encoding), "utf-8", new System.ServiceModel.Configuration.EncodingConverter(), null, System.Configuration.ConfigurationPropertyOptions.None));
|
||||
properties.Add(new ConfigurationProperty(ConfigurationStrings.TransferMode, typeof(System.ServiceModel.TransferMode), System.ServiceModel.TransferMode.Buffered, null, new System.ServiceModel.Configuration.ServiceModelEnumValidator(typeof(System.ServiceModel.TransferModeHelper)), System.Configuration.ConfigurationPropertyOptions.None));
|
||||
properties.Add(new ConfigurationProperty(WebConfigurationStrings.ContentTypeMapper, typeof(string), string.Empty, null, new System.Configuration.StringValidator(0), System.Configuration.ConfigurationPropertyOptions.None));
|
||||
properties.Add(new ConfigurationProperty(WebConfigurationStrings.HelpEnabled, typeof(bool), false, null, null, System.Configuration.ConfigurationPropertyOptions.None));
|
||||
properties.Add(new ConfigurationProperty(WebConfigurationStrings.DefaultOutgoingResponseFormat, typeof(System.ServiceModel.Web.WebMessageFormat), System.ServiceModel.Web.WebMessageFormat.Xml, null, new System.ServiceModel.Configuration.InternalEnumValidator(typeof(System.ServiceModel.Web.WebMessageFormatHelper)), System.Configuration.ConfigurationPropertyOptions.None));
|
||||
properties.Add(new ConfigurationProperty(WebConfigurationStrings.AutomaticFormatSelectionEnabled, typeof(bool), false, null, null, System.Configuration.ConfigurationPropertyOptions.None));
|
||||
properties.Add(new ConfigurationProperty(WebConfigurationStrings.CrossDomainScriptAccessEnabled, typeof(bool), false, null, null, System.Configuration.ConfigurationPropertyOptions.None));
|
||||
properties.Add(new ConfigurationProperty(WebConfigurationStrings.FaultExceptionEnabled, typeof(bool), false, null, null, System.Configuration.ConfigurationPropertyOptions.None));
|
||||
this.properties = properties;
|
||||
}
|
||||
return this.properties;
|
||||
}
|
||||
}
|
||||
|
||||
protected internal override ServiceEndpoint CreateServiceEndpoint(ContractDescription contractDescription)
|
||||
{
|
||||
return new WebHttpEndpoint(contractDescription);
|
||||
}
|
||||
|
||||
protected override void OnInitializeAndValidate(ChannelEndpointElement channelEndpointElement)
|
||||
{
|
||||
if (string.IsNullOrEmpty(channelEndpointElement.Binding))
|
||||
{
|
||||
channelEndpointElement.Binding = WebHttpBinding.WebHttpBindingConfigurationStrings.WebHttpBindingCollectionElementName;
|
||||
}
|
||||
else if (!string.Equals(channelEndpointElement.Binding, WebHttpBinding.WebHttpBindingConfigurationStrings.WebHttpBindingCollectionElementName, StringComparison.Ordinal))
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR2.GetString(SR2.WebEndpointRequiredBinding, typeof(WebHttpEndpoint).Name, WebHttpBinding.WebHttpBindingConfigurationStrings.WebHttpBindingCollectionElementName)));
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnInitializeAndValidate(ServiceEndpointElement serviceEndpointElement)
|
||||
{
|
||||
if (string.IsNullOrEmpty(serviceEndpointElement.Binding))
|
||||
{
|
||||
serviceEndpointElement.Binding = WebHttpBinding.WebHttpBindingConfigurationStrings.WebHttpBindingCollectionElementName;
|
||||
}
|
||||
else if (!string.Equals(serviceEndpointElement.Binding, WebHttpBinding.WebHttpBindingConfigurationStrings.WebHttpBindingCollectionElementName, StringComparison.Ordinal))
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR2.GetString(SR2.WebEndpointRequiredBinding, typeof(WebHttpEndpoint).Name, WebHttpBinding.WebHttpBindingConfigurationStrings.WebHttpBindingCollectionElementName)));
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnApplyConfiguration(ServiceEndpoint endpoint, ServiceEndpointElement serviceEndpointElement)
|
||||
{
|
||||
InternalOnApplyConfiguration(endpoint);
|
||||
}
|
||||
|
||||
protected override void OnApplyConfiguration(ServiceEndpoint endpoint, ChannelEndpointElement serviceEndpointElement)
|
||||
{
|
||||
InternalOnApplyConfiguration(endpoint);
|
||||
}
|
||||
|
||||
void InternalOnApplyConfiguration(ServiceEndpoint endpoint)
|
||||
{
|
||||
WebHttpEndpoint webHttpEndpoint = endpoint as WebHttpEndpoint;
|
||||
Fx.Assert(webHttpEndpoint != null, "The endpoint should be of type WebHttpServiceEndpoint since this is what was returned with CreateServiceEndpoint().");
|
||||
|
||||
|
||||
if (IsSet(ConfigurationStrings.HostNameComparisonMode))
|
||||
{
|
||||
webHttpEndpoint.HostNameComparisonMode = this.HostNameComparisonMode;
|
||||
}
|
||||
if (IsSet(ConfigurationStrings.MaxBufferPoolSize))
|
||||
{
|
||||
webHttpEndpoint.MaxBufferPoolSize = this.MaxBufferPoolSize;
|
||||
}
|
||||
if (IsSet(ConfigurationStrings.MaxReceivedMessageSize))
|
||||
{
|
||||
webHttpEndpoint.MaxReceivedMessageSize = this.MaxReceivedMessageSize;
|
||||
}
|
||||
if (IsSet(ConfigurationStrings.WriteEncoding))
|
||||
{
|
||||
webHttpEndpoint.WriteEncoding = this.WriteEncoding;
|
||||
}
|
||||
if (IsSet(ConfigurationStrings.TransferMode))
|
||||
{
|
||||
webHttpEndpoint.TransferMode = this.TransferMode;
|
||||
}
|
||||
if (IsSet(WebConfigurationStrings.HelpEnabled))
|
||||
{
|
||||
webHttpEndpoint.HelpEnabled = this.HelpEnabled;
|
||||
}
|
||||
if (IsSet(WebConfigurationStrings.DefaultOutgoingResponseFormat))
|
||||
{
|
||||
webHttpEndpoint.DefaultOutgoingResponseFormat = this.DefaultOutgoingResponseFormat;
|
||||
}
|
||||
if (IsSet(WebConfigurationStrings.AutomaticFormatSelectionEnabled))
|
||||
{
|
||||
webHttpEndpoint.AutomaticFormatSelectionEnabled = this.AutomaticFormatSelectionEnabled;
|
||||
}
|
||||
if (IsSet(WebConfigurationStrings.CrossDomainScriptAccessEnabled))
|
||||
{
|
||||
webHttpEndpoint.CrossDomainScriptAccessEnabled = this.CrossDomainScriptAccessEnabled;
|
||||
}
|
||||
if (IsSet(WebConfigurationStrings.FaultExceptionEnabled))
|
||||
{
|
||||
webHttpEndpoint.FaultExceptionEnabled = this.FaultExceptionEnabled;
|
||||
}
|
||||
PropertyInformationCollection propertyInfo = this.ElementInformation.Properties;
|
||||
if (propertyInfo[ConfigurationStrings.MaxBufferSize].ValueOrigin != PropertyValueOrigin.Default)
|
||||
{
|
||||
webHttpEndpoint.MaxBufferSize = this.MaxBufferSize;
|
||||
}
|
||||
if (IsSet(WebConfigurationStrings.ContentTypeMapper))
|
||||
{
|
||||
webHttpEndpoint.ContentTypeMapper = WebHttpBindingElement.GetContentTypeMapper(this.ContentTypeMapper);
|
||||
}
|
||||
this.Security.ApplyConfiguration(webHttpEndpoint.Security);
|
||||
WebHttpBindingElement.ApplyReaderQuotasConfiguration(webHttpEndpoint.ReaderQuotas, this.ReaderQuotas);
|
||||
}
|
||||
|
||||
bool IsSet(string propertyName)
|
||||
{
|
||||
return this.ElementInformation.Properties[propertyName].IsModified;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,108 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace System.ServiceModel.Configuration
|
||||
{
|
||||
using System.Configuration;
|
||||
using System.ServiceModel;
|
||||
using System.ServiceModel.Configuration;
|
||||
|
||||
public sealed partial class WebHttpSecurityElement : ServiceModelConfigurationElement
|
||||
{
|
||||
ConfigurationPropertyCollection properties;
|
||||
|
||||
[ConfigurationProperty(ConfigurationStrings.Mode, DefaultValue = WebHttpSecurity.DefaultMode)]
|
||||
[InternalEnumValidator(typeof(WebHttpSecurityModeHelper))]
|
||||
public WebHttpSecurityMode Mode
|
||||
{
|
||||
get { return (WebHttpSecurityMode)base[ConfigurationStrings.Mode]; }
|
||||
set { base[ConfigurationStrings.Mode] = value; }
|
||||
}
|
||||
|
||||
|
||||
[ConfigurationProperty(ConfigurationStrings.Transport)]
|
||||
public HttpTransportSecurityElement Transport
|
||||
{
|
||||
get { return (HttpTransportSecurityElement)base[ConfigurationStrings.Transport]; }
|
||||
}
|
||||
|
||||
protected override ConfigurationPropertyCollection Properties
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.properties == null)
|
||||
{
|
||||
ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection();
|
||||
properties.Add(new ConfigurationProperty("mode", typeof(WebHttpSecurityMode), System.ServiceModel.WebHttpSecurityMode.None, null, new InternalEnumValidator(typeof(WebHttpSecurityModeHelper)), System.Configuration.ConfigurationPropertyOptions.None));
|
||||
properties.Add(new ConfigurationProperty("transport", typeof(HttpTransportSecurityElement), null, null, null, System.Configuration.ConfigurationPropertyOptions.None));
|
||||
this.properties = properties;
|
||||
}
|
||||
return this.properties;
|
||||
}
|
||||
}
|
||||
|
||||
internal void ApplyConfiguration(WebHttpSecurity security)
|
||||
{
|
||||
if (security == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("security");
|
||||
}
|
||||
if (this.ElementInformation.Properties["mode"].IsModified)
|
||||
{
|
||||
security.Mode = this.Mode;
|
||||
this.Transport.ApplyConfiguration(security.Transport);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
internal void InitializeFrom(WebHttpSecurity security)
|
||||
{
|
||||
if (security == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("security");
|
||||
}
|
||||
SetPropertyValueIfNotDefaultValue(ConfigurationStrings.Mode, security.Mode);
|
||||
this.InitializeTransportSecurity(security.Transport);
|
||||
}
|
||||
|
||||
void ApplyConfiguration(HttpTransportSecurity security)
|
||||
{
|
||||
if (security == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("security");
|
||||
}
|
||||
security.ClientCredentialType = this.Transport.ClientCredentialType;
|
||||
security.ProxyCredentialType = this.Transport.ProxyCredentialType;
|
||||
security.Realm = this.Transport.Realm;
|
||||
}
|
||||
|
||||
void InitializeTransportSecurity(HttpTransportSecurity security)
|
||||
{
|
||||
if (security == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("security");
|
||||
}
|
||||
// Can't call this.Transport.SetPropertyValueIfNotDefaultValue directly because it's protected, so we check
|
||||
// the defaults here instead.
|
||||
if (IsNonDefaultValue(this.Transport, ConfigurationStrings.ClientCredentialType, security.ClientCredentialType))
|
||||
{
|
||||
this.Transport.ClientCredentialType = security.ClientCredentialType;
|
||||
}
|
||||
if (IsNonDefaultValue(this.Transport, ConfigurationStrings.ProxyCredentialType, security.ProxyCredentialType))
|
||||
{
|
||||
this.Transport.ProxyCredentialType = security.ProxyCredentialType;
|
||||
}
|
||||
if (IsNonDefaultValue(this.Transport, ConfigurationStrings.Realm, security.Realm))
|
||||
{
|
||||
this.Transport.Realm = security.Realm;
|
||||
}
|
||||
}
|
||||
|
||||
static bool IsNonDefaultValue<T>(ServiceModelConfigurationElement element, string propertyName, T value)
|
||||
{
|
||||
PropertyInformation configurationPropertyInfo = element.ElementInformation.Properties[propertyName];
|
||||
return configurationPropertyInfo != null && !object.Equals(configurationPropertyInfo.DefaultValue, value);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,170 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#pragma warning disable 1634 // Stops compiler from warning about unknown warnings (for Presharp)
|
||||
|
||||
namespace System.ServiceModel.Configuration
|
||||
{
|
||||
using System.ComponentModel;
|
||||
using System.Configuration;
|
||||
using System.ServiceModel.Channels;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
|
||||
public sealed partial class WebMessageEncodingElement : BindingElementExtensionElement
|
||||
{
|
||||
|
||||
const string ConfigurationStringsWebContentTypeMapperType = "webContentTypeMapperType";
|
||||
public WebMessageEncodingElement()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Configuration", "Configuration102:ConfigurationPropertyAttributeRule", MessageId = "System.ServiceModel.Configuration.WebMessageEncodingElement.BindingElementType",
|
||||
Justification = "Not a configurable property; a property that had to be overridden from abstract parent class")]
|
||||
public override Type BindingElementType
|
||||
{
|
||||
get { return typeof(WebMessageEncodingBindingElement); }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(ConfigurationStrings.MaxReadPoolSize, DefaultValue = EncoderDefaults.MaxReadPoolSize)]
|
||||
[IntegerValidator(MinValue = 1)]
|
||||
public int MaxReadPoolSize
|
||||
{
|
||||
get { return (int) base[ConfigurationStrings.MaxReadPoolSize]; }
|
||||
set { base[ConfigurationStrings.MaxReadPoolSize] = value; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(ConfigurationStrings.MaxWritePoolSize, DefaultValue = EncoderDefaults.MaxWritePoolSize)]
|
||||
[IntegerValidator(MinValue = 1)]
|
||||
public int MaxWritePoolSize
|
||||
{
|
||||
get { return (int) base[ConfigurationStrings.MaxWritePoolSize]; }
|
||||
set { base[ConfigurationStrings.MaxWritePoolSize] = value; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(ConfigurationStrings.ReaderQuotas)]
|
||||
public XmlDictionaryReaderQuotasElement ReaderQuotas
|
||||
{
|
||||
get { return (XmlDictionaryReaderQuotasElement) base[ConfigurationStrings.ReaderQuotas]; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(ConfigurationStringsWebContentTypeMapperType, DefaultValue = "")]
|
||||
[StringValidator(MinLength = 0)]
|
||||
public string WebContentTypeMapperType
|
||||
{
|
||||
get { return (string) base[ConfigurationStringsWebContentTypeMapperType]; }
|
||||
set
|
||||
{
|
||||
if (String.IsNullOrEmpty(value))
|
||||
{
|
||||
value = String.Empty;
|
||||
}
|
||||
base[ConfigurationStringsWebContentTypeMapperType] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[ConfigurationProperty(ConfigurationStrings.WriteEncoding, DefaultValue = TextEncoderDefaults.EncodingString)]
|
||||
[TypeConverter(typeof(EncodingConverter))]
|
||||
[WebEncodingValidator]
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Configuration", "Configuration104:ConfigurationValidatorAttributeRule", MessageId = "System.ServiceModel.Configuration.WebMessageEncodingElement.WriteEncoding",
|
||||
Justification = "Bug with internal FxCop assembly flags this property as not having a validator.")]
|
||||
public Encoding WriteEncoding
|
||||
{
|
||||
get { return (Encoding) base[ConfigurationStrings.WriteEncoding]; }
|
||||
set { base[ConfigurationStrings.WriteEncoding] = value; }
|
||||
}
|
||||
|
||||
public override void ApplyConfiguration(BindingElement bindingElement)
|
||||
{
|
||||
base.ApplyConfiguration(bindingElement);
|
||||
WebMessageEncodingBindingElement binding = (WebMessageEncodingBindingElement) bindingElement;
|
||||
binding.WriteEncoding = this.WriteEncoding;
|
||||
binding.MaxReadPoolSize = this.MaxReadPoolSize;
|
||||
binding.MaxWritePoolSize = this.MaxWritePoolSize;
|
||||
if (!string.IsNullOrEmpty(this.WebContentTypeMapperType))
|
||||
{
|
||||
Type CTMType = Type.GetType(this.WebContentTypeMapperType, true);
|
||||
if (!typeof(WebContentTypeMapper).IsAssignableFrom(CTMType))
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ConfigurationErrorsException(
|
||||
SR2.GetString(SR2.ConfigInvalidWebContentTypeMapper,
|
||||
CTMType,
|
||||
ConfigurationStringsWebContentTypeMapperType,
|
||||
typeof(WebMessageEncodingBindingElement),
|
||||
typeof(WebContentTypeMapper))));
|
||||
}
|
||||
try
|
||||
{
|
||||
binding.ContentTypeMapper = (WebContentTypeMapper) Activator.CreateInstance(CTMType);
|
||||
}
|
||||
catch (MissingMethodException innerException)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ConfigurationErrorsException(
|
||||
SR2.GetString(SR2.ConfigWebContentTypeMapperNoConstructor,
|
||||
CTMType,
|
||||
ConfigurationStringsWebContentTypeMapperType,
|
||||
typeof(WebMessageEncodingBindingElement),
|
||||
typeof(WebContentTypeMapper)),
|
||||
innerException));
|
||||
}
|
||||
}
|
||||
#pragma warning suppress 56506 // bindingElement is checked for null in base.ApplyConfiguration()
|
||||
ApplyConfiguration(this.ReaderQuotas, binding.ReaderQuotas);
|
||||
}
|
||||
|
||||
public override void CopyFrom(ServiceModelExtensionElement from)
|
||||
{
|
||||
base.CopyFrom(from);
|
||||
|
||||
WebMessageEncodingElement source = (WebMessageEncodingElement) from;
|
||||
#pragma warning suppress 56506 // base.CopyFrom() checks for 'from' being null
|
||||
this.WriteEncoding = source.WriteEncoding;
|
||||
this.MaxReadPoolSize = source.MaxReadPoolSize;
|
||||
this.MaxWritePoolSize = source.MaxWritePoolSize;
|
||||
this.WebContentTypeMapperType = source.WebContentTypeMapperType;
|
||||
this.ReaderQuotas.MaxArrayLength = source.ReaderQuotas.MaxArrayLength;
|
||||
this.ReaderQuotas.MaxBytesPerRead = source.ReaderQuotas.MaxBytesPerRead;
|
||||
this.ReaderQuotas.MaxDepth = source.ReaderQuotas.MaxDepth;
|
||||
this.ReaderQuotas.MaxNameTableCharCount = source.ReaderQuotas.MaxNameTableCharCount;
|
||||
this.ReaderQuotas.MaxStringContentLength = source.ReaderQuotas.MaxStringContentLength;
|
||||
}
|
||||
|
||||
internal protected override BindingElement CreateBindingElement()
|
||||
{
|
||||
WebMessageEncodingBindingElement binding = new WebMessageEncodingBindingElement();
|
||||
this.ApplyConfiguration(binding);
|
||||
return binding;
|
||||
}
|
||||
|
||||
internal void ApplyConfiguration(XmlDictionaryReaderQuotasElement currentQuotas, XmlDictionaryReaderQuotas readerQuotas)
|
||||
{
|
||||
if (readerQuotas == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("readerQuotas");
|
||||
}
|
||||
if (currentQuotas.MaxDepth != 0)
|
||||
{
|
||||
readerQuotas.MaxDepth = currentQuotas.MaxDepth;
|
||||
}
|
||||
if (currentQuotas.MaxStringContentLength != 0)
|
||||
{
|
||||
readerQuotas.MaxStringContentLength = currentQuotas.MaxStringContentLength;
|
||||
}
|
||||
if (currentQuotas.MaxArrayLength != 0)
|
||||
{
|
||||
readerQuotas.MaxArrayLength = currentQuotas.MaxArrayLength;
|
||||
}
|
||||
if (currentQuotas.MaxBytesPerRead != 0)
|
||||
{
|
||||
readerQuotas.MaxBytesPerRead = currentQuotas.MaxBytesPerRead;
|
||||
}
|
||||
if (currentQuotas.MaxNameTableCharCount != 0)
|
||||
{
|
||||
readerQuotas.MaxNameTableCharCount = currentQuotas.MaxNameTableCharCount;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,28 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace System.ServiceModel.Configuration
|
||||
{
|
||||
using System.ServiceModel.Description;
|
||||
|
||||
public sealed partial class WebScriptEnablingElement : BehaviorExtensionElement
|
||||
{
|
||||
public WebScriptEnablingElement()
|
||||
{
|
||||
}
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Configuration", "Configuration102:ConfigurationPropertyAttributeRule", MessageId = "System.ServiceModel.Configuration.WebScriptEnablingElement.BehaviorType",
|
||||
Justification = "Not a configurable property; a property that had to be overridden from abstract parent class")]
|
||||
public override Type BehaviorType
|
||||
{
|
||||
get { return typeof(WebScriptEnablingBehavior); }
|
||||
}
|
||||
|
||||
internal protected override object CreateBehavior()
|
||||
{
|
||||
return new WebScriptEnablingBehavior();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
namespace System.ServiceModel.Configuration
|
||||
{
|
||||
using System.ServiceModel.Description;
|
||||
|
||||
public class WebScriptEndpointCollectionElement : StandardEndpointCollectionElement<WebScriptEndpoint, WebScriptEndpointElement>
|
||||
{
|
||||
}
|
||||
}
|
@ -0,0 +1,227 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
namespace System.ServiceModel.Configuration
|
||||
{
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.ServiceModel;
|
||||
using System.ServiceModel.Dispatcher;
|
||||
using System.ServiceModel.Channels;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.ServiceModel.Web;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using System.ServiceModel.Description;
|
||||
using System.Configuration;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime;
|
||||
|
||||
public class WebScriptEndpointElement : StandardEndpointElement
|
||||
{
|
||||
ConfigurationPropertyCollection properties;
|
||||
|
||||
public WebScriptEndpointElement() : base() { }
|
||||
|
||||
protected internal override Type EndpointType
|
||||
{
|
||||
get { return typeof(WebScriptEndpoint); }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(ConfigurationStrings.HostNameComparisonMode, DefaultValue = HttpTransportDefaults.HostNameComparisonMode)]
|
||||
[ServiceModelEnumValidator(typeof(HostNameComparisonModeHelper))]
|
||||
public HostNameComparisonMode HostNameComparisonMode
|
||||
{
|
||||
get { return (HostNameComparisonMode)base[ConfigurationStrings.HostNameComparisonMode]; }
|
||||
set { base[ConfigurationStrings.HostNameComparisonMode] = value; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(ConfigurationStrings.MaxBufferPoolSize, DefaultValue = TransportDefaults.MaxBufferPoolSize)]
|
||||
[LongValidator(MinValue = 0)]
|
||||
public long MaxBufferPoolSize
|
||||
{
|
||||
get { return (long)base[ConfigurationStrings.MaxBufferPoolSize]; }
|
||||
set { base[ConfigurationStrings.MaxBufferPoolSize] = value; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(ConfigurationStrings.MaxBufferSize, DefaultValue = TransportDefaults.MaxBufferSize)]
|
||||
[IntegerValidator(MinValue = 1)]
|
||||
public int MaxBufferSize
|
||||
{
|
||||
get { return (int)base[ConfigurationStrings.MaxBufferSize]; }
|
||||
set { base[ConfigurationStrings.MaxBufferSize] = value; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(ConfigurationStrings.MaxReceivedMessageSize, DefaultValue = TransportDefaults.MaxReceivedMessageSize)]
|
||||
[LongValidator(MinValue = 1)]
|
||||
public long MaxReceivedMessageSize
|
||||
{
|
||||
get { return (long)base[ConfigurationStrings.MaxReceivedMessageSize]; }
|
||||
set { base[ConfigurationStrings.MaxReceivedMessageSize] = value; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(ConfigurationStrings.ReaderQuotas)]
|
||||
public XmlDictionaryReaderQuotasElement ReaderQuotas
|
||||
{
|
||||
get { return (XmlDictionaryReaderQuotasElement)base[ConfigurationStrings.ReaderQuotas]; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(ConfigurationStrings.Security)]
|
||||
public WebHttpSecurityElement Security
|
||||
{
|
||||
get { return (WebHttpSecurityElement)base[ConfigurationStrings.Security]; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(ConfigurationStrings.TransferMode, DefaultValue = WebHttpBindingDefaults.TransferMode)]
|
||||
[ServiceModelEnumValidator(typeof(TransferModeHelper))]
|
||||
public TransferMode TransferMode
|
||||
{
|
||||
get { return (TransferMode)base[ConfigurationStrings.TransferMode]; }
|
||||
set { base[ConfigurationStrings.TransferMode] = value; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(ConfigurationStrings.WriteEncoding, DefaultValue = TextEncoderDefaults.EncodingString)]
|
||||
[TypeConverter(typeof(EncodingConverter))]
|
||||
[WebEncodingValidator]
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Configuration", "Configuration104:ConfigurationValidatorAttributeRule", MessageId = "System.ServiceModel.Configuration.WebHttpBindingElement.WriteEncoding",
|
||||
Justification = "Bug with internal FxCop assembly flags this property as not having a validator.")]
|
||||
public Encoding WriteEncoding
|
||||
{
|
||||
get { return (Encoding)base[ConfigurationStrings.WriteEncoding]; }
|
||||
set { base[ConfigurationStrings.WriteEncoding] = value; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(WebConfigurationStrings.ContentTypeMapper, DefaultValue = "")]
|
||||
[StringValidator(MinLength = 0)]
|
||||
public string ContentTypeMapper
|
||||
{
|
||||
get { return (string)base[WebConfigurationStrings.ContentTypeMapper]; }
|
||||
set
|
||||
{
|
||||
if (String.IsNullOrEmpty(value))
|
||||
{
|
||||
value = String.Empty;
|
||||
}
|
||||
base[WebConfigurationStrings.ContentTypeMapper] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[ConfigurationProperty(WebConfigurationStrings.CrossDomainScriptAccessEnabled, DefaultValue = false)]
|
||||
public bool CrossDomainScriptAccessEnabled
|
||||
{
|
||||
get { return (bool)base[WebConfigurationStrings.CrossDomainScriptAccessEnabled]; }
|
||||
set { base[WebConfigurationStrings.CrossDomainScriptAccessEnabled] = value; }
|
||||
}
|
||||
|
||||
protected override ConfigurationPropertyCollection Properties
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.properties == null)
|
||||
{
|
||||
ConfigurationPropertyCollection properties = base.Properties;
|
||||
properties.Add(new ConfigurationProperty(ConfigurationStrings.HostNameComparisonMode, typeof(System.ServiceModel.HostNameComparisonMode), System.ServiceModel.HostNameComparisonMode.StrongWildcard, null, new System.ServiceModel.Configuration.ServiceModelEnumValidator(typeof(System.ServiceModel.HostNameComparisonModeHelper)), System.Configuration.ConfigurationPropertyOptions.None));
|
||||
properties.Add(new ConfigurationProperty(ConfigurationStrings.MaxBufferSize, typeof(System.Int32), 65536, null, new System.Configuration.IntegerValidator(1, 2147483647, false), System.Configuration.ConfigurationPropertyOptions.None));
|
||||
properties.Add(new ConfigurationProperty(ConfigurationStrings.MaxBufferPoolSize, typeof(System.Int64), (long)524288, null, new System.Configuration.LongValidator(0, 9223372036854775807, false), System.Configuration.ConfigurationPropertyOptions.None));
|
||||
properties.Add(new ConfigurationProperty(ConfigurationStrings.MaxReceivedMessageSize, typeof(System.Int64), (long)65536, null, new System.Configuration.LongValidator(1, 9223372036854775807, false), System.Configuration.ConfigurationPropertyOptions.None));
|
||||
properties.Add(new ConfigurationProperty(ConfigurationStrings.ReaderQuotas, typeof(System.ServiceModel.Configuration.XmlDictionaryReaderQuotasElement), null, null, null, System.Configuration.ConfigurationPropertyOptions.None));
|
||||
properties.Add(new ConfigurationProperty(ConfigurationStrings.Security, typeof(System.ServiceModel.Configuration.WebHttpSecurityElement), null, null, null, System.Configuration.ConfigurationPropertyOptions.None));
|
||||
properties.Add(new ConfigurationProperty(ConfigurationStrings.WriteEncoding, typeof(System.Text.Encoding), "utf-8", new System.ServiceModel.Configuration.EncodingConverter(), null, System.Configuration.ConfigurationPropertyOptions.None));
|
||||
properties.Add(new ConfigurationProperty(ConfigurationStrings.TransferMode, typeof(System.ServiceModel.TransferMode), System.ServiceModel.TransferMode.Buffered, null, new System.ServiceModel.Configuration.ServiceModelEnumValidator(typeof(System.ServiceModel.TransferModeHelper)), System.Configuration.ConfigurationPropertyOptions.None));
|
||||
properties.Add(new ConfigurationProperty(WebConfigurationStrings.ContentTypeMapper, typeof(string), string.Empty, null, new System.Configuration.StringValidator(0), System.Configuration.ConfigurationPropertyOptions.None));
|
||||
properties.Add(new ConfigurationProperty(WebConfigurationStrings.CrossDomainScriptAccessEnabled, typeof(bool), false, null, null, System.Configuration.ConfigurationPropertyOptions.None));
|
||||
this.properties = properties;
|
||||
}
|
||||
return this.properties;
|
||||
}
|
||||
}
|
||||
|
||||
protected internal override ServiceEndpoint CreateServiceEndpoint(ContractDescription contractDescription)
|
||||
{
|
||||
return new WebScriptEndpoint(contractDescription);
|
||||
}
|
||||
|
||||
protected override void OnInitializeAndValidate(ChannelEndpointElement channelEndpointElement)
|
||||
{
|
||||
if (string.IsNullOrEmpty(channelEndpointElement.Binding))
|
||||
{
|
||||
channelEndpointElement.Binding = WebHttpBinding.WebHttpBindingConfigurationStrings.WebHttpBindingCollectionElementName;
|
||||
}
|
||||
else if (!string.Equals(channelEndpointElement.Binding, WebHttpBinding.WebHttpBindingConfigurationStrings.WebHttpBindingCollectionElementName, StringComparison.Ordinal))
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR2.GetString(SR2.WebEndpointRequiredBinding, typeof(WebScriptEndpoint).Name, WebHttpBinding.WebHttpBindingConfigurationStrings.WebHttpBindingCollectionElementName)));
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnInitializeAndValidate(ServiceEndpointElement serviceEndpointElement)
|
||||
{
|
||||
if (string.IsNullOrEmpty(serviceEndpointElement.Binding))
|
||||
{
|
||||
serviceEndpointElement.Binding = WebHttpBinding.WebHttpBindingConfigurationStrings.WebHttpBindingCollectionElementName;
|
||||
}
|
||||
else if (!string.Equals(serviceEndpointElement.Binding, WebHttpBinding.WebHttpBindingConfigurationStrings.WebHttpBindingCollectionElementName, StringComparison.Ordinal))
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR2.GetString(SR2.WebEndpointRequiredBinding, typeof(WebScriptEndpoint).Name, WebHttpBinding.WebHttpBindingConfigurationStrings.WebHttpBindingCollectionElementName)));
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnApplyConfiguration(ServiceEndpoint endpoint, ServiceEndpointElement serviceEndpointElement)
|
||||
{
|
||||
InternalOnApplyConfiguration(endpoint);
|
||||
}
|
||||
|
||||
protected override void OnApplyConfiguration(ServiceEndpoint endpoint, ChannelEndpointElement serviceEndpointElement)
|
||||
{
|
||||
InternalOnApplyConfiguration(endpoint);
|
||||
}
|
||||
|
||||
void InternalOnApplyConfiguration(ServiceEndpoint endpoint)
|
||||
{
|
||||
WebScriptEndpoint webScriptEndpoint = endpoint as WebScriptEndpoint;
|
||||
Fx.Assert(webScriptEndpoint != null, "The endpoint should be of type WebScriptEnablingServiceEndpoint since this is what was returned with CreateServiceEndpoint().");
|
||||
|
||||
if (IsSet(ConfigurationStrings.HostNameComparisonMode))
|
||||
{
|
||||
webScriptEndpoint.HostNameComparisonMode = this.HostNameComparisonMode;
|
||||
}
|
||||
if (IsSet(ConfigurationStrings.MaxBufferPoolSize))
|
||||
{
|
||||
webScriptEndpoint.MaxBufferPoolSize = this.MaxBufferPoolSize;
|
||||
}
|
||||
if (IsSet(ConfigurationStrings.MaxReceivedMessageSize))
|
||||
{
|
||||
webScriptEndpoint.MaxReceivedMessageSize = this.MaxReceivedMessageSize;
|
||||
}
|
||||
if (IsSet(ConfigurationStrings.WriteEncoding))
|
||||
{
|
||||
webScriptEndpoint.WriteEncoding = this.WriteEncoding;
|
||||
}
|
||||
if (IsSet(ConfigurationStrings.TransferMode))
|
||||
{
|
||||
webScriptEndpoint.TransferMode = this.TransferMode;
|
||||
}
|
||||
if (IsSet(WebConfigurationStrings.CrossDomainScriptAccessEnabled))
|
||||
{
|
||||
webScriptEndpoint.CrossDomainScriptAccessEnabled = this.CrossDomainScriptAccessEnabled;
|
||||
}
|
||||
PropertyInformationCollection propertyInfo = this.ElementInformation.Properties;
|
||||
if (propertyInfo[ConfigurationStrings.MaxBufferSize].ValueOrigin != PropertyValueOrigin.Default)
|
||||
{
|
||||
webScriptEndpoint.MaxBufferSize = this.MaxBufferSize;
|
||||
}
|
||||
if (IsSet(WebConfigurationStrings.ContentTypeMapper))
|
||||
{
|
||||
webScriptEndpoint.ContentTypeMapper = WebHttpBindingElement.GetContentTypeMapper(this.ContentTypeMapper);
|
||||
}
|
||||
this.Security.ApplyConfiguration(webScriptEndpoint.Security);
|
||||
WebHttpBindingElement.ApplyReaderQuotasConfiguration(webScriptEndpoint.ReaderQuotas, this.ReaderQuotas);
|
||||
}
|
||||
|
||||
bool IsSet(string propertyName)
|
||||
{
|
||||
return this.ElementInformation.Properties[propertyName].IsModified;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user