Exemple #1
0
        internal bool IsTextContentType(string contentType)
        {
            string mediaType            = TextMessageEncoderFactory.GetMediaType(this.version);
            string supportedContentType = TextMessageEncoderFactory.GetContentType(mediaType, this.writeEncoding);

            return(base.IsContentTypeSupported(contentType, supportedContentType, mediaType));
        }
        internal bool IsTextContentType(string contentType)
        {
            // check for Text contentType: text/xml or application/soap+xml
            string textMediaType   = TextMessageEncoderFactory.GetMediaType(version);
            string textContentType = TextMessageEncoderFactory.GetContentType(textMediaType, writeEncoding);

            return(IsContentTypeSupported(contentType, textContentType, textMediaType));
        }
            public TextMessageEncoder(MessageVersion version, Encoding writeEncoding, int maxReadPoolSize, int maxWritePoolSize, XmlDictionaryReaderQuotas quotas)
            {
                if (version == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("version");
                }
                if (writeEncoding == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("writeEncoding");
                }

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

                thisLock = new object();

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

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

                this.bufferedReadReaderQuotas = EncoderHelpers.GetBufferedReadQuotas(this.readerQuotas);

                this.onStreamedReaderClose = new OnXmlDictionaryReaderClose(ReturnStreamedReader);

                this.mediaType   = TextMessageEncoderFactory.GetMediaType(version);
                this.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.GetString(SR.EnvelopeVersionNotSupported, version.Envelope)));
                }
            }
Exemple #4
0
            public TextMessageEncoder(MessageVersion version, Encoding writeEncoding, int maxReadPoolSize, int maxWritePoolSize, XmlDictionaryReaderQuotas quotas)
            {
                if (version == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("version");
                }
                if (writeEncoding == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("writeEncoding");
                }

                TextEncoderDefaults.ValidateEncoding(writeEncoding);
                _writeEncoding        = writeEncoding;
                _optimizeWriteForUTF8 = IsUTF8Encoding(writeEncoding);

                _thisLock = new object();

                _version          = version;
                _maxReadPoolSize  = maxReadPoolSize;
                _maxWritePoolSize = maxWritePoolSize;

                _readerQuotas = new XmlDictionaryReaderQuotas();
                quotas.CopyTo(_readerQuotas);
                _bufferedReadReaderQuotas = EncoderHelpers.GetBufferedReadQuotas(_readerQuotas);

                _mediaType   = TextMessageEncoderFactory.GetMediaType(version);
                _contentType = TextMessageEncoderFactory.GetContentType(_mediaType, writeEncoding);
                if (version.Envelope == EnvelopeVersion.Soap12)
                {
                    _contentEncodingMap = TextMessageEncoderFactory.Soap12Content;
                }
                else if (version.Envelope == EnvelopeVersion.Soap11)
                {
                    // public profile does not allow SOAP1.1/WSA1.0. However, the EnvelopeVersion 1.1 is supported. Need to know what the implications are here
                    // but I think that it's not necessary to have here since we're a sender in N only.
                    _contentEncodingMap = TextMessageEncoderFactory.Soap11Content;
                }
                else if (version.Envelope == EnvelopeVersion.None)
                {
                    _contentEncodingMap = TextMessageEncoderFactory.SoapNoneContent;
                }
                else
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(
                                                                                  string.Format(SRServiceModel.EnvelopeVersionNotSupported, version.Envelope)));
                }
            }