示例#1
0
        public MtomMessageEncoder(MessageVersion version, Encoding writeEncoding, int maxReadPoolSize, int maxWritePoolSize, int maxBufferSize, XmlDictionaryReaderQuotas quotas, MtomMessageEncoderFactory factory)
        {
            if (version == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(version));
            }
            if (writeEncoding == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(writeEncoding));
            }

            _factory = factory;
            TextEncoderDefaults.ValidateEncoding(writeEncoding);
            _writeEncoding = writeEncoding;

            MaxReadPoolSize  = maxReadPoolSize;
            MaxWritePoolSize = maxWritePoolSize;

            ReaderQuotas = new XmlDictionaryReaderQuotas();
            quotas.CopyTo(ReaderQuotas);

            _bufferedReadReaderQuotas = EncoderHelpers.GetBufferedReadQuotas(ReaderQuotas);
            MaxBufferSize             = maxBufferSize;
            _version     = version;
            _contentType = GetContentType(out _boundary);
        }
        public MtomMessageEncodingBindingElement(MessageVersion messageVersion, Encoding writeEncoding)
        {
            if (messageVersion == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(messageVersion));
            }

            if (messageVersion == MessageVersion.None)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.Format(SR.MtomEncoderBadMessageVersion, messageVersion.ToString()), nameof(messageVersion)));
            }

            if (writeEncoding == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(writeEncoding));
            }

            TextEncoderDefaults.ValidateEncoding(writeEncoding);
            _maxReadPoolSize  = EncoderDefaults.MaxReadPoolSize;
            _maxWritePoolSize = EncoderDefaults.MaxWritePoolSize;
            _readerQuotas     = new XmlDictionaryReaderQuotas();
            EncoderDefaults.ReaderQuotas.CopyTo(_readerQuotas);
            _maxBufferSize  = MtomEncoderDefaults.MaxBufferSize;
            _messageVersion = messageVersion;
            _writeEncoding  = writeEncoding;
        }
示例#3
0
            public TextMessageEncoder(MessageVersion version, Encoding writeEncoding, int maxReadPoolSize, int maxWritePoolSize, XmlDictionaryReaderQuotas quotas)
            {
                if (version == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(version));
                }
                if (writeEncoding == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(writeEncoding));
                }

                TextEncoderDefaults.ValidateEncoding(writeEncoding);
                this.writeEncoding   = writeEncoding;
                optimizeWriteForUTF8 = IsUTF8Encoding(writeEncoding);

                thisLock = new object();

                this.version          = version;
                this.maxReadPoolSize  = maxReadPoolSize;
                this.maxWritePoolSize = maxWritePoolSize;

                readerQuotas = new XmlDictionaryReaderQuotas();
                quotas.CopyTo(readerQuotas);

                bufferedReadReaderQuotas = EncoderHelpers.GetBufferedReadQuotas(readerQuotas);

                onStreamedReaderClose = new OnXmlDictionaryReaderClose(ReturnStreamedReader);

                mediaType   = TextMessageEncoderFactory.GetMediaType(version);
                contentType = TextMessageEncoderFactory.GetContentType(mediaType, writeEncoding);
                if (version.Envelope == EnvelopeVersion.Soap12)
                {
                    contentEncodingMap = TextMessageEncoderFactory.Soap12Content;
                }
                else if (version.Envelope == EnvelopeVersion.Soap11)
                {
                    contentEncodingMap = TextMessageEncoderFactory.Soap11Content;
                }
                else if (version.Envelope == EnvelopeVersion.None)
                {
                    contentEncodingMap = TextMessageEncoderFactory.SoapNoneContent;
                }
                else
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(
                                                                                  SR.Format(SR.EnvelopeVersionNotSupported, version.Envelope)));
                }
            }
示例#4
0
        public TextMessageEncodingBindingElement(MessageVersion messageVersion, Encoding writeEncoding)
        {
            if (writeEncoding == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(writeEncoding));
            }

            TextEncoderDefaults.ValidateEncoding(writeEncoding);

            _maxReadPoolSize  = EncoderDefaults.MaxReadPoolSize;
            _maxWritePoolSize = EncoderDefaults.MaxWritePoolSize;
            _readerQuotas     = new XmlDictionaryReaderQuotas();
            EncoderDefaults.ReaderQuotas.CopyTo(_readerQuotas);
            _messageVersion = messageVersion ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(messageVersion));
            _writeEncoding  = writeEncoding;
        }