|
//------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------
namespace System.ServiceModel.Configuration
{
using System.ComponentModel;
using System.Configuration;
using System.Globalization;
using System.ServiceModel.Channels;
using System.Text;
public sealed partial class MtomMessageEncodingElement : BindingElementExtensionElement
{
public MtomMessageEncodingElement()
{
}
public override void ApplyConfiguration(BindingElement bindingElement)
{
base.ApplyConfiguration(bindingElement);
MtomMessageEncodingBindingElement binding = (MtomMessageEncodingBindingElement)bindingElement;
binding.MessageVersion = this.MessageVersion;
binding.WriteEncoding = this.WriteEncoding;
binding.MaxReadPoolSize = this.MaxReadPoolSize;
binding.MaxWritePoolSize = this.MaxWritePoolSize;
#pragma warning suppress 56506 //Microsoft; base.ApplyConfiguration() checks for 'binding' being null
this.ReaderQuotas.ApplyConfiguration(binding.ReaderQuotas);
binding.MaxBufferSize = this.MaxBufferSize;
}
public override Type BindingElementType
{
get { return typeof(MtomMessageEncodingBindingElement); }
}
public override void CopyFrom(ServiceModelExtensionElement from)
{
base.CopyFrom(from);
MtomMessageEncodingElement source = (MtomMessageEncodingElement)from;
#pragma warning suppress 56506 //Microsoft; base.CopyFrom() checks for 'from' being null
this.MessageVersion = source.MessageVersion;
this.WriteEncoding = source.WriteEncoding;
this.MaxReadPoolSize = source.MaxReadPoolSize;
this.MaxWritePoolSize = source.MaxWritePoolSize;
this.MaxBufferSize = source.MaxBufferSize;
}
protected internal override BindingElement CreateBindingElement()
{
MtomMessageEncodingBindingElement binding = new MtomMessageEncodingBindingElement();
this.ApplyConfiguration(binding);
return binding;
}
protected internal override void InitializeFrom(BindingElement bindingElement)
{
base.InitializeFrom(bindingElement);
MtomMessageEncodingBindingElement binding = (MtomMessageEncodingBindingElement)bindingElement;
SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MessageVersion, binding.MessageVersion);
SetPropertyValueIfNotDefaultValue(ConfigurationStrings.WriteEncoding, binding.WriteEncoding);
SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MaxReadPoolSize, binding.MaxReadPoolSize);
SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MaxWritePoolSize, binding.MaxWritePoolSize);
this.ReaderQuotas.InitializeFrom(binding.ReaderQuotas);
SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MaxBufferSize, binding.MaxBufferSize);
}
[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.MessageVersion, DefaultValue = TextEncoderDefaults.MessageVersionString)]
[TypeConverter(typeof(MessageVersionConverter))]
public MessageVersion MessageVersion
{
get { return (MessageVersion)base[ConfigurationStrings.MessageVersion]; }
set { base[ConfigurationStrings.MessageVersion] = value; }
}
[ConfigurationProperty(ConfigurationStrings.ReaderQuotas)]
public XmlDictionaryReaderQuotasElement ReaderQuotas
{
get { return (XmlDictionaryReaderQuotasElement) base[ConfigurationStrings.ReaderQuotas]; }
}
[ConfigurationProperty(ConfigurationStrings.MaxBufferSize, DefaultValue = MtomEncoderDefaults.MaxBufferSize)]
[IntegerValidator(MinValue = 1)]
public int MaxBufferSize
{
get { return (int)base[ConfigurationStrings.MaxBufferSize]; }
set { base[ConfigurationStrings.MaxBufferSize] = value; }
}
[ConfigurationProperty(ConfigurationStrings.WriteEncoding, DefaultValue = TextEncoderDefaults.EncodingString)]
[TypeConverter(typeof(EncodingConverter))]
public Encoding WriteEncoding
{
get { return (Encoding)base[ConfigurationStrings.WriteEncoding]; }
set { base[ConfigurationStrings.WriteEncoding] = value; }
}
}
}
|