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 static string GetContentType(WebMessageEncodingBindingElement encodingElement) { if (encodingElement == null) { return(WebMessageEncoderFactory.GetContentType(JsonGlobals.applicationJsonMediaType, TextEncoderDefaults.Encoding)); } else { return(WebMessageEncoderFactory.GetContentType(JsonGlobals.applicationJsonMediaType, encodingElement.WriteEncoding)); } }
static TextMessageEncoderFactory.ContentEncoding[] GetContentEncodingMap(string mediaType) { Encoding[] readEncodings = TextMessageEncoderFactory.GetSupportedEncodings(); TextMessageEncoderFactory.ContentEncoding[] map = new TextMessageEncoderFactory.ContentEncoding[readEncodings.Length]; for (int i = 0; i < readEncodings.Length; i++) { TextMessageEncoderFactory.ContentEncoding contentEncoding = new TextMessageEncoderFactory.ContentEncoding(); contentEncoding.contentType = WebMessageEncoderFactory.GetContentType(mediaType, readEncodings[i]); contentEncoding.encoding = readEncodings[i]; map[i] = contentEncoding; } return(map); }