1 //------------------------------------------------------------------------------ 2 // Copyright (c) Microsoft Corporation. All rights reserved. 3 //------------------------------------------------------------------------------ 4 5 namespace System.ServiceModel.Configuration 6 { 7 using System.Configuration; 8 using System.ServiceModel.Channels; 9 10 public sealed partial class BinaryMessageEncodingElement : BindingElementExtensionElement 11 { BinaryMessageEncodingElement()12 public BinaryMessageEncodingElement() 13 { 14 } 15 16 public override Type BindingElementType 17 { 18 get { return typeof(BinaryMessageEncodingBindingElement); } 19 } 20 21 [ConfigurationProperty(ConfigurationStrings.MaxReadPoolSize, DefaultValue = EncoderDefaults.MaxReadPoolSize)] 22 [IntegerValidator(MinValue = 1)] 23 public int MaxReadPoolSize 24 { 25 get { return (int)base[ConfigurationStrings.MaxReadPoolSize]; } 26 set { base[ConfigurationStrings.MaxReadPoolSize] = value; } 27 } 28 29 [ConfigurationProperty(ConfigurationStrings.MaxWritePoolSize, DefaultValue = EncoderDefaults.MaxWritePoolSize)] 30 [IntegerValidator(MinValue = 1)] 31 public int MaxWritePoolSize 32 { 33 get { return (int)base[ConfigurationStrings.MaxWritePoolSize]; } 34 set { base[ConfigurationStrings.MaxWritePoolSize] = value; } 35 } 36 37 [ConfigurationProperty(ConfigurationStrings.MaxSessionSize, DefaultValue = BinaryEncoderDefaults.MaxSessionSize)] 38 [IntegerValidator(MinValue = 0)] 39 public int MaxSessionSize 40 { 41 get { return (int)base[ConfigurationStrings.MaxSessionSize]; } 42 set { base[ConfigurationStrings.MaxSessionSize] = value; } 43 } 44 45 [ConfigurationProperty(ConfigurationStrings.ReaderQuotas)] 46 public XmlDictionaryReaderQuotasElement ReaderQuotas 47 { 48 get { return (XmlDictionaryReaderQuotasElement) base[ConfigurationStrings.ReaderQuotas]; } 49 } 50 51 [ConfigurationProperty(ConfigurationStrings.CompressionFormat, DefaultValue = EncoderDefaults.DefaultCompressionFormat)] 52 [ServiceModelEnumValidator(typeof(CompressionFormatHelper))] 53 public CompressionFormat CompressionFormat 54 { 55 get { return (CompressionFormat)base[ConfigurationStrings.CompressionFormat]; } 56 set { base[ConfigurationStrings.CompressionFormat] = value; } 57 } 58 ApplyConfiguration(BindingElement bindingElement)59 public override void ApplyConfiguration(BindingElement bindingElement) 60 { 61 base.ApplyConfiguration(bindingElement); 62 BinaryMessageEncodingBindingElement binding = (BinaryMessageEncodingBindingElement)bindingElement; 63 binding.MaxSessionSize = this.MaxSessionSize; 64 binding.MaxReadPoolSize = this.MaxReadPoolSize; 65 binding.MaxWritePoolSize = this.MaxWritePoolSize; 66 #pragma warning suppress 56506 //Microsoft; base.ApplyConfiguration() checks for 'binding' being null 67 this.ReaderQuotas.ApplyConfiguration(binding.ReaderQuotas); 68 binding.CompressionFormat = this.CompressionFormat; 69 } 70 CopyFrom(ServiceModelExtensionElement from)71 public override void CopyFrom(ServiceModelExtensionElement from) 72 { 73 base.CopyFrom(from); 74 75 BinaryMessageEncodingElement source = (BinaryMessageEncodingElement)from; 76 #pragma warning suppress 56506 //Microsoft; base.CopyFrom() checks for 'from' being null 77 this.MaxSessionSize = source.MaxSessionSize; 78 this.MaxReadPoolSize = source.MaxReadPoolSize; 79 this.MaxWritePoolSize = source.MaxWritePoolSize; 80 this.CompressionFormat = source.CompressionFormat; 81 } 82 InitializeFrom(BindingElement bindingElement)83 protected internal override void InitializeFrom(BindingElement bindingElement) 84 { 85 base.InitializeFrom(bindingElement); 86 BinaryMessageEncodingBindingElement binding = (BinaryMessageEncodingBindingElement)bindingElement; 87 SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MaxSessionSize, binding.MaxSessionSize); 88 SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MaxReadPoolSize, binding.MaxReadPoolSize); 89 SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MaxWritePoolSize, binding.MaxWritePoolSize); 90 this.ReaderQuotas.InitializeFrom(binding.ReaderQuotas); 91 SetPropertyValueIfNotDefaultValue(ConfigurationStrings.CompressionFormat, binding.CompressionFormat); 92 } 93 CreateBindingElement()94 protected internal override BindingElement CreateBindingElement() 95 { 96 BinaryMessageEncodingBindingElement binding = new BinaryMessageEncodingBindingElement(); 97 this.ApplyConfiguration(binding); 98 return binding; 99 } 100 } 101 } 102 103