public MtomMessageEncodingBindingElement(MessageVersion messageVersion, Encoding writeEncoding) { if (messageVersion == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("messageVersion"); } if (messageVersion == MessageVersion.None) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(string.Format(SRServiceModel.MtomEncoderBadMessageVersion, messageVersion.ToString()), "messageVersion")); } if (writeEncoding == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("writeEncoding"); } TextEncoderDefaults.ValidateEncoding(writeEncoding); _maxReadPoolSize = EncoderDefaults.MaxReadPoolSize; _maxWritePoolSize = EncoderDefaults.MaxWritePoolSize; _readerQuotas = new XmlDictionaryReaderQuotas(); EncoderDefaults.ReaderQuotas.CopyTo(_readerQuotas); _maxBufferSize = MtomEncoderDefaults.MaxBufferSize; _messageVersion = messageVersion; _writeEncoding = writeEncoding; }
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 MtomMessageEncoder(System.ServiceModel.Channels.MessageVersion version, Encoding writeEncoding, int maxReadPoolSize, int maxWritePoolSize, int maxBufferSize, XmlDictionaryReaderQuotas quotas) { if (version == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("version"); } if (writeEncoding == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("writeEncoding"); } TextEncoderDefaults.ValidateEncoding(writeEncoding); this.writeEncoding = writeEncoding; this.maxReadPoolSize = maxReadPoolSize; this.maxWritePoolSize = maxWritePoolSize; this.readerQuotas = new XmlDictionaryReaderQuotas(); quotas.CopyTo(this.readerQuotas); this.maxBufferSize = maxBufferSize; this.onStreamedReaderClose = new OnXmlDictionaryReaderClose(this.ReturnStreamedReader); this.thisLock = new object(); if (version.Envelope == EnvelopeVersion.Soap12) { this.contentEncodingMap = TextMessageEncoderFactory.Soap12Content; } else { if (version.Envelope != EnvelopeVersion.Soap11) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Invalid MessageVersion", new object[0]))); } this.contentEncodingMap = TextMessageEncoderFactory.Soap11Content; } this.version = version; }
public JsonMessageEncoder(Encoding writeEncoding, int maxReadPoolSize, int maxWritePoolSize, XmlDictionaryReaderQuotas quotas, bool crossDomainScriptAccessEnabled) { if (writeEncoding == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("writeEncoding"); } thisLock = new object(); TextEncoderDefaults.ValidateEncoding(writeEncoding); this.writeEncoding = writeEncoding; this.maxReadPoolSize = maxReadPoolSize; this.maxWritePoolSize = maxWritePoolSize; this.readerQuotas = new XmlDictionaryReaderQuotas(); this.onStreamedReaderClose = new OnXmlDictionaryReaderClose(ReturnStreamedReader); quotas.CopyTo(this.readerQuotas); this.bufferedReadReaderQuotas = EncoderHelpers.GetBufferedReadQuotas(this.readerQuotas); this.contentType = WebMessageEncoderFactory.GetContentType(JsonGlobals.applicationJsonMediaType, writeEncoding); this.crossDomainScriptAccessEnabled = crossDomainScriptAccessEnabled; this.encodedClosingFunctionCall = this.writeEncoding.GetBytes(");"); }
internal override bool IsCharSetSupported(string charSet) { if ((charSet != null) && (charSet.Length != 0)) { Encoding encoding; return(TextEncoderDefaults.TryGetEncoding(charSet, out encoding)); } return(true); }
internal static bool TryGetEncodingFromCharSet(string charSet, out Encoding encoding) { encoding = null; if ((charSet != null) && (charSet.Length != 0)) { return(TextEncoderDefaults.TryGetEncoding(charSet, out encoding)); } return(true); }
internal static string GetContentType(string mediaType, Encoding encoding) { string charset = TextEncoderDefaults.EncodingToCharSet(encoding); if (!string.IsNullOrEmpty(charset)) { return(string.Format(CultureInfo.InvariantCulture, "{0}; charset={1}", mediaType, charset)); } return(mediaType); }
internal override bool IsCharSetSupported(string charSet) { if (charSet == null || charSet.Length == 0) { return(true); } Encoding tmp; return(TextEncoderDefaults.TryGetEncoding(charSet, out tmp)); }
public WebMessageEncodingBindingElement(Encoding writeEncoding) { if (writeEncoding == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("writeEncoding"); } TextEncoderDefaults.ValidateEncoding(writeEncoding); this.maxReadPoolSize = EncoderDefaults.MaxReadPoolSize; this.maxWritePoolSize = EncoderDefaults.MaxWritePoolSize; this.readerQuotas = new XmlDictionaryReaderQuotas(); EncoderDefaults.ReaderQuotas.CopyTo(this.readerQuotas); this.writeEncoding = writeEncoding; }
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))); } }
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; }
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))); } }
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); }
public TextMessageEncodingBindingElement(System.ServiceModel.Channels.MessageVersion messageVersion, Encoding writeEncoding) { if (messageVersion == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("messageVersion"); } if (writeEncoding == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("writeEncoding"); } TextEncoderDefaults.ValidateEncoding(writeEncoding); this.maxReadPoolSize = 0x40; this.maxWritePoolSize = 0x10; this.readerQuotas = new XmlDictionaryReaderQuotas(); EncoderDefaults.ReaderQuotas.CopyTo(this.readerQuotas); this.messageVersion = messageVersion; this.writeEncoding = writeEncoding; }
public WebMessageEncoder(Encoding writeEncoding, int maxReadPoolSize, int maxWritePoolSize, XmlDictionaryReaderQuotas quotas, WebContentTypeMapper contentTypeMapper, bool javascriptCallbackEnabled) { if (writeEncoding == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("writeEncoding"); } this.thisLock = new object(); TextEncoderDefaults.ValidateEncoding(writeEncoding); this.writeEncoding = writeEncoding; this.maxReadPoolSize = maxReadPoolSize; this.maxWritePoolSize = maxWritePoolSize; this.contentTypeMapper = contentTypeMapper; this.javascriptCallbackEnabled = javascriptCallbackEnabled; this.readerQuotas = new XmlDictionaryReaderQuotas(); quotas.CopyTo(this.readerQuotas); this.defaultContentType = GetContentType(defaultMediaType, writeEncoding); }
public MtomMessageEncodingBindingElement(System.ServiceModel.Channels.MessageVersion messageVersion, Encoding writeEncoding) { if (messageVersion == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("messageVersion"); } if (messageVersion == System.ServiceModel.Channels.MessageVersion.None) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(System.ServiceModel.SR.GetString("MtomEncoderBadMessageVersion", new object[] { messageVersion.ToString() }), "messageVersion")); } if (writeEncoding == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("writeEncoding"); } TextEncoderDefaults.ValidateEncoding(writeEncoding); this.maxReadPoolSize = 0x40; this.maxWritePoolSize = 0x10; this.readerQuotas = new XmlDictionaryReaderQuotas(); EncoderDefaults.ReaderQuotas.CopyTo(this.readerQuotas); this.maxBufferSize = 0x10000; this.messageVersion = messageVersion; this.writeEncoding = writeEncoding; }
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)); }