public SoapMessageEncoder(MessageVersion version, Encoding writeEncoding, XmlDictionaryReaderQuotas quotas, bool omitXmlDeclaration, bool indentXml) { _indentXml = indentXml; _omitXmlDeclaration = omitXmlDeclaration; if (writeEncoding == null) { throw new ArgumentNullException(nameof(writeEncoding)); } _supportXmlDictionaryReader = SoapMessageEncoderDefaults.TryValidateEncoding(writeEncoding, out _); _writeEncoding = writeEncoding; _optimizeWriteForUtf8 = IsUtf8Encoding(writeEncoding); MessageVersion = version ?? throw new ArgumentNullException(nameof(version)); ReaderQuotas = new XmlDictionaryReaderQuotas(); (quotas ?? XmlDictionaryReaderQuotas.Max).CopyTo(ReaderQuotas); MediaType = GetMediaType(version); ContentType = GetContentType(MediaType, writeEncoding); }
public SoapMessageEncoder(MessageVersion version, Encoding writeEncoding, XmlDictionaryReaderQuotas quotas) { if (writeEncoding == null) { throw new ArgumentNullException(nameof(writeEncoding)); } SoapMessageEncoderDefaults.ValidateEncoding(writeEncoding); _writeEncoding = writeEncoding; _optimizeWriteForUtf8 = IsUtf8Encoding(writeEncoding); MessageVersion = version ?? throw new ArgumentNullException(nameof(version)); MessageVersion = version; ReaderQuotas = new XmlDictionaryReaderQuotas(); quotas.CopyTo(ReaderQuotas); MediaType = GetMediaType(version); ContentType = GetContentType(MediaType, writeEncoding); }
internal static string GetContentType(string mediaType, Encoding encoding) { return(string.Format(CultureInfo.InvariantCulture, "{0}; charset={1}", mediaType, SoapMessageEncoderDefaults.EncodingToCharSet(encoding))); }