internal ODataBatchReader(ODataRawInputContext inputContext, string batchBoundary, Encoding batchEncoding, bool synchronous) { this.inputContext = inputContext; this.synchronous = synchronous; this.urlResolver = new ODataBatchUrlResolver(inputContext.UrlResolver); this.batchStream = new ODataBatchReaderStream(inputContext, batchBoundary, batchEncoding); }
internal ODataBatchReaderStream(ODataRawInputContext inputContext, string batchBoundary, Encoding batchEncoding) { this.inputContext = inputContext; this.batchBoundary = batchBoundary; this.batchEncoding = batchEncoding; this.batchBuffer = new ODataBatchReaderStreamBuffer(); this.lineBuffer = new byte[0x7d0]; }
/// <summary> /// Asynchronously creates an instance of the input context for the specified format. /// </summary> /// <param name="format">The format to create the context for.</param> /// <param name="readerPayloadKind">The <see cref="ODataPayloadKind"/> to read.</param> /// <param name="message">The message to use.</param> /// <param name="encoding">The encoding to use.</param> /// <param name="messageReaderSettings">Configuration settings of the OData reader.</param> /// <param name="version">The OData protocol version to be used for reading the payload.</param> /// <param name="readingResponse">true if reading a response message; otherwise false.</param> /// <param name="model">The model to use.</param> /// <param name="urlResolver">The optional URL resolver to perform custom URL resolution for URLs read from the payload.</param> /// <returns>Task which when completed returned the newly created input context.</returns> internal static Task <ODataInputContext> CreateInputContextAsync( ODataFormat format, ODataPayloadKind readerPayloadKind, ODataMessage message, Encoding encoding, ODataMessageReaderSettings messageReaderSettings, ODataVersion version, bool readingResponse, IEdmModel model, IODataUrlResolver urlResolver) { DebugUtils.CheckNoExternalCallers(); Debug.Assert(format != ODataFormat.Metadata, "Async reading of metadata documents is not supported."); Debug.Assert(readerPayloadKind != ODataPayloadKind.MetadataDocument, "Async reading of metadata documents is not supported."); if (format == ODataFormat.Atom) { return(ODataAtomInputContext.CreateAsync( format, message, encoding, messageReaderSettings, version, readingResponse, model, urlResolver)); } if (format == ODataFormat.VerboseJson) { return(ODataJsonInputContext.CreateAsync( format, message, encoding, messageReaderSettings, version, readingResponse, model, urlResolver)); } if (format == ODataFormat.Batch || format == ODataFormat.RawValue) { return(ODataRawInputContext.CreateAsync( format, message, encoding, messageReaderSettings, version, readingResponse, model, urlResolver, readerPayloadKind)); } throw new ODataException(Strings.General_InternalError(InternalErrorCodes.ODataInputContext_CreateInputContext_UnrecognizedFormat)); }
/// <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) { DebugUtils.CheckNoExternalCallers(); 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); }
internal static Task <ODataInputContext> CreateInputContextAsync(ODataFormat format, ODataPayloadKind readerPayloadKind, ODataMessage message, Encoding encoding, ODataMessageReaderSettings messageReaderSettings, ODataVersion version, bool readingResponse, IEdmModel model, IODataUrlResolver urlResolver) { if (format == ODataFormat.Atom) { return(ODataAtomInputContext.CreateAsync(format, message, encoding, messageReaderSettings, version, readingResponse, model, urlResolver)); } if (format == ODataFormat.VerboseJson) { return(ODataJsonInputContext.CreateAsync(format, message, encoding, messageReaderSettings, version, readingResponse, model, urlResolver)); } if ((format != ODataFormat.Batch) && (format != ODataFormat.RawValue)) { throw new ODataException(Microsoft.Data.OData.Strings.General_InternalError(InternalErrorCodes.ODataInputContext_CreateInputContext_UnrecognizedFormat)); } return(ODataRawInputContext.CreateAsync(format, message, encoding, messageReaderSettings, version, readingResponse, model, urlResolver, readerPayloadKind)); }
/// <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) { DebugUtils.CheckNoExternalCallers(); 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> /// Creates an instance of the input context for the specified format. /// </summary> /// <param name="format">The format to create the context for.</param> /// <param name="readerPayloadKind">The <see cref="ODataPayloadKind"/> to read.</param> /// <param name="message">The message to use.</param> /// <param name="encoding">The encoding to use.</param> /// <param name="messageReaderSettings">Configuration settings of the OData reader.</param> /// <param name="version">The OData protocol version to be used for reading the payload.</param> /// <param name="readingResponse">true if reading a response message; otherwise false.</param> /// <param name="model">The model to use.</param> /// <param name="urlResolver">The optional URL resolver to perform custom URL resolution for URLs read from the payload.</param> /// <returns>The newly created input context.</returns> internal static ODataInputContext CreateInputContext( ODataFormat format, ODataPayloadKind readerPayloadKind, ODataMessage message, Encoding encoding, ODataMessageReaderSettings messageReaderSettings, ODataVersion version, bool readingResponse, IEdmModel model, IODataUrlResolver urlResolver) { DebugUtils.CheckNoExternalCallers(); if (format == ODataFormat.Atom) { return(ODataAtomInputContext.Create( format, message, encoding, messageReaderSettings, version, readingResponse, model, urlResolver)); } if (format == ODataFormat.VerboseJson) { return(ODataJsonInputContext.Create( format, message, encoding, messageReaderSettings, version, readingResponse, model, urlResolver)); } if (format == ODataFormat.Metadata) { return(ODataMetadataInputContext.Create( format, message, encoding, messageReaderSettings, version, readingResponse, model, urlResolver)); } if (format == ODataFormat.Batch || format == ODataFormat.RawValue) { return(ODataRawInputContext.Create( format, message, encoding, messageReaderSettings, version, readingResponse, model, urlResolver, readerPayloadKind)); } throw new ODataException(Strings.General_InternalError(InternalErrorCodes.ODataInputContext_CreateInputContext_UnrecognizedFormat)); }