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; }
internal static bool TryGetEncodingFromCharSet(string charSet, out Encoding encoding) { encoding = null; if (charSet == null || charSet.Length == 0) { return(true); } return(TextEncoderDefaults.TryGetEncoding(charSet, out encoding)); }
internal override bool IsCharSetSupported(string charSet) { if (charSet == null || charSet.Length == 0) { return(true); } Encoding tmp; return(TextEncoderDefaults.TryGetEncoding(charSet, out tmp)); }
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))); } }
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; }
internal override bool IsCharSetSupported(string charSet) { Encoding tmp; if (!TextEncoderDefaults.TryGetEncoding(charSet, out tmp)) { // GetEncodingFromContentType supports charset with quotes (by simply stripping them) so we do the same here // This also gives us parity with Desktop WCF behavior if (charSet.Length > 2 && charSet[0] == '"' && charSet[charSet.Length - 1] == '"') { charSet = charSet.Substring(1, charSet.Length - 2); return(TextEncoderDefaults.TryGetEncoding(charSet, out tmp)); } return(false); } return(true); }
internal static string GetContentType(string mediaType, Encoding encoding) { return(string.Format(CultureInfo.InvariantCulture, "{0}; charset={1}", mediaType, TextEncoderDefaults.EncodingToCharSet(encoding))); }
internal override bool IsCharSetSupported(string charSet) { Encoding tmp; return(TextEncoderDefaults.TryGetEncoding(charSet, out tmp)); }