/// <summary> /// Constructor. /// </summary> /// <param name="inputContext">The input context to read the content from.</param> /// <param name="batchBoundary">The boundary string for the batch structure itself.</param> /// <param name="batchEncoding">The encoding to use to read from the batch stream.</param> /// <param name="synchronous">true if the reader is created for synchronous operation; false for asynchronous.</param> internal ODataBatchReader(ODataRawInputContext inputContext, string batchBoundary, Encoding batchEncoding, bool synchronous) { Debug.Assert(inputContext != null, "inputContext != null"); Debug.Assert(!string.IsNullOrEmpty(batchBoundary), "!string.IsNullOrEmpty(batchBoundary)"); this.inputContext = inputContext; this.synchronous = synchronous; this.urlResolver = new ODataBatchUrlResolver(inputContext.UrlResolver); this.batchStream = new ODataBatchReaderStream(inputContext, batchBoundary, batchEncoding); this.allowLegacyContentIdBehaviour = true; }
/// <summary> /// Constructor. /// </summary> /// <param name="rawInputContext">The input context to read the content from.</param> /// <param name="encoding">The encoding for the underlying stream.</param> internal ODataAsynchronousReader(ODataRawInputContext rawInputContext, Encoding encoding) { Debug.Assert(rawInputContext != null, "rawInputContext != null"); // Currently we only support single-byte UTF8 in async reader. if (encoding != null) { ReaderValidationUtils.ValidateEncodingSupportedInAsync(encoding); } this.rawInputContext = rawInputContext; }
/// <summary> /// Constructor. /// </summary> /// <param name="rawInputContext">The input context to read the content from.</param> /// <param name="encoding">The encoding for the underlying stream.</param> internal ODataAsynchronousReader(ODataRawInputContext rawInputContext, Encoding encoding) { Debug.Assert(rawInputContext != null, "rawInputContext != null"); // Currently we only support single-byte UTF8 in async reader. if (encoding != null) { ReaderValidationUtils.ValidateEncodingSupportedInAsync(encoding); } this.rawInputContext = rawInputContext; }
private static ODataBatchReaderStream CreateBatchReaderStream(string inputString) { var underlyingStream = new MemoryStream(Encoding.UTF8.GetBytes(inputString)); var inputContext = new ODataRawInputContext( ODataFormat.Batch, underlyingStream, Encoding.UTF8, new ODataMessageReaderSettings(), false, true, null, null, ODataPayloadKind.Batch); var batchStream = new ODataBatchReaderStream(inputContext, "batch_862fb28e-dc50-4af1-aad5-9608647761d1", Encoding.UTF8); return batchStream; }
/// <summary> /// Constructor. /// </summary> /// <param name="inputContext">The input context to read the content from.</param> /// <param name="batchBoundary">The boundary string for the batch structure itself.</param> /// <param name="batchEncoding">The encoding to use to read from the batch stream.</param> internal ODataBatchReaderStream( ODataRawInputContext inputContext, string batchBoundary, Encoding batchEncoding) { Debug.Assert(inputContext != null, "inputContext != null"); Debug.Assert(!string.IsNullOrEmpty(batchBoundary), "!string.IsNullOrEmpty(batchBoundary)"); this.inputContext = inputContext; this.batchBoundary = batchBoundary; this.batchEncoding = batchEncoding; this.batchBuffer = new ODataBatchReaderStreamBuffer(); // When we allocate a batch reader stream we will in almost all cases also call ReadLine // (to read the headers of the parts); so allocating it here. this.lineBuffer = new byte[LineBufferLength]; }
/// <summary> /// Constructor. /// </summary> /// <param name="inputContext">The input context to read the content from.</param> /// <param name="batchBoundary">The boundary string for the batch structure itself.</param> /// <param name="batchEncoding">The encoding to use to read from the batch stream.</param> internal ODataBatchReaderStream( ODataRawInputContext inputContext, string batchBoundary, Encoding batchEncoding) { Debug.Assert(inputContext != null, "inputContext != null"); Debug.Assert(!string.IsNullOrEmpty(batchBoundary), "!string.IsNullOrEmpty(batchBoundary)"); this.inputContext = inputContext; this.batchBoundary = batchBoundary; this.batchEncoding = batchEncoding; this.batchBuffer = new ODataBatchReaderStreamBuffer(); // When we allocate a batch reader stream we will in almost all cases also call ReadLine // (to read the headers of the parts); so allocating it here. this.lineBuffer = new byte[LineBufferLength]; }