| | | 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 TextMessageEncodingElement : BindingElementExtensionElement |
| | | 13 | | { |
| | | 14 | | public override void ApplyConfiguration(BindingElement bindingElement) |
| | | 15 | | { |
| | 4 | 16 | | base.ApplyConfiguration(bindingElement); |
| | 4 | 17 | | TextMessageEncodingBindingElement binding = (TextMessageEncodingBindingElement)bindingElement; |
| | 4 | 18 | | binding.MessageVersion = MessageVersion; |
| | 4 | 19 | | binding.WriteEncoding = WriteEncoding; |
| | 4 | 20 | | binding.MaxReadPoolSize = MaxReadPoolSize; |
| | 4 | 21 | | binding.MaxWritePoolSize = MaxWritePoolSize; |
| | 4 | 22 | | ReaderQuotas.ApplyConfiguration(binding.ReaderQuotas); |
| | 4 | 23 | | } |
| | | 24 | | |
| | | 25 | | public override Type BindingElementType |
| | | 26 | | { |
| | 24 | 27 | | get { return typeof(TextMessageEncodingBindingElement); } |
| | | 28 | | } |
| | | 29 | | |
| | | 30 | | public override void CopyFrom(ServiceModelExtensionElement from) |
| | | 31 | | { |
| | 0 | 32 | | base.CopyFrom(from); |
| | | 33 | | |
| | 0 | 34 | | TextMessageEncodingElement source = (TextMessageEncodingElement)from; |
| | 0 | 35 | | MessageVersion = source.MessageVersion; |
| | 0 | 36 | | WriteEncoding = source.WriteEncoding; |
| | 0 | 37 | | MaxReadPoolSize = source.MaxReadPoolSize; |
| | 0 | 38 | | MaxWritePoolSize = source.MaxWritePoolSize; |
| | 0 | 39 | | } |
| | | 40 | | |
| | | 41 | | protected internal override BindingElement CreateBindingElement() |
| | | 42 | | { |
| | 4 | 43 | | TextMessageEncodingBindingElement binding = new TextMessageEncodingBindingElement(); |
| | 4 | 44 | | ApplyConfiguration(binding); |
| | 4 | 45 | | return binding; |
| | | 46 | | } |
| | | 47 | | |
| | | 48 | | protected internal override void InitializeFrom(BindingElement bindingElement) |
| | | 49 | | { |
| | 0 | 50 | | base.InitializeFrom(bindingElement); |
| | 0 | 51 | | TextMessageEncodingBindingElement binding = (TextMessageEncodingBindingElement)bindingElement; |
| | 0 | 52 | | SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MessageVersion, binding.MessageVersion); |
| | 0 | 53 | | SetPropertyValueIfNotDefaultValue(ConfigurationStrings.WriteEncoding, binding.WriteEncoding); |
| | 0 | 54 | | SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MaxReadPoolSize, binding.MaxReadPoolSize); |
| | 0 | 55 | | SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MaxWritePoolSize, binding.MaxWritePoolSize); |
| | 0 | 56 | | ReaderQuotas.InitializeFrom(binding.ReaderQuotas); |
| | 0 | 57 | | } |
| | | 58 | | |
| | | 59 | | [ConfigurationProperty(ConfigurationStrings.MaxReadPoolSize, DefaultValue = EncoderDefaults.MaxReadPoolSize)] |
| | | 60 | | [IntegerValidator(MinValue = 1)] |
| | | 61 | | public int MaxReadPoolSize |
| | | 62 | | { |
| | 4 | 63 | | get { return (int)base[ConfigurationStrings.MaxReadPoolSize]; } |
| | 0 | 64 | | set { base[ConfigurationStrings.MaxReadPoolSize] = value; } |
| | | 65 | | } |
| | | 66 | | |
| | | 67 | | [ConfigurationProperty(ConfigurationStrings.MaxWritePoolSize, DefaultValue = EncoderDefaults.MaxWritePoolSize)] |
| | | 68 | | [IntegerValidator(MinValue = 1)] |
| | | 69 | | public int MaxWritePoolSize |
| | | 70 | | { |
| | 4 | 71 | | get { return (int)base[ConfigurationStrings.MaxWritePoolSize]; } |
| | 0 | 72 | | set { base[ConfigurationStrings.MaxWritePoolSize] = value; } |
| | | 73 | | } |
| | | 74 | | |
| | | 75 | | [ConfigurationProperty(ConfigurationStrings.MessageVersion, DefaultValue = TextEncoderDefaults.MessageVersionStr |
| | | 76 | | [TypeConverter(typeof(MessageVersionConverter))] |
| | | 77 | | public MessageVersion MessageVersion |
| | | 78 | | { |
| | 4 | 79 | | get { return (MessageVersion)base[ConfigurationStrings.MessageVersion]; } |
| | 0 | 80 | | set { base[ConfigurationStrings.MessageVersion] = value; } |
| | | 81 | | } |
| | | 82 | | |
| | | 83 | | [ConfigurationProperty(ConfigurationStrings.ReaderQuotas)] |
| | | 84 | | public XmlDictionaryReaderQuotasElement ReaderQuotas |
| | | 85 | | { |
| | 4 | 86 | | get { return (XmlDictionaryReaderQuotasElement)base[ConfigurationStrings.ReaderQuotas]; } |
| | | 87 | | } |
| | | 88 | | |
| | | 89 | | [ConfigurationProperty(ConfigurationStrings.WriteEncoding, DefaultValue = TextEncoderDefaults.EncodingString)] |
| | | 90 | | [TypeConverter(typeof(EncodingConverter))] |
| | | 91 | | public Encoding WriteEncoding |
| | | 92 | | { |
| | 4 | 93 | | get { return (Encoding)base[ConfigurationStrings.WriteEncoding]; } |
| | 0 | 94 | | set { base[ConfigurationStrings.WriteEncoding] = value; } |
| | | 95 | | } |
| | | 96 | | } |
| | | 97 | | } |