/// <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) { DebugUtils.CheckNoExternalCallers(); 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 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)); }