| | | 1 | | // Licensed to the .NET Foundation under one or more agreements. |
| | | 2 | | // The .NET Foundation licenses this file to you under the MIT license. |
| | | 3 | | |
| | | 4 | | using System; |
| | | 5 | | using System.Configuration; |
| | | 6 | | using CoreWCF.Channels; |
| | | 7 | | |
| | | 8 | | namespace CoreWCF.Configuration |
| | | 9 | | { |
| | | 10 | | public sealed class BinaryMessageEncodingElement : BindingElementExtensionElement |
| | | 11 | | { |
| | | 12 | | public override Type BindingElementType |
| | | 13 | | { |
| | 12 | 14 | | get { return typeof(BinaryMessageEncodingBindingElement); } |
| | | 15 | | } |
| | | 16 | | |
| | | 17 | | [ConfigurationProperty(ConfigurationStrings.MaxReadPoolSize, DefaultValue = EncoderDefaults.MaxReadPoolSize)] |
| | | 18 | | [IntegerValidator(MinValue = 1)] |
| | | 19 | | public int MaxReadPoolSize |
| | | 20 | | { |
| | 2 | 21 | | get { return (int)base[ConfigurationStrings.MaxReadPoolSize]; } |
| | 0 | 22 | | set { base[ConfigurationStrings.MaxReadPoolSize] = value; } |
| | | 23 | | } |
| | | 24 | | |
| | | 25 | | [ConfigurationProperty(ConfigurationStrings.MaxWritePoolSize, DefaultValue = EncoderDefaults.MaxWritePoolSize)] |
| | | 26 | | [IntegerValidator(MinValue = 1)] |
| | | 27 | | public int MaxWritePoolSize |
| | | 28 | | { |
| | 2 | 29 | | get { return (int)base[ConfigurationStrings.MaxWritePoolSize]; } |
| | 0 | 30 | | set { base[ConfigurationStrings.MaxWritePoolSize] = value; } |
| | | 31 | | } |
| | | 32 | | |
| | | 33 | | [ConfigurationProperty(ConfigurationStrings.MaxSessionSize, DefaultValue = BinaryEncoderDefaults.MaxSessionSize) |
| | | 34 | | [IntegerValidator(MinValue = 0)] |
| | | 35 | | public int MaxSessionSize |
| | | 36 | | { |
| | 2 | 37 | | get { return (int)base[ConfigurationStrings.MaxSessionSize]; } |
| | 0 | 38 | | set { base[ConfigurationStrings.MaxSessionSize] = value; } |
| | | 39 | | } |
| | | 40 | | |
| | | 41 | | [ConfigurationProperty(ConfigurationStrings.ReaderQuotas)] |
| | | 42 | | public XmlDictionaryReaderQuotasElement ReaderQuotas |
| | | 43 | | { |
| | 2 | 44 | | get { return (XmlDictionaryReaderQuotasElement)base[ConfigurationStrings.ReaderQuotas]; } |
| | | 45 | | } |
| | | 46 | | |
| | | 47 | | [ConfigurationProperty(ConfigurationStrings.CompressionFormat, DefaultValue = EncoderDefaults.DefaultCompression |
| | | 48 | | public CompressionFormat CompressionFormat |
| | | 49 | | { |
| | 2 | 50 | | get { return (CompressionFormat)base[ConfigurationStrings.CompressionFormat]; } |
| | 0 | 51 | | set { base[ConfigurationStrings.CompressionFormat] = value; } |
| | | 52 | | } |
| | | 53 | | |
| | | 54 | | public override void ApplyConfiguration(BindingElement bindingElement) |
| | | 55 | | { |
| | 2 | 56 | | base.ApplyConfiguration(bindingElement); |
| | 2 | 57 | | BinaryMessageEncodingBindingElement binding = (BinaryMessageEncodingBindingElement)bindingElement; |
| | 2 | 58 | | binding.MaxSessionSize = MaxSessionSize; |
| | 2 | 59 | | binding.MaxReadPoolSize = MaxReadPoolSize; |
| | 2 | 60 | | binding.MaxWritePoolSize = MaxWritePoolSize; |
| | 2 | 61 | | ReaderQuotas.ApplyConfiguration(binding.ReaderQuotas); |
| | 2 | 62 | | binding.CompressionFormat = CompressionFormat; |
| | 2 | 63 | | } |
| | | 64 | | |
| | | 65 | | public override void CopyFrom(ServiceModelExtensionElement from) |
| | | 66 | | { |
| | 0 | 67 | | base.CopyFrom(from); |
| | | 68 | | |
| | 0 | 69 | | BinaryMessageEncodingElement source = (BinaryMessageEncodingElement)from; |
| | 0 | 70 | | MaxSessionSize = source.MaxSessionSize; |
| | 0 | 71 | | MaxReadPoolSize = source.MaxReadPoolSize; |
| | 0 | 72 | | MaxWritePoolSize = source.MaxWritePoolSize; |
| | 0 | 73 | | CompressionFormat = source.CompressionFormat; |
| | 0 | 74 | | } |
| | | 75 | | |
| | | 76 | | protected internal override void InitializeFrom(BindingElement bindingElement) |
| | | 77 | | { |
| | 0 | 78 | | base.InitializeFrom(bindingElement); |
| | 0 | 79 | | BinaryMessageEncodingBindingElement binding = (BinaryMessageEncodingBindingElement)bindingElement; |
| | 0 | 80 | | SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MaxSessionSize, binding.MaxSessionSize); |
| | 0 | 81 | | SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MaxReadPoolSize, binding.MaxReadPoolSize); |
| | 0 | 82 | | SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MaxWritePoolSize, binding.MaxWritePoolSize); |
| | 0 | 83 | | ReaderQuotas.ApplyConfiguration(binding.ReaderQuotas); |
| | 0 | 84 | | SetPropertyValueIfNotDefaultValue(ConfigurationStrings.CompressionFormat, binding.CompressionFormat); |
| | 0 | 85 | | } |
| | | 86 | | |
| | | 87 | | protected internal override BindingElement CreateBindingElement() |
| | | 88 | | { |
| | 2 | 89 | | BinaryMessageEncodingBindingElement binding = new BinaryMessageEncodingBindingElement(); |
| | 2 | 90 | | ApplyConfiguration(binding); |
| | 2 | 91 | | return binding; |
| | | 92 | | } |
| | | 93 | | } |
| | | 94 | | } |