public UTF8BufferedMessageData(TextMessageEncoder messageEncoder, int maxReaderPoolSize) : base(messageEncoder.RecycledStatePool) { _messageEncoder = messageEncoder; _readerPool = new Pool <XmlDictionaryReader>(maxReaderPoolSize); _onClose = new OnXmlDictionaryReaderClose(OnXmlReaderClosed); }
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; }
private void MoveToInitial(XmlDictionaryReaderQuotas quotas, XmlBinaryReaderSession session, OnXmlDictionaryReaderClose onClose) { MoveToInitial(quotas); _maxBytesPerRead = quotas.MaxBytesPerRead; _arrayState = ArrayState.None; _isTextWithEndElement = false; }
/// <summary> /// Constructs a <see cref="PoxBinaryBufferedMessageData"/>. /// </summary> /// <param name="buffer">The message contents.</param> /// <param name="bufferManager">The buffer manager from which /// <paramref name="buffer"/> came.</param> /// <param name="encoder">The encoder producing the message contents.</param> internal PoxBinaryBufferedMessageData(ArraySegment <byte> buffer, BufferManager bufferManager, PoxBinaryMessageEncoder encoder) : this(buffer, encoder) { this._bufferManager = bufferManager; this._onReaderClose = new OnXmlDictionaryReaderClose(this.OnReaderClose); }
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(");"); }
public void SetInput(Stream stream, Encoding[] encodings, string contentType, XmlDictionaryReaderQuotas quotas, int maxBufferSize, OnXmlDictionaryReaderClose onClose) { SetReadEncodings(encodings); CheckContentType(contentType); Initialize(stream, contentType, quotas, maxBufferSize); this.onClose = onClose; }
private void Initialize(IXmlDictionary dictionary, XmlDictionaryReaderQuotas quotas, XmlBinaryReaderSession session, OnXmlDictionaryReaderClose onClose) { if (quotas == null) { throw new ArgumentNullException("quotas"); } if (dictionary == null) { dictionary = new XmlDictionary(); } this.dictionary = dictionary; this.quota = quotas; if (session == null) { session = new XmlBinaryReaderSession(); } this.session = session; on_close = onClose; NameTable nt = new NameTable(); this.context = new XmlParserContext(nt, new XmlNamespaceManager(nt), null, XmlSpace.None); current = node = new NodeInfo(); current.Reset(); node_stack.Add(node); }
public MtomBufferedMessageData(MtomMessageEncoder messageEncoder, int maxReaderPoolSize) : base(messageEncoder.RecycledStatePool) { this.messageEncoder = messageEncoder; readerPool = new Pool <XmlDictionaryReader>(maxReaderPoolSize); onClose = new OnXmlDictionaryReaderClose(OnXmlReaderClosed); }
public static XmlDictionaryReader CreateTextReader( byte [] buffer, int offset, int count, Encoding encoding, XmlDictionaryReaderQuotas quotas, OnXmlDictionaryReaderClose onClose) { return(CreateTextReader(new MemoryStream(buffer, offset, count), encoding, quotas, onClose)); }
public static XmlDictionaryReader CreateMtomReader( Stream stream, Encoding [] encodings, string contentType, XmlDictionaryReaderQuotas quotas, int maxBufferSize, OnXmlDictionaryReaderClose onClose) { return(new XmlMtomDictionaryReader(stream, encodings, contentType, quotas, maxBufferSize, onClose)); }
public static XmlDictionaryReader CreateMtomReader( byte [] buffer, int offset, int count, Encoding [] encodings, string contentType, XmlDictionaryReaderQuotas quotas, int maxBufferSize, OnXmlDictionaryReaderClose onClose) { return(CreateMtomReader(new MemoryStream(buffer, offset, count), encodings, contentType, quotas, maxBufferSize, onClose)); }
public static XmlDictionaryReader CreateBinaryReader( Stream stream, IXmlDictionary dictionary, XmlDictionaryReaderQuotas quotas, XmlBinaryReaderSession session, OnXmlDictionaryReaderClose onClose) { return(new XmlBinaryDictionaryReader(stream, dictionary, quotas, session, onClose)); }
public override void Close() { if (on_close != null) { on_close(this); on_close = null; } read_state = ReadState.Closed; }
public XmlBinaryDictionaryReader(Stream stream, IXmlDictionary dictionary, XmlDictionaryReaderQuotas quota, XmlBinaryReaderSession session, OnXmlDictionaryReaderClose onClose) { source = new StreamSource(stream); Initialize(dictionary, quota, session, onClose); }
public static XmlDictionaryReader CreateBinaryReader(byte[] buffer, int offset, int count, IXmlDictionary dictionary, XmlDictionaryReaderQuotas quotas, XmlBinaryReaderSession session, OnXmlDictionaryReaderClose onClose) { XmlBinaryReader reader = new XmlBinaryReader(); reader.SetInput(buffer, offset, count, dictionary, quotas, session, onClose); return reader; }
public XmlBinaryDictionaryReader(byte [] buffer, int offset, int count, IXmlDictionary dictionary, XmlDictionaryReaderQuotas quota, XmlBinaryReaderSession session, OnXmlDictionaryReaderClose onClose) { source = /*new ArraySource (buffer, offset, count);*/ new StreamSource(new MemoryStream(buffer, offset, count)); Initialize(dictionary, quota, session, onClose); }
public static XmlDictionaryReader CreateBinaryReader( byte [] buffer, int offset, int count, IXmlDictionary dictionary, XmlDictionaryReaderQuotas quotas, XmlBinaryReaderSession session, OnXmlDictionaryReaderClose onClose) { return(new XmlBinaryDictionaryReader(buffer, offset, count, dictionary, quotas, session, onClose)); }
public void SetInput(Stream stream, IXmlDictionary dictionary, XmlDictionaryReaderQuotas quotas, XmlBinaryReaderSession session, OnXmlDictionaryReaderClose onClose) { if (stream == null) throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(stream)); MoveToInitial(quotas, session, null); BufferReader.SetBuffer(stream, dictionary, session); _buffered = false; }
public XmlSimpleDictionaryReader (XmlReader reader, XmlDictionary dictionary, OnXmlDictionaryReaderClose onClose) { this.reader = reader; this.onClose = onClose; as_line_info = reader as IXmlLineInfo; as_dict_reader = reader as XmlDictionaryReader; if (dictionary == null) dictionary = new XmlDictionary (); dict = dictionary; }
public static XmlDictionaryReader CreateTextReader( Stream stream, Encoding encoding, XmlDictionaryReaderQuotas quotas, OnXmlDictionaryReaderClose onClose) { XmlReaderSettings s = new XmlReaderSettings(); XmlNameTable nt = new NameTable(); XmlParserContext c = new XmlParserContext(nt, new XmlNamespaceManager(nt), String.Empty, XmlSpace.None, encoding); XmlDictionaryReader res = new XmlSimpleDictionaryReader(XmlReader.Create(stream, s, c), null, onClose); res.quotas = quotas; return(res); }
/// <summary> /// Creates a <see cref="XmlDictionaryReader"/> for the specified <paramref name="stream"/> /// </summary> /// <param name="stream">A stream that holds the XML to be read.</param> /// <param name="ownStream">Specifies if the stream should be closed when the reader is closed.</param> /// <param name="encoding">The encoding of the text stored in <paramref name="stream" /></param> private static XmlDictionaryReader GetXmlReader(Stream stream, bool ownStream, Encoding encoding = null) { encoding = encoding ?? Encoding.UTF8; OnXmlDictionaryReaderClose onClose = ownStream ? (r => stream.Close()) : (OnXmlDictionaryReaderClose)null; return XmlDictionaryReader.CreateTextReader( stream, encoding, new XmlDictionaryReaderQuotas(), onClose); }
public XmlSimpleDictionaryReader(XmlReader reader, XmlDictionary dictionary, OnXmlDictionaryReaderClose onClose) { this.reader = reader; this.onClose = onClose; as_line_info = reader as IXmlLineInfo; as_dict_reader = reader as XmlDictionaryReader; if (dictionary == null) { dictionary = new XmlDictionary(); } dict = dictionary; }
public XmlMtomDictionaryReader ( Stream stream, Encoding [] encodings, string contentType, XmlDictionaryReaderQuotas quotas, int maxBufferSize, OnXmlDictionaryReaderClose onClose) { this.stream = stream; this.encodings = encodings; content_type = contentType != null ? CreateContentType (contentType) : null; this.quotas = quotas; this.max_buffer_size = maxBufferSize; on_close = onClose; Initialize (); }
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 BinaryMessageEncoderFactory(System.ServiceModel.Channels.MessageVersion messageVersion, int maxReadPoolSize, int maxWritePoolSize, int maxSessionSize, XmlDictionaryReaderQuotas readerQuotas, BinaryVersion version) { this.messageVersion = messageVersion; this.messageEncoder = new BinaryMessageEncoder(this, false, 0); this.maxReadPoolSize = maxReadPoolSize; this.maxWritePoolSize = maxWritePoolSize; this.maxSessionSize = maxSessionSize; this.thisLock = new object(); this.onStreamedReaderClose = new OnXmlDictionaryReaderClose(this.ReturnStreamedReader); this.readerQuotas = new XmlDictionaryReaderQuotas(); if (readerQuotas != null) { readerQuotas.CopyTo(this.readerQuotas); } this.binaryVersion = version; }
public XmlMtomDictionaryReader( Stream stream, Encoding [] encodings, string contentType, XmlDictionaryReaderQuotas quotas, int maxBufferSize, OnXmlDictionaryReaderClose onClose) { this.stream = stream; this.encodings = encodings; content_type = contentType != null?CreateContentType(contentType) : null; this.quotas = quotas; this.max_buffer_size = maxBufferSize; on_close = onClose; Initialize(); }
public void SetInput(Stream stream, Encoding encoding, XmlDictionaryReaderQuotas quotas, OnXmlDictionaryReaderClose onClose) { if (encoding != null) { reader = new PushbackReader(stream, encoding); } else { reader = new PushbackReader(stream); } if (quotas == null) { throw new ArgumentNullException("quotas"); } this.quotas = quotas; this.on_close = onClose; }
public TextMessageEncoder(MessageVersion version, Encoding writeEncoding, int maxReadPoolSize, int maxWritePoolSize, XmlDictionaryReaderQuotas quotas) { if (writeEncoding == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(writeEncoding)); } TextEncoderDefaults.ValidateEncoding(writeEncoding); _writeEncoding = writeEncoding; _optimizeWriteForUTF8 = IsUTF8Encoding(writeEncoding); ThisLock = new object(); _version = version ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(version)); MaxReadPoolSize = maxReadPoolSize; MaxWritePoolSize = maxWritePoolSize; ReaderQuotas = new XmlDictionaryReaderQuotas(); quotas.CopyTo(ReaderQuotas); _bufferedReadReaderQuotas = EncoderHelpers.GetBufferedReadQuotas(ReaderQuotas); _onStreamedReaderClose = new OnXmlDictionaryReaderClose(ReturnStreamedReader); _mediaType = GetMediaType(version); _contentType = GetContentType(_mediaType, writeEncoding); if (version.Envelope == EnvelopeVersion.Soap12) { _contentEncodingMap = Soap12Content; } else if (version.Envelope == EnvelopeVersion.Soap11) { _contentEncodingMap = Soap11Content; } else if (version.Envelope == EnvelopeVersion.None) { _contentEncodingMap = SoapNoneContent; } else { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException( SR.Format(SR.EnvelopeVersionNotSupported, version.Envelope))); } }
public void SetInput(byte[] buffer, int offset, int count, IXmlDictionary dictionary, XmlDictionaryReaderQuotas quotas, XmlBinaryReaderSession session, OnXmlDictionaryReaderClose onClose) { if (buffer == null) throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(buffer)); if (offset < 0) throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.Format(SR.ValueMustBeNonNegative))); if (offset > buffer.Length) throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.Format(SR.OffsetExceedsBufferSize, buffer.Length))); if (count < 0) throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.Format(SR.ValueMustBeNonNegative))); if (count > buffer.Length - offset) throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.Format(SR.SizeExceedsRemainingBufferSpace, buffer.Length - offset))); MoveToInitial(quotas, session, null); BufferReader.SetBuffer(buffer, offset, count, dictionary, session); _buffered = true; }
public override void Close() { base.Close(); OnXmlDictionaryReaderClose onClose = this.onClose; this.onClose = null; if (onClose != null) { try { onClose(this); } catch (Exception exception) { if (Fx.IsFatal(exception)) { throw; } throw DiagnosticUtility.ExceptionUtility.ThrowHelperCallback(exception); } } }
public BinaryMessageEncoderFactory(MessageVersion messageVersion, int maxReadPoolSize, int maxWritePoolSize, int maxSessionSize, XmlDictionaryReaderQuotas readerQuotas, long maxReceivedMessageSize, BinaryVersion version, CompressionFormat compressionFormat) { this.messageVersion = messageVersion; this.maxReadPoolSize = maxReadPoolSize; this.maxWritePoolSize = maxWritePoolSize; this.maxSessionSize = maxSessionSize; this.thisLock = new object(); this.onStreamedReaderClose = new OnXmlDictionaryReaderClose(ReturnStreamedReader); this.readerQuotas = new XmlDictionaryReaderQuotas(); if (readerQuotas != null) { readerQuotas.CopyTo(this.readerQuotas); } this.bufferedReadReaderQuotas = EncoderHelpers.GetBufferedReadQuotas(this.readerQuotas); this.MaxReceivedMessageSize = maxReceivedMessageSize; this.binaryVersion = version; this.compressionFormat = compressionFormat; this.messageEncoder = new BinaryMessageEncoder(this, false, 0); }
public override void Close() { this.rowOffsets = null; base.Close(); OnXmlDictionaryReaderClose onClose = this.onClose; this.onClose = null; if (onClose != null) { try { onClose(this); } catch (Exception exception) { if (Fx.IsFatal(exception)) { throw; } throw DiagnosticUtility.ExceptionUtility.ThrowHelperCallback(exception); } } }
public MtomMessageEncoderFactory(MessageVersion version, Encoding writeEncoding, int maxReadPoolSize, int maxWritePoolSize, int maxBufferSize, XmlDictionaryReaderQuotas quotas) { _messageVersion = version; _writeEncoding = writeEncoding; _maxReadPoolSize = maxReadPoolSize; _maxWritePoolSize = maxWritePoolSize; _maxBufferSize = maxBufferSize; _readerQuotas = quotas; _thisLock = new object(); _onStreamedReaderClose = new OnXmlDictionaryReaderClose(ReturnStreamedReader); if (version.Envelope == EnvelopeVersion.Soap12) { ContentEncodingMap = TextMessageEncoderFactory.Soap12Content; } else if (version.Envelope == EnvelopeVersion.Soap11) { ContentEncodingMap = TextMessageEncoderFactory.Soap11Content; } else { Fx.Assert("Invalid MessageVersion"); throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Invalid MessageVersion"))); } }
private void MoveToInitial(XmlDictionaryReaderQuotas quotas, OnXmlDictionaryReaderClose onClose) { MoveToInitial(quotas); _maxBytesPerRead = quotas.MaxBytesPerRead; _onClose = onClose; }
public void SetInput(Stream stream, Encoding encoding, XmlDictionaryReaderQuotas quotas, OnXmlDictionaryReaderClose onClose) { if (stream == null) throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("stream"); MoveToInitial(quotas, onClose); stream = new EncodingStreamWrapper(stream, encoding); BufferReader.SetBuffer(stream, null, null); _buffered = false; }
protected override void Dispose(bool disposing) { OnXmlDictionaryReaderClose onClose = _onReaderClose; _onReaderClose = null; ResetState(); if (onClose != null) { try { onClose(this); } catch (Exception e) { if (DiagnosticUtility.IsFatal(e)) { throw; } throw new Exception(SR.GenericCallbackException, e); } } base.Dispose(disposing); }
public static XmlDictionaryReader CreateJsonReader(byte[] buffer, int offset, int count, Encoding encoding, XmlDictionaryReaderQuotas quotas, OnXmlDictionaryReaderClose onClose) { XmlJsonReader reader = new XmlJsonReader(); reader.SetInput(buffer, offset, count, encoding, quotas, onClose); return(reader); }
public void SetInput(byte[] buffer, int offset, int count, Encoding encoding, XmlDictionaryReaderQuotas quotas, OnXmlDictionaryReaderClose onClose) { if (buffer == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("buffer"); } if (offset < 0) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( new ArgumentOutOfRangeException("offset", SR.GetString(SR.ValueMustBeNonNegative))); } if (offset > buffer.Length) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( new ArgumentOutOfRangeException("offset", SR.GetString(SR.JsonOffsetExceedsBufferSize, buffer.Length))); } if (count < 0) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( new ArgumentOutOfRangeException("count", SR.GetString(SR.ValueMustBeNonNegative))); } if (count > buffer.Length - offset) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( new ArgumentOutOfRangeException("count", SR.GetString(SR.JsonSizeExceedsRemainingBufferSpace, buffer.Length - offset))); } MoveToInitial(quotas, onClose); ArraySegment<byte> seg = JsonEncodingStreamWrapper.ProcessBuffer(buffer, offset, count, encoding); BufferReader.SetBuffer(seg.Array, seg.Offset, seg.Count, null, null); this.buffered = true; ResetState(); }
public BinaryBufferedMessageData(BinaryMessageEncoderFactory factory, int maxPoolSize) : base(factory.RecycledStatePool) { this.factory = factory; this.readerPool = new Pool <XmlDictionaryReader>(maxPoolSize); this.onClose = new OnXmlDictionaryReaderClose(this.OnXmlReaderClosed); }
private void MoveToInitial(XmlDictionaryReaderQuotas quotas, OnXmlDictionaryReaderClose onClose) { base.MoveToInitial(quotas); this.maxBytesPerRead = quotas.MaxBytesPerRead; this.onClose = onClose; }
private void Initialize (IXmlDictionary dictionary, XmlDictionaryReaderQuotas quotas, XmlBinaryReaderSession session, OnXmlDictionaryReaderClose onClose) { if (quotas == null) throw new ArgumentNullException ("quotas"); if (dictionary == null) dictionary = new XmlDictionary (); this.dictionary = dictionary; this.quota = quotas; if (session == null) session = new XmlBinaryReaderSession (); this.session = session; on_close = onClose; NameTable nt = new NameTable (); this.context = new XmlParserContext (nt, new XmlNamespaceManager (nt), null, XmlSpace.None); current = node = new NodeInfo (); current.Reset (); node_stack.Add (node); }
static public XmlDictionaryReader CreateMtomReader(byte[] buffer, int offset, int count, Encoding[] encodings, string contentType, XmlDictionaryReaderQuotas quotas, int maxBufferSize, OnXmlDictionaryReaderClose onClose) { XmlMtomReader reader = new XmlMtomReader(); reader.SetInput(buffer, offset, count, encodings, contentType, quotas, maxBufferSize, onClose); return reader; }
static public XmlDictionaryReader CreateMtomReader(Stream stream, Encoding[] encodings, string contentType, XmlDictionaryReaderQuotas quotas, int maxBufferSize, OnXmlDictionaryReaderClose onClose) { XmlMtomReader reader = new XmlMtomReader(); reader.SetInput(stream, encodings, contentType, quotas, maxBufferSize, onClose); return reader; }
static public XmlDictionaryReader CreateTextReader(Stream stream, Encoding encoding, XmlDictionaryReaderQuotas quotas, OnXmlDictionaryReaderClose onClose) { XmlUTF8TextReader reader = new XmlUTF8TextReader(); reader.SetInput(stream, encoding, quotas, onClose); return reader; }
static public XmlDictionaryReader CreateTextReader(byte[] buffer, int offset, int count, Encoding encoding, XmlDictionaryReaderQuotas quotas, OnXmlDictionaryReaderClose onClose) { XmlUTF8TextReader reader = new XmlUTF8TextReader(); reader.SetInput(buffer, offset, count, encoding, quotas, onClose); return reader; }
public void SetInput(Stream stream, Encoding encoding, XmlDictionaryReaderQuotas quotas, OnXmlDictionaryReaderClose onClose) { if (stream == null) { throw new ArgumentNullException(nameof(stream)); } MoveToInitial(quotas, onClose); stream = new JsonEncodingStreamWrapper(stream, encoding, true); BufferReader.SetBuffer(stream, null, null); _buffered = false; ResetState(); }
public void SetInput(byte[] buffer, int offset, int count, Encoding encoding, XmlDictionaryReaderQuotas quotas, OnXmlDictionaryReaderClose onClose) { if (buffer == null) { throw new ArgumentNullException(nameof(buffer)); } if (offset < 0) { throw new ArgumentOutOfRangeException(nameof(offset), SR.ValueMustBeNonNegative); } if (offset > buffer.Length) { throw new ArgumentOutOfRangeException(nameof(offset), SR.Format(SR.JsonOffsetExceedsBufferSize, buffer.Length)); } if (count < 0) { throw new ArgumentOutOfRangeException(nameof(count), SR.ValueMustBeNonNegative); } if (count > buffer.Length - offset) { throw new ArgumentOutOfRangeException(nameof(count), SR.Format(SR.JsonSizeExceedsRemainingBufferSpace, buffer.Length - offset)); } MoveToInitial(quotas, onClose); ArraySegment<byte> seg = JsonEncodingStreamWrapper.ProcessBuffer(buffer, offset, count, encoding); BufferReader.SetBuffer(seg.Array, seg.Offset, seg.Count, null, null); _buffered = true; ResetState(); }
public override void Close() { _rowOffsets = null; base.Close(); OnXmlDictionaryReaderClose onClose = _onClose; _onClose = null; if (onClose != null) { try { onClose(this); } catch (Exception e) { if (DiagnosticUtility.IsFatal(e)) throw; throw DiagnosticUtility.ExceptionUtility.ThrowHelperCallback(e); } } }
public UTF8BufferedMessageData(TextMessageEncoderFactory.TextMessageEncoder messageEncoder, int maxReaderPoolSize) : base(messageEncoder.RecycledStatePool) { this.messageEncoder = messageEncoder; this.readerPool = new Pool <XmlDictionaryReader>(maxReaderPoolSize); this.onClose = new OnXmlDictionaryReaderClose(this.OnXmlReaderClosed); }
public static XmlDictionaryReader CreateBinaryReader(Stream stream, IXmlDictionary dictionary, XmlDictionaryReaderQuotas quotas, XmlBinaryReaderSession session, OnXmlDictionaryReaderClose onClose) { XmlBinaryReader reader = new XmlBinaryReader(); reader.SetInput(stream, dictionary, quotas, session, onClose); return reader; }
public XmlBinaryDictionaryReader (Stream stream, IXmlDictionary dictionary, XmlDictionaryReaderQuotas quota, XmlBinaryReaderSession session, OnXmlDictionaryReaderClose onClose) { source = new StreamSource (stream); Initialize (dictionary, quota, session, onClose); }
public static XmlDictionaryReader CreateJsonReader (byte [] source, int offset, int length, Encoding encoding, XmlDictionaryReaderQuotas quotas, OnXmlDictionaryReaderClose readerClose) { return new JsonReader (source, offset, length, encoding, quotas, readerClose); }
void MoveToInitial(XmlDictionaryReaderQuotas quotas, OnXmlDictionaryReaderClose onClose) { MoveToInitial(quotas); this.maxBytesPerRead = quotas.MaxBytesPerRead; this.onReaderClose = onClose; }
public static XmlDictionaryReader CreateJsonReader (Stream source, Encoding encoding, XmlDictionaryReaderQuotas quotas, OnXmlDictionaryReaderClose readerClose) { return new JsonReader (source, encoding, quotas, readerClose); }
public void SetInput(Stream stream, Encoding encoding, XmlDictionaryReaderQuotas quotas, OnXmlDictionaryReaderClose onClose) { if (stream == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("stream"); } MoveToInitial(quotas, onClose); stream = new JsonEncodingStreamWrapper(stream, encoding, true); BufferReader.SetBuffer(stream, null, null); this.buffered = false; ResetState(); }
public void SetInput(Stream stream, Encoding encoding, XmlDictionaryReaderQuotas quotas, OnXmlDictionaryReaderClose onClose) { if (stream == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("stream"); } this.MoveToInitial(quotas, onClose); stream = new EncodingStreamWrapper(stream, encoding); base.BufferReader.SetBuffer(stream, null, null); this.buffered = false; }
public void SetInput(byte[] buffer, int offset, int count, Encoding encoding, XmlDictionaryReaderQuotas quotas, OnXmlDictionaryReaderClose onClose) { if (buffer == null) throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException(nameof(buffer))); if (offset < 0) throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.Format(SR.ValueMustBeNonNegative))); if (offset > buffer.Length) throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.Format(SR.OffsetExceedsBufferSize, buffer.Length))); if (count < 0) throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.Format(SR.ValueMustBeNonNegative))); if (count > buffer.Length - offset) throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.Format(SR.SizeExceedsRemainingBufferSpace, buffer.Length - offset))); MoveToInitial(quotas, onClose); ArraySegment<byte> seg = EncodingStreamWrapper.ProcessBuffer(buffer, offset, count, encoding); BufferReader.SetBuffer(seg.Array, seg.Offset, seg.Count, null, null); _buffered = true; }
public void SetInput(byte[] buffer, int offset, int count, Encoding encoding, XmlDictionaryReaderQuotas quotas, OnXmlDictionaryReaderClose onClose) { if (buffer == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("buffer")); } if (offset < 0) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("offset", System.Runtime.Serialization.SR.GetString("ValueMustBeNonNegative"))); } if (offset > buffer.Length) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("offset", System.Runtime.Serialization.SR.GetString("OffsetExceedsBufferSize", new object[] { buffer.Length }))); } if (count < 0) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("count", System.Runtime.Serialization.SR.GetString("ValueMustBeNonNegative"))); } if (count > (buffer.Length - offset)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("count", System.Runtime.Serialization.SR.GetString("SizeExceedsRemainingBufferSpace", new object[] { buffer.Length - offset }))); } this.MoveToInitial(quotas, onClose); ArraySegment <byte> segment = EncodingStreamWrapper.ProcessBuffer(buffer, offset, count, encoding); base.BufferReader.SetBuffer(segment.Array, segment.Offset, segment.Count, null, null); this.buffered = true; }