示例#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);
        }
示例#2
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)));
                }
            }