| | | 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.ComponentModel; |
| | | 5 | | using System.Xml; |
| | | 6 | | using CoreWCF.Runtime; |
| | | 7 | | |
| | | 8 | | namespace CoreWCF.Channels |
| | | 9 | | { |
| | | 10 | | public sealed class ByteStreamMessageEncodingBindingElement : MessageEncodingBindingElement |
| | | 11 | | { |
| | | 12 | | private readonly XmlDictionaryReaderQuotas _readerQuotas; |
| | | 13 | | private bool _moveBodyReaderToContent; |
| | | 14 | | |
| | 2 | 15 | | public ByteStreamMessageEncodingBindingElement() : this((XmlDictionaryReaderQuotas)null) |
| | | 16 | | { |
| | 2 | 17 | | } |
| | | 18 | | |
| | 35 | 19 | | public ByteStreamMessageEncodingBindingElement(XmlDictionaryReaderQuotas quota) |
| | | 20 | | { |
| | 35 | 21 | | _readerQuotas = new XmlDictionaryReaderQuotas(); |
| | 35 | 22 | | if (quota != null) |
| | | 23 | | { |
| | 33 | 24 | | quota.CopyTo(_readerQuotas); |
| | | 25 | | } |
| | 35 | 26 | | } |
| | | 27 | | |
| | | 28 | | private ByteStreamMessageEncodingBindingElement(ByteStreamMessageEncodingBindingElement byteStreamEncoderBinding |
| | 0 | 29 | | : this(byteStreamEncoderBindingElement._readerQuotas) |
| | | 30 | | { |
| | 0 | 31 | | } |
| | | 32 | | |
| | | 33 | | public override MessageVersion MessageVersion |
| | | 34 | | { |
| | | 35 | | get |
| | | 36 | | { |
| | 0 | 37 | | return MessageVersion.None; |
| | | 38 | | } |
| | | 39 | | set |
| | | 40 | | { |
| | 0 | 41 | | if (value != MessageVersion.None) |
| | | 42 | | { |
| | 0 | 43 | | throw Fx.Exception.Argument(nameof(MessageVersion), SR.Format(SR.ByteStreamMessageEncoderMessageVers |
| | | 44 | | } |
| | 0 | 45 | | } |
| | | 46 | | } |
| | | 47 | | |
| | | 48 | | public XmlDictionaryReaderQuotas ReaderQuotas |
| | | 49 | | { |
| | | 50 | | get |
| | | 51 | | { |
| | 0 | 52 | | return _readerQuotas; |
| | | 53 | | } |
| | | 54 | | set |
| | | 55 | | { |
| | 0 | 56 | | if (value == null) |
| | 0 | 57 | | throw Fx.Exception.ArgumentNull(nameof(ReaderQuotas)); |
| | 0 | 58 | | value.CopyTo(ReaderQuotas); |
| | 0 | 59 | | } |
| | | 60 | | } |
| | | 61 | | |
| | | 62 | | public override T GetProperty<T>(BindingContext context) |
| | | 63 | | { |
| | 33 | 64 | | if (context == null) |
| | | 65 | | { |
| | 0 | 66 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(context)); |
| | | 67 | | } |
| | 33 | 68 | | if (typeof(T).FullName == "CoreWCF.Channels.WebMessageEncoderFactory+WebMessageEncoder") |
| | | 69 | | { |
| | 33 | 70 | | _moveBodyReaderToContent = true; |
| | 33 | 71 | | return null; |
| | | 72 | | } |
| | | 73 | | |
| | 0 | 74 | | return base.GetProperty<T>(context); |
| | | 75 | | } |
| | | 76 | | |
| | 35 | 77 | | public override MessageEncoderFactory CreateMessageEncoderFactory() => new ByteStreamMessageEncoderFactory(_read |
| | | 78 | | |
| | 0 | 79 | | public override BindingElement Clone() => new ByteStreamMessageEncodingBindingElement(this); |
| | | 80 | | } |
| | | 81 | | } |