internal ODataBatchOperationMessage(Func<Stream> contentStreamCreatorFunc, ODataBatchOperationHeaders headers, IODataBatchOperationListener operationListener, IODataUrlResolver urlResolver, bool writing) : base(writing, false, -1L) { this.contentStreamCreatorFunc = contentStreamCreatorFunc; this.operationListener = operationListener; this.headers = headers; this.urlResolver = urlResolver; }
/// <summary> /// Constructor. /// </summary> /// <param name="listener">Listener interface to be notified of operation changes.</param> internal ODataBatchOperationStream(IODataBatchOperationListener listener) { DebugUtils.CheckNoExternalCallers(); Debug.Assert(listener != null, "listener != null"); this.listener = listener; }
/// <summary> /// Constructor. /// </summary> /// <param name="batchStream">The underlying stream to write the message to.</param> /// <param name="listener">Listener interface to be notified of operation changes.</param> internal ODataBatchOperationWriteStream(Stream batchStream, IODataBatchOperationListener listener) : base(listener) { DebugUtils.CheckNoExternalCallers(); Debug.Assert(batchStream != null, "batchStream != null"); this.batchStream = batchStream; }
/// <summary> /// Constructor. Creates a request message for an operation of a batch request. /// </summary> /// <param name="outputStream">The underlying stream to write the message to.</param> /// <param name="method">The HTTP method used for this request message.</param> /// <param name="requestUrl">The request Url for this request message.</param> /// <param name="operationListener">Listener interface to be notified of operation changes.</param> internal ODataBatchOperationRequestMessage(Stream outputStream, HttpMethod method, Uri requestUrl, IODataBatchOperationListener operationListener) { DebugUtils.CheckNoExternalCallers(); this.Method = method; this.Url = requestUrl; this.message = new ODataBatchOperationMessage(outputStream, operationListener); }
/// <summary> /// Constructor. Base class constructor to create a message for an operation of a batch request/response. /// </summary> /// <param name="outputStream">The stream to write the message to.</param> /// <param name="operationListener">Listener interface to be notified of part changes.</param> internal ODataBatchOperationMessage(Stream outputStream, IODataBatchOperationListener operationListener) { DebugUtils.CheckNoExternalCallers(); Debug.Assert(outputStream != null, "outputStream != null"); Debug.Assert(operationListener != null, "operationListener != null"); this.outputStream = outputStream; this.operationListener = operationListener; }
protected override void Dispose(bool disposing) { if (disposing && (this.listener != null)) { this.listener.BatchOperationContentStreamDisposed(); this.listener = null; } base.Dispose(disposing); }
/// <summary> /// Constructor. /// </summary> /// <param name="contentStreamCreatorFunc">A function to retrieve the content stream for this batch operation message.</param> /// <param name="headers">The headers of the batch operation message.</param> /// <param name="operationListener">Listener interface to be notified of part changes.</param> /// <param name="urlResolver">The optional URL resolver to perform custom URL resolution for URLs written to the payload.</param> /// <param name="writing">true if the request message is being written; false when it is read.</param> private ODataBatchOperationResponseMessage( Func<Stream> contentStreamCreatorFunc, ODataBatchOperationHeaders headers, IODataBatchOperationListener operationListener, IODataUrlResolver urlResolver, bool writing) { Debug.Assert(contentStreamCreatorFunc != null, "contentStreamCreatorFunc != null"); Debug.Assert(operationListener != null, "operationListener != null"); this.message = new ODataBatchOperationMessage(contentStreamCreatorFunc, headers, operationListener, urlResolver, writing); }
internal static ODataBatchOperationReadStream CreateBatchOperationReadStream(ODataBatchReaderStream batchReaderStream, ODataBatchOperationHeaders headers, IODataBatchOperationListener operationListener) { string str; if (!headers.TryGetValue("Content-Length", out str)) { return ODataBatchOperationReadStream.Create(batchReaderStream, operationListener); } int length = int.Parse(str, CultureInfo.InvariantCulture); if (length < 0) { throw new ODataException(Strings.ODataBatchReaderStream_InvalidContentLengthSpecified(str)); } return ODataBatchOperationReadStream.Create(batchReaderStream, operationListener, length); }
/// <summary> /// Disposes the object. /// </summary> /// <param name="disposing">True if called from Dispose; false if called form the finalizer.</param> protected override void Dispose(bool disposing) { if (disposing) { if (this.listener != null) { // Tell the listener that the stream is being disposed; we expect // that no asynchronous action is triggered by doing so. this.listener.BatchOperationContentStreamDisposed(); this.listener = null; } } base.Dispose(disposing); }
/// <summary> /// Constructor. /// </summary> /// <param name="contentStreamCreatorFunc">A function to retrieve the content stream for this batch operation message.</param> /// <param name="headers">The headers of the batch operation message.</param> /// <param name="operationListener">Listener interface to be notified of part changes.</param> /// <param name="contentId">The content-ID for the operation response message.</param> /// <param name="payloadUriConverter">The optional URL converter to perform custom URL conversion for URLs written to the payload.</param> /// <param name="writing">true if the request message is being written; false when it is read.</param> /// <param name="container">The dependency injection container to get related services.</param> private ODataBatchOperationResponseMessage( Func <Stream> contentStreamCreatorFunc, ODataBatchOperationHeaders headers, IODataBatchOperationListener operationListener, string contentId, IODataPayloadUriConverter payloadUriConverter, bool writing, IServiceProvider container) { Debug.Assert(contentStreamCreatorFunc != null, "contentStreamCreatorFunc != null"); Debug.Assert(operationListener != null, "operationListener != null"); this.message = new ODataBatchOperationMessage(contentStreamCreatorFunc, headers, operationListener, payloadUriConverter, writing); this.ContentId = contentId; this.Container = container; }
/// <summary> /// Constructor. Base class constructor to create a message for an operation of a batch request/response. /// </summary> /// <param name="contentStreamCreatorFunc">A function to retrieve the content stream for this batch operation message.</param> /// <param name="headers">The headers of the batch operation message.</param> /// <param name="operationListener">Listener interface to be notified of part changes.</param> /// <param name="payloadUriConverter">The URL resolver to perform custom URL resolution for URLs read or written from/to the payload.</param> /// <param name="writing">true if the request message is being written; false when it is read.</param> internal ODataBatchOperationMessage( Func <Stream> contentStreamCreatorFunc, ODataBatchOperationHeaders headers, IODataBatchOperationListener operationListener, IODataPayloadUriConverter payloadUriConverter, bool writing) : base(writing, /*disableMessageStreamDisposal*/ false, /*maxMessageSize*/ -1) { Debug.Assert(contentStreamCreatorFunc != null, "contentStreamCreatorFunc != null"); Debug.Assert(operationListener != null, "operationListener != null"); this.contentStreamCreatorFunc = contentStreamCreatorFunc; this.operationListener = operationListener; this.headers = headers; this.payloadUriConverter = payloadUriConverter; }
/// <summary> /// Creates an operation request message that can be used to read the operation content from. /// </summary> /// <param name="batchReaderStream">The batch stream underyling the operation response message.</param> /// <param name="method">The HTTP method to use for the message to create.</param> /// <param name="requestUrl">The request URL for the message to create.</param> /// <param name="headers">The headers to use for the operation request message.</param> /// <param name="operationListener">The operation listener.</param> /// <param name="contentId">The content-ID for the operation request message.</param> /// <param name="urlResolver">The (optional) URL resolver for the message to create.</param> /// <returns>An <see cref="ODataBatchOperationRequestMessage"/> to read the request content from.</returns> internal static ODataBatchOperationRequestMessage CreateReadMessage( ODataBatchReaderStream batchReaderStream, string method, Uri requestUrl, ODataBatchOperationHeaders headers, IODataBatchOperationListener operationListener, string contentId, IODataUrlResolver urlResolver) { Debug.Assert(batchReaderStream != null, "batchReaderStream != null"); Debug.Assert(operationListener != null, "operationListener != null"); Func <Stream> streamCreatorFunc = () => ODataBatchUtils.CreateBatchOperationReadStream(batchReaderStream, headers, operationListener); return(new ODataBatchOperationRequestMessage(streamCreatorFunc, method, requestUrl, headers, operationListener, contentId, urlResolver, /*writing*/ false)); }
/// <summary> /// Constructor. Base class constructor to create a message for an operation of a batch request/response. /// </summary> /// <param name="contentStreamCreatorFunc">A function to retrieve the content stream for this batch operation message.</param> /// <param name="headers">The headers of the batch operation message.</param> /// <param name="operationListener">Listener interface to be notified of part changes.</param> /// <param name="urlResolver">The URL resolver to perform custom URL resolution for URLs read or written from/to the payload.</param> /// <param name="writing">true if the request message is being written; false when it is read.</param> internal ODataBatchOperationMessage( Func<Stream> contentStreamCreatorFunc, ODataBatchOperationHeaders headers, IODataBatchOperationListener operationListener, IODataUrlResolver urlResolver, bool writing) : base(writing, /*disableMessageStreamDisposal*/ false, /*maxMessageSize*/ -1) { DebugUtils.CheckNoExternalCallers(); Debug.Assert(contentStreamCreatorFunc != null, "contentStreamCreatorFunc != null"); Debug.Assert(operationListener != null, "operationListener != null"); this.contentStreamCreatorFunc = contentStreamCreatorFunc; this.operationListener = operationListener; this.headers = headers; this.urlResolver = urlResolver; }
/// <summary> /// Constructor. Base class constructor to create a message for an operation of a batch request/response. /// </summary> /// <param name="contentStreamCreatorFunc">A function to retrieve the content stream for this batch operation message.</param> /// <param name="headers">The headers of the batch operation message.</param> /// <param name="operationListener">Listener interface to be notified of part changes.</param> /// <param name="urlResolver">The URL resolver to perform custom URL resolution for URLs read or written from/to the payload.</param> /// <param name="writing">true if the request message is being written; false when it is read.</param> internal ODataBatchOperationMessage( Func <Stream> contentStreamCreatorFunc, ODataBatchOperationHeaders headers, IODataBatchOperationListener operationListener, IODataUrlResolver urlResolver, bool writing) : base(writing, /*disableMessageStreamDisposal*/ false, /*maxMessageSize*/ -1) { DebugUtils.CheckNoExternalCallers(); Debug.Assert(contentStreamCreatorFunc != null, "contentStreamCreatorFunc != null"); Debug.Assert(operationListener != null, "operationListener != null"); this.contentStreamCreatorFunc = contentStreamCreatorFunc; this.operationListener = operationListener; this.headers = headers; this.urlResolver = urlResolver; }
/// <summary> /// Creates an operation response message that can be used to read the operation content from. /// </summary> /// <param name="batchReaderStream">The batch stream underyling the operation response message.</param> /// <param name="statusCode">The status code to use for the operation response message.</param> /// <param name="headers">The headers to use for the operation response message.</param> /// <param name="contentId">The content-ID for the operation response message.</param> /// <param name="operationListener">The operation listener.</param> /// <param name="urlResolver">The (optional) URL resolver for the message to create.</param> /// <returns>An <see cref="ODataBatchOperationResponseMessage"/> that can be used to read the operation content.</returns> internal static ODataBatchOperationResponseMessage CreateReadMessage( ODataBatchReaderStream batchReaderStream, int statusCode, ODataBatchOperationHeaders headers, string contentId, IODataBatchOperationListener operationListener, IODataUrlResolver urlResolver) { Debug.Assert(batchReaderStream != null, "batchReaderStream != null"); Debug.Assert(operationListener != null, "operationListener != null"); Func <Stream> streamCreatorFunc = () => ODataBatchUtils.CreateBatchOperationReadStream(batchReaderStream, headers, operationListener); ODataBatchOperationResponseMessage responseMessage = new ODataBatchOperationResponseMessage(streamCreatorFunc, headers, operationListener, contentId, urlResolver, /*writing*/ false); responseMessage.statusCode = statusCode; return(responseMessage); }
/// <summary> /// Constructor. Creates a request message for an operation of a batch request. /// </summary> /// <param name="contentStreamCreatorFunc">A function to create the content stream.</param> /// <param name="method">The HTTP method used for this request message.</param> /// <param name="requestUrl">The request Url for this request message.</param> /// <param name="headers">The headers for the this request message.</param> /// <param name="operationListener">Listener interface to be notified of operation changes.</param> /// <param name="urlResolver">The optional URL resolver to perform custom URL resolution for URLs written to the payload.</param> /// <param name="writing">true if the request message is being written; false when it is read.</param> private ODataBatchOperationRequestMessage( Func <Stream> contentStreamCreatorFunc, string method, Uri requestUrl, ODataBatchOperationHeaders headers, IODataBatchOperationListener operationListener, IODataUrlResolver urlResolver, bool writing) { Debug.Assert(contentStreamCreatorFunc != null, "contentStreamCreatorFunc != null"); Debug.Assert(operationListener != null, "operationListener != null"); Debug.Assert(urlResolver != null, "urlResolver != null"); this.Method = method; this.Url = requestUrl; this.message = new ODataBatchOperationMessage(contentStreamCreatorFunc, headers, operationListener, urlResolver, writing); }
/// <summary> /// Constructor. Creates a request message for an operation of a batch request. /// </summary> /// <param name="contentStreamCreatorFunc">A function to create the content stream.</param> /// <param name="method">The HTTP method used for this request message.</param> /// <param name="requestUrl">The request Url for this request message.</param> /// <param name="headers">The headers for the this request message.</param> /// <param name="operationListener">Listener interface to be notified of operation changes.</param> /// <param name="urlResolver">The optional URL resolver to perform custom URL resolution for URLs written to the payload.</param> /// <param name="writing">true if the request message is being written; false when it is read.</param> private ODataBatchOperationRequestMessage( Func<Stream> contentStreamCreatorFunc, string method, Uri requestUrl, ODataBatchOperationHeaders headers, IODataBatchOperationListener operationListener, IODataUrlResolver urlResolver, bool writing) { Debug.Assert(contentStreamCreatorFunc != null, "contentStreamCreatorFunc != null"); Debug.Assert(operationListener != null, "operationListener != null"); Debug.Assert(urlResolver != null, "urlResolver != null"); this.Method = method; this.Url = requestUrl; this.message = new ODataBatchOperationMessage(contentStreamCreatorFunc, headers, operationListener, urlResolver, writing); }
/// <summary> /// Creates a batch operation stream from the specified batch stream. /// </summary> /// <param name="batchReaderStream">The batch stream to create the operation read stream for.</param> /// <param name="headers">The headers of the current part; based on the header we create different, optimized stream implementations.</param> /// <param name="operationListener">The operation listener to be passed to the newly created read stream.</param> /// <returns>A new <see cref="ODataBatchOperationReadStream"/> instance.</returns> internal static ODataBatchOperationReadStream CreateBatchOperationReadStream( ODataBatchReaderStream batchReaderStream, ODataBatchOperationHeaders headers, IODataBatchOperationListener operationListener) { Debug.Assert(batchReaderStream != null, "batchReaderStream != null"); Debug.Assert(operationListener != null, "operationListener != null"); // See whether we have a Content-Length header string contentLengthValue; if (headers.TryGetValue(ODataConstants.ContentLengthHeader, out contentLengthValue)) { int length = Int32.Parse(contentLengthValue, CultureInfo.InvariantCulture); if (length < 0) { throw new ODataException(Strings.ODataBatchReaderStream_InvalidContentLengthSpecified(contentLengthValue)); } return ODataBatchOperationReadStream.Create(batchReaderStream, operationListener, length); } return ODataBatchOperationReadStream.Create(batchReaderStream, operationListener); }
/// <summary> /// Creates a batch operation stream from the specified batch stream. /// </summary> /// <param name="batchReaderStream">The batch stream to create the operation read stream for.</param> /// <param name="headers">The headers of the current part; based on the header we create different, optimized stream implementations.</param> /// <param name="operationListener">The operation listener to be passed to the newly created read stream.</param> /// <returns>A new <see cref="ODataBatchOperationReadStream"/> instance.</returns> internal static ODataBatchOperationReadStream CreateBatchOperationReadStream( ODataBatchReaderStream batchReaderStream, ODataBatchOperationHeaders headers, IODataBatchOperationListener operationListener) { Debug.Assert(batchReaderStream != null, "batchReaderStream != null"); Debug.Assert(operationListener != null, "operationListener != null"); // See whether we have a Content-Length header string contentLengthValue; if (headers.TryGetValue(ODataConstants.ContentLengthHeader, out contentLengthValue)) { int length = Int32.Parse(contentLengthValue, CultureInfo.InvariantCulture); if (length < 0) { throw new ODataException(Strings.ODataBatchReaderStream_InvalidContentLengthSpecified(contentLengthValue)); } return(ODataBatchOperationReadStream.Create(batchReaderStream, operationListener, length)); } return(ODataBatchOperationReadStream.Create(batchReaderStream, operationListener)); }
internal ODataBatchOperationWriteStream(Stream batchStream, IODataBatchOperationListener listener) : base(listener) { this.batchStream = batchStream; }
/// <summary> /// Constructor. /// </summary> /// <param name="batchStream">The underlying stream to write the message to.</param> /// <param name="listener">Listener interface to be notified of operation changes.</param> internal ODataBatchOperationWriteStream(Stream batchStream, IODataBatchOperationListener listener) : base(listener) { Debug.Assert(batchStream != null, "batchStream != null"); this.batchStream = batchStream; }
/// <summary> /// Constructor. Creates a request message for an operation of a batch response. /// </summary> /// <param name="outputStream">The underlying stream to write the message to.</param> /// <param name="operationListener">Listener interface to be notified of operation changes.</param> internal ODataBatchOperationResponseMessage(Stream outputStream, IODataBatchOperationListener operationListener) { DebugUtils.CheckNoExternalCallers(); this.message = new ODataBatchOperationMessage(outputStream, operationListener); }
internal static ODataBatchOperationResponseMessage CreateReadMessage(ODataBatchReaderStream batchReaderStream, int statusCode, ODataBatchOperationHeaders headers, IODataBatchOperationListener operationListener, IODataUrlResolver urlResolver) { return(new ODataBatchOperationResponseMessage(() => ODataBatchUtils.CreateBatchOperationReadStream(batchReaderStream, headers, operationListener), headers, operationListener, urlResolver, false) { statusCode = statusCode }); }
/// <summary> /// Create a batch operation read stream over the specified batch stream using the batch delimiter to detect the end of the stream. /// </summary> /// <param name="batchReaderStream">The batch stream underlying the operation stream to create.</param> /// <param name="listener">The batch operation listener.</param> /// <returns>A <see cref="ODataBatchOperationReadStream"/> to read the content of a batch operation from.</returns> internal static ODataBatchOperationReadStream Create(ODataBatchReaderStream batchReaderStream, IODataBatchOperationListener listener) { return(new ODataBatchOperationReadStreamWithDelimiter(batchReaderStream, listener)); }
/// <summary> /// Constructor. /// </summary> /// <param name="batchReaderStream">The underlying batch stream to write the message to.</param> /// <param name="listener">Listener interface to be notified of operation changes.</param> internal ODataBatchOperationReadStreamWithDelimiter(ODataBatchReaderStream batchReaderStream, IODataBatchOperationListener listener) : base(batchReaderStream, listener) { }
/// <summary> /// Create a batch operation read stream over the specified batch stream with a given content length. /// </summary> /// <param name="batchReaderStream">The batch stream underlying the operation stream to create.</param> /// <param name="listener">The batch operation listener.</param> /// <param name="length">The content length of the operation stream.</param> /// <returns>A <see cref="ODataBatchOperationReadStream"/> to read the content of a batch operation from.</returns> internal static ODataBatchOperationReadStream Create(ODataBatchReaderStream batchReaderStream, IODataBatchOperationListener listener, int length) { return new ODataBatchOperationReadStreamWithLength(batchReaderStream, listener, length); }
/// <summary> /// Constructor. /// </summary> /// <param name="batchReaderStream">The underlying stream to read from.</param> /// <param name="listener">Listener interface to be notified of operation changes.</param> internal ODataBatchOperationReadStream(ODataBatchReaderStream batchReaderStream, IODataBatchOperationListener listener) : base(listener) { DebugUtils.CheckNoExternalCallers(); Debug.Assert(batchReaderStream != null, "batchReaderStream != null"); this.batchReaderStream = batchReaderStream; }
internal static ODataBatchOperationWriteStream CreateBatchOperationWriteStream(Stream outputStream, IODataBatchOperationListener operationListener) { return new ODataBatchOperationWriteStream(outputStream, operationListener); }
/// <summary> /// Create a batch operation read stream over the specified batch stream with a given content length. /// </summary> /// <param name="batchReaderStream">The batch stream underlying the operation stream to create.</param> /// <param name="listener">The batch operation listener.</param> /// <param name="length">The content length of the operation stream.</param> /// <returns>A <see cref="ODataBatchOperationReadStream"/> to read the content of a batch operation from.</returns> internal static ODataBatchOperationReadStream Create(ODataBatchReaderStream batchReaderStream, IODataBatchOperationListener listener, int length) { DebugUtils.CheckNoExternalCallers(); return new ODataBatchOperationReadStreamWithLength(batchReaderStream, listener, length); }
/// <summary> /// Create a batch operation read stream over the specified batch stream using the batch delimiter to detect the end of the stream. /// </summary> /// <param name="batchReaderStream">The batch stream underlying the operation stream to create.</param> /// <param name="listener">The batch operation listener.</param> /// <returns>A <see cref="ODataBatchOperationReadStream"/> to read the content of a batch operation from.</returns> internal static ODataBatchOperationReadStream Create(ODataBatchReaderStream batchReaderStream, IODataBatchOperationListener listener) { DebugUtils.CheckNoExternalCallers(); return new ODataBatchOperationReadStreamWithDelimiter(batchReaderStream, listener); }
/// <summary> /// Creates a batch operation write stream over the specified output stream. /// </summary> /// <param name="outputStream">The output stream to create the operation write stream over.</param> /// <param name="operationListener">The operation listener to be passed to the newly created write stream.</param> /// <returns>A new <see cref="ODataBatchOperationWriteStream"/> instance.</returns> internal static ODataBatchOperationWriteStream CreateBatchOperationWriteStream( Stream outputStream, IODataBatchOperationListener operationListener) { Debug.Assert(outputStream != null, "outputStream != null"); Debug.Assert(operationListener != null, "operationListener != null"); return new ODataBatchOperationWriteStream(outputStream, operationListener); }
internal ODataBatchOperationStream(IODataBatchOperationListener listener) { this.listener = listener; }
/// <summary> /// Create a batch operation read stream over the specified batch stream using the batch delimiter to detect the end of the stream. /// </summary> /// <param name="batchReaderStream">The batch stream underlying the operation stream to create.</param> /// <param name="listener">The batch operation listener.</param> /// <returns>A <see cref="ODataBatchOperationReadStream"/> to read the content of a batch operation from.</returns> internal static ODataBatchOperationReadStream Create(ODataBatchReaderStream batchReaderStream, IODataBatchOperationListener listener) { return new ODataBatchOperationReadStreamWithDelimiter(batchReaderStream, listener); }
internal ODataBatchOperationMessage(Func <Stream> contentStreamCreatorFunc, ODataBatchOperationHeaders headers, IODataBatchOperationListener operationListener, IODataUrlResolver urlResolver, bool writing) : base(writing, false, -1L) { this.contentStreamCreatorFunc = contentStreamCreatorFunc; this.operationListener = operationListener; this.headers = headers; this.urlResolver = urlResolver; }
/// <summary> /// Creates an operation request message that can be used to write the operation content to. /// </summary> /// <param name="outputStream">The output stream underlying the operation message.</param> /// <param name="method">The HTTP method to use for the message to create.</param> /// <param name="requestUrl">The request URL for the message to create.</param> /// <param name="operationListener">The operation listener.</param> /// <param name="urlResolver">The (optional) URL resolver for the message to create.</param> /// <returns>An <see cref="ODataBatchOperationRequestMessage"/> to write the request content to.</returns> internal static ODataBatchOperationRequestMessage CreateWriteMessage( Stream outputStream, string method, Uri requestUrl, IODataBatchOperationListener operationListener, IODataUrlResolver urlResolver) { DebugUtils.CheckNoExternalCallers(); Debug.Assert(outputStream != null, "outputStream != null"); Debug.Assert(operationListener != null, "operationListener != null"); Func<Stream> streamCreatorFunc = () => ODataBatchUtils.CreateBatchOperationWriteStream(outputStream, operationListener); return new ODataBatchOperationRequestMessage(streamCreatorFunc, method, requestUrl, /*headers*/ null, operationListener, urlResolver, /*writing*/ true); }
/// <summary> /// Create a batch operation read stream over the specified batch stream with a given content length. /// </summary> /// <param name="batchReaderStream">The batch stream underlying the operation stream to create.</param> /// <param name="listener">The batch operation listener.</param> /// <param name="length">The content length of the operation stream.</param> /// <returns>A <see cref="ODataBatchOperationReadStream"/> to read the content of a batch operation from.</returns> internal static ODataBatchOperationReadStream Create(ODataBatchReaderStream batchReaderStream, IODataBatchOperationListener listener, int length) { return(new ODataBatchOperationReadStreamWithLength(batchReaderStream, listener, length)); }
internal ODataBatchOperationReadStream(ODataBatchReaderStream batchReaderStream, IODataBatchOperationListener listener) : base(listener) { this.batchReaderStream = batchReaderStream; }
/// <summary> /// Constructor. /// </summary> /// <param name="batchReaderStream">The underlying batch stream to write the message to.</param> /// <param name="listener">Listener interface to be notified of operation changes.</param> /// <param name="length">The total length of the stream.</param> internal ODataBatchOperationReadStreamWithLength(ODataBatchReaderStream batchReaderStream, IODataBatchOperationListener listener, int length) : base(batchReaderStream, listener) { ExceptionUtils.CheckIntegerNotNegative(length, "length"); this.length = length; }
internal static ODataBatchOperationReadStream CreateBatchOperationReadStream(ODataBatchReaderStream batchReaderStream, ODataBatchOperationHeaders headers, IODataBatchOperationListener operationListener) { string str; if (!headers.TryGetValue("Content-Length", out str)) { return(ODataBatchOperationReadStream.Create(batchReaderStream, operationListener)); } int length = int.Parse(str, CultureInfo.InvariantCulture); if (length < 0) { throw new ODataException(Strings.ODataBatchReaderStream_InvalidContentLengthSpecified(str)); } return(ODataBatchOperationReadStream.Create(batchReaderStream, operationListener, length)); }
/// <summary> /// Constructor. /// </summary> /// <param name="batchReaderStream">The underlying stream to read from.</param> /// <param name="listener">Listener interface to be notified of operation changes.</param> internal ODataBatchOperationReadStream(ODataBatchReaderStream batchReaderStream, IODataBatchOperationListener listener) : base(listener) { Debug.Assert(batchReaderStream != null, "batchReaderStream != null"); this.batchReaderStream = batchReaderStream; }
/// <summary> /// Constructor. /// </summary> /// <param name="listener">Listener interface to be notified of operation changes.</param> internal ODataBatchOperationStream(IODataBatchOperationListener listener) { Debug.Assert(listener != null, "listener != null"); this.listener = listener; }
internal static ODataBatchOperationWriteStream CreateBatchOperationWriteStream(Stream outputStream, IODataBatchOperationListener operationListener) { return(new ODataBatchOperationWriteStream(outputStream, operationListener)); }
/// <summary> /// Creates an operation request message that can be used to read the operation content from. /// </summary> /// <param name="batchReaderStream">The batch stream underyling the operation response message.</param> /// <param name="method">The HTTP method to use for the message to create.</param> /// <param name="requestUrl">The request URL for the message to create.</param> /// <param name="headers">The headers to use for the operation request message.</param> /// <param name="operationListener">The operation listener.</param> /// <param name="urlResolver">The (optional) URL resolver for the message to create.</param> /// <returns>An <see cref="ODataBatchOperationRequestMessage"/> to read the request content from.</returns> internal static ODataBatchOperationRequestMessage CreateReadMessage( ODataBatchReaderStream batchReaderStream, string method, Uri requestUrl, ODataBatchOperationHeaders headers, IODataBatchOperationListener operationListener, IODataUrlResolver urlResolver) { DebugUtils.CheckNoExternalCallers(); Debug.Assert(batchReaderStream != null, "batchReaderStream != null"); Debug.Assert(operationListener != null, "operationListener != null"); Func<Stream> streamCreatorFunc = () => ODataBatchUtils.CreateBatchOperationReadStream(batchReaderStream, headers, operationListener); return new ODataBatchOperationRequestMessage(streamCreatorFunc, method, requestUrl, headers, operationListener, urlResolver, /*writing*/ false); }
internal static ODataBatchOperationRequestMessage CreateWriteMessage(Stream outputStream, string method, Uri requestUrl, IODataBatchOperationListener operationListener, IODataUrlResolver urlResolver) { return(new ODataBatchOperationRequestMessage(() => ODataBatchUtils.CreateBatchOperationWriteStream(outputStream, operationListener), method, requestUrl, null, operationListener, urlResolver, true)); }
/// <summary> /// Creates an operation response message that can be used to write the operation content to. /// </summary> /// <param name="outputStream">The output stream underlying the operation message.</param> /// <param name="operationListener">The operation listener.</param> /// <param name="urlResolver">The (optional) URL resolver for the message to create.</param> /// <returns>An <see cref="ODataBatchOperationResponseMessage"/> that can be used to write the operation content.</returns> internal static ODataBatchOperationResponseMessage CreateWriteMessage( Stream outputStream, IODataBatchOperationListener operationListener, IODataUrlResolver urlResolver) { Func<Stream> streamCreatorFunc = () => ODataBatchUtils.CreateBatchOperationWriteStream(outputStream, operationListener); return new ODataBatchOperationResponseMessage(streamCreatorFunc, /*headers*/ null, operationListener, /*contentId*/ null, urlResolver, /*writing*/ true); }
private ODataBatchOperationResponseMessage(Func <Stream> contentStreamCreatorFunc, ODataBatchOperationHeaders headers, IODataBatchOperationListener operationListener, IODataUrlResolver urlResolver, bool writing) { this.message = new ODataBatchOperationMessage(contentStreamCreatorFunc, headers, operationListener, urlResolver, writing); }
/// <summary> /// Creates an operation response message that can be used to read the operation content from. /// </summary> /// <param name="batchReaderStream">The batch stream underyling the operation response message.</param> /// <param name="statusCode">The status code to use for the operation response message.</param> /// <param name="headers">The headers to use for the operation response message.</param> /// <param name="contentId">The content-ID for the operation response message.</param> /// <param name="operationListener">The operation listener.</param> /// <param name="urlResolver">The (optional) URL resolver for the message to create.</param> /// <returns>An <see cref="ODataBatchOperationResponseMessage"/> that can be used to read the operation content.</returns> internal static ODataBatchOperationResponseMessage CreateReadMessage( ODataBatchReaderStream batchReaderStream, int statusCode, ODataBatchOperationHeaders headers, string contentId, IODataBatchOperationListener operationListener, IODataUrlResolver urlResolver) { Debug.Assert(batchReaderStream != null, "batchReaderStream != null"); Debug.Assert(operationListener != null, "operationListener != null"); Func<Stream> streamCreatorFunc = () => ODataBatchUtils.CreateBatchOperationReadStream(batchReaderStream, headers, operationListener); ODataBatchOperationResponseMessage responseMessage = new ODataBatchOperationResponseMessage(streamCreatorFunc, headers, operationListener, contentId, urlResolver, /*writing*/ false); responseMessage.statusCode = statusCode; return responseMessage; }
internal static ODataBatchOperationResponseMessage CreateWriteMessage(Stream outputStream, IODataBatchOperationListener operationListener, IODataUrlResolver urlResolver) { return(new ODataBatchOperationResponseMessage(() => ODataBatchUtils.CreateBatchOperationWriteStream(outputStream, operationListener), null, operationListener, urlResolver, true)); }
/// <summary> /// Create a batch operation read stream over the specified batch stream with a given content length. /// </summary> /// <param name="batchReaderStream">The batch stream underlying the operation stream to create.</param> /// <param name="listener">The batch operation listener.</param> /// <param name="length">The content length of the operation stream.</param> /// <returns>A <see cref="ODataBatchOperationReadStream"/> to read the content of a batch operation from.</returns> internal static ODataBatchOperationReadStream Create(ODataBatchReaderStream batchReaderStream, IODataBatchOperationListener listener, int length) { DebugUtils.CheckNoExternalCallers(); return(new ODataBatchOperationReadStreamWithLength(batchReaderStream, listener, length)); }
/// <summary> /// Constructor using default encoding (Base64Url without the BOM preamble). /// </summary> /// <param name="listener">The batch operation listener.</param> internal ODataJsonLightBatchBodyContentReaderStream(IODataBatchOperationListener listener) { this.listener = listener; }
/// <summary> /// Create a batch operation read stream over the specified batch stream using the batch delimiter to detect the end of the stream. /// </summary> /// <param name="batchReaderStream">The batch stream underlying the operation stream to create.</param> /// <param name="listener">The batch operation listener.</param> /// <returns>A <see cref="ODataBatchOperationReadStream"/> to read the content of a batch operation from.</returns> internal static ODataBatchOperationReadStream Create(ODataBatchReaderStream batchReaderStream, IODataBatchOperationListener listener) { DebugUtils.CheckNoExternalCallers(); return(new ODataBatchOperationReadStreamWithDelimiter(batchReaderStream, listener)); }