| | | 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.ComponentModel; |
| | | 6 | | using System.Configuration; |
| | | 7 | | using System.Text; |
| | | 8 | | using CoreWCF.Channels; |
| | | 9 | | |
| | | 10 | | namespace CoreWCF.Configuration |
| | | 11 | | { |
| | | 12 | | public sealed class MtomMessageEncodingElement : BindingElementExtensionElement |
| | | 13 | | { |
| | 2 | 14 | | public MtomMessageEncodingElement() |
| | | 15 | | { |
| | 2 | 16 | | } |
| | | 17 | | |
| | | 18 | | public override void ApplyConfiguration(BindingElement bindingElement) |
| | | 19 | | { |
| | 2 | 20 | | base.ApplyConfiguration(bindingElement); |
| | 2 | 21 | | MtomMessageEncodingBindingElement binding = (MtomMessageEncodingBindingElement)bindingElement; |
| | 2 | 22 | | binding.MessageVersion = MessageVersion; |
| | 2 | 23 | | binding.WriteEncoding = WriteEncoding; |
| | 2 | 24 | | binding.MaxReadPoolSize = MaxReadPoolSize; |
| | 2 | 25 | | binding.MaxWritePoolSize = MaxWritePoolSize; |
| | 2 | 26 | | ReaderQuotas.ApplyConfiguration(binding.ReaderQuotas); |
| | 2 | 27 | | binding.MaxBufferSize = MaxBufferSize; |
| | 2 | 28 | | } |
| | | 29 | | |
| | | 30 | | public override Type BindingElementType |
| | | 31 | | { |
| | 12 | 32 | | get { return typeof(MtomMessageEncodingBindingElement); } |
| | | 33 | | } |
| | | 34 | | |
| | | 35 | | public override void CopyFrom(ServiceModelExtensionElement from) |
| | | 36 | | { |
| | 0 | 37 | | base.CopyFrom(from); |
| | | 38 | | |
| | 0 | 39 | | MtomMessageEncodingElement source = (MtomMessageEncodingElement)from; |
| | 0 | 40 | | MessageVersion = source.MessageVersion; |
| | 0 | 41 | | WriteEncoding = source.WriteEncoding; |
| | 0 | 42 | | MaxReadPoolSize = source.MaxReadPoolSize; |
| | 0 | 43 | | MaxWritePoolSize = source.MaxWritePoolSize; |
| | 0 | 44 | | MaxBufferSize = source.MaxBufferSize; |
| | 0 | 45 | | } |
| | | 46 | | |
| | | 47 | | protected internal override BindingElement CreateBindingElement() |
| | | 48 | | { |
| | 2 | 49 | | MtomMessageEncodingBindingElement binding = new MtomMessageEncodingBindingElement(); |
| | 2 | 50 | | ApplyConfiguration(binding); |
| | 2 | 51 | | return binding; |
| | | 52 | | } |
| | | 53 | | |
| | | 54 | | protected internal override void InitializeFrom(BindingElement bindingElement) |
| | | 55 | | { |
| | 0 | 56 | | base.InitializeFrom(bindingElement); |
| | 0 | 57 | | MtomMessageEncodingBindingElement binding = (MtomMessageEncodingBindingElement)bindingElement; |
| | 0 | 58 | | SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MessageVersion, binding.MessageVersion); |
| | 0 | 59 | | SetPropertyValueIfNotDefaultValue(ConfigurationStrings.WriteEncoding, binding.WriteEncoding); |
| | 0 | 60 | | SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MaxReadPoolSize, binding.MaxReadPoolSize); |
| | 0 | 61 | | SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MaxWritePoolSize, binding.MaxWritePoolSize); |
| | 0 | 62 | | ReaderQuotas.InitializeFrom(binding.ReaderQuotas); |
| | 0 | 63 | | SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MaxBufferSize, binding.MaxBufferSize); |
| | 0 | 64 | | } |
| | | 65 | | |
| | | 66 | | [ConfigurationProperty(ConfigurationStrings.MaxReadPoolSize, DefaultValue = EncoderDefaults.MaxReadPoolSize)] |
| | | 67 | | [IntegerValidator(MinValue = 1)] |
| | | 68 | | public int MaxReadPoolSize |
| | | 69 | | { |
| | 2 | 70 | | get { return (int)base[ConfigurationStrings.MaxReadPoolSize]; } |
| | 0 | 71 | | set { base[ConfigurationStrings.MaxReadPoolSize] = value; } |
| | | 72 | | } |
| | | 73 | | |
| | | 74 | | [ConfigurationProperty(ConfigurationStrings.MaxWritePoolSize, DefaultValue = EncoderDefaults.MaxWritePoolSize)] |
| | | 75 | | [IntegerValidator(MinValue = 1)] |
| | | 76 | | public int MaxWritePoolSize |
| | | 77 | | { |
| | 2 | 78 | | get { return (int)base[ConfigurationStrings.MaxWritePoolSize]; } |
| | 0 | 79 | | set { base[ConfigurationStrings.MaxWritePoolSize] = value; } |
| | | 80 | | } |
| | | 81 | | |
| | | 82 | | [ConfigurationProperty(ConfigurationStrings.MessageVersion, DefaultValue = TextEncoderDefaults.MessageVersionStr |
| | | 83 | | [TypeConverter(typeof(MessageVersionConverter))] |
| | | 84 | | public MessageVersion MessageVersion |
| | | 85 | | { |
| | 2 | 86 | | get { return (MessageVersion)base[ConfigurationStrings.MessageVersion]; } |
| | 0 | 87 | | set { base[ConfigurationStrings.MessageVersion] = value; } |
| | | 88 | | } |
| | | 89 | | |
| | | 90 | | [ConfigurationProperty(ConfigurationStrings.ReaderQuotas)] |
| | | 91 | | public XmlDictionaryReaderQuotasElement ReaderQuotas |
| | | 92 | | { |
| | 2 | 93 | | get { return (XmlDictionaryReaderQuotasElement)base[ConfigurationStrings.ReaderQuotas]; } |
| | | 94 | | } |
| | | 95 | | |
| | | 96 | | [ConfigurationProperty(ConfigurationStrings.MaxBufferSize, DefaultValue = MtomEncoderDefaults.MaxBufferSize)] |
| | | 97 | | [IntegerValidator(MinValue = 1)] |
| | | 98 | | public int MaxBufferSize |
| | | 99 | | { |
| | 2 | 100 | | get { return (int)base[ConfigurationStrings.MaxBufferSize]; } |
| | 0 | 101 | | set { base[ConfigurationStrings.MaxBufferSize] = value; } |
| | | 102 | | } |
| | | 103 | | |
| | | 104 | | [ConfigurationProperty(ConfigurationStrings.WriteEncoding, DefaultValue = TextEncoderDefaults.EncodingString)] |
| | | 105 | | [TypeConverter(typeof(EncodingConverter))] |
| | | 106 | | public Encoding WriteEncoding |
| | | 107 | | { |
| | 2 | 108 | | get { return (Encoding)base[ConfigurationStrings.WriteEncoding]; } |
| | 0 | 109 | | set { base[ConfigurationStrings.WriteEncoding] = value; } |
| | | 110 | | } |
| | | 111 | | } |
| | | 112 | | } |