/// <summary> /// Asynchronously ends an active changeset - implementation of the actual functionality. /// </summary> /// <returns>A task that represents the asynchronous write operation.</returns> protected override async Task WriteEndChangesetImplementationAsync() { // Write pending message data (headers, response line) for a previously unclosed message/request await this.WritePendingMessageDataAsync(true) .ConfigureAwait(false); string currentChangesetBoundary = this.changeSetBoundary; // Change the state first so we validate the change set boundary before attempting to write it. this.SetState(BatchWriterState.ChangesetCompleted); this.dependsOnIdsTracker.ChangeSetEnded(); Debug.Assert(this.changeSetBoundary != null, "this.changeSetBoundary != null"); this.changeSetBoundary = null; // In the case of an empty changeset the start changeset boundary has not been written yet // we will leave it like that, since we want the empty changeset to be represented only as // the end changeset boundary. // Due to WCF DS V2 compatibility we must not write the start boundary in this case // otherwise WCF DS V2 won't be able to read it (it fails on the start-end boundary empty changeset). // Write the end boundary for the change set await ODataMultipartMixedBatchWriterUtils.WriteEndBoundaryAsync( this.RawOutputContext.TextWriter, currentChangesetBoundary, !this.changesetStartBoundaryWritten).ConfigureAwait(false); }
/// <summary> /// Asynchronously ends a batch - implementation of the actual functionality. /// </summary> /// <returns>A task that represents the asynchronous write operation.</returns> protected override async Task WriteEndBatchImplementationAsync() { Debug.Assert( this.batchStartBoundaryWritten || this.CurrentOperationMessage == null, "If not batch boundary was written we must not have an active message."); // Write pending message data (headers, response line) for a previously unclosed message/request await this.WritePendingMessageDataAsync(true) .ConfigureAwait(false); this.SetState(BatchWriterState.BatchCompleted); // Write the end boundary for the batch await ODataMultipartMixedBatchWriterUtils.WriteEndBoundaryAsync( this.RawOutputContext.TextWriter, this.batchBoundary, !this.batchStartBoundaryWritten).ConfigureAwait(false); // For compatibility with WCF DS we write a newline after the end batch boundary. // Technically it's not needed, but it doesn't violate anything either. await this.RawOutputContext.TextWriter.WriteLineAsync() .ConfigureAwait(false); }