Esempio n. 1
0
        private void EnsureODataFormatAndContentType()
        {
            string header = null;

            if (!this.settings.UseFormat.HasValue)
            {
                header = this.message.GetHeader("Content-Type");
                header = (header == null) ? null : header.Trim();
            }
            if (!string.IsNullOrEmpty(header))
            {
                ODataPayloadKind kind;
                MediaType        type;
                this.format = MediaTypeUtils.GetFormatFromContentType(header, new ODataPayloadKind[] { this.writerPayloadKind }, MediaTypeResolver.DefaultMediaTypeResolver, out type, out this.encoding, out kind, out this.batchBoundary);
            }
            else
            {
                MediaType type2;
                this.format = MediaTypeUtils.GetContentTypeFromSettings(this.settings, this.writerPayloadKind, MediaTypeResolver.DefaultMediaTypeResolver, out type2, out this.encoding);
                if (this.writerPayloadKind == ODataPayloadKind.Batch)
                {
                    this.batchBoundary = ODataBatchWriterUtils.CreateBatchBoundary(this.writingResponse);
                    header             = ODataBatchWriterUtils.CreateMultipartMixedContentType(this.batchBoundary);
                }
                else
                {
                    this.batchBoundary = null;
                    header             = HttpUtils.BuildContentType(type2, this.encoding);
                }
                this.message.SetHeader("Content-Type", header);
            }
        }
Esempio n. 2
0
 private void WriteEndBatchImplementation()
 {
     this.WritePendingMessageData(true);
     this.SetState(BatchWriterState.BatchCompleted);
     ODataBatchWriterUtils.WriteEndBoundary(this.rawOutputContext.TextWriter, this.batchBoundary, !this.batchStartBoundaryWritten);
     this.rawOutputContext.TextWriter.WriteLine();
 }
Esempio n. 3
0
 private ODataBatchOperationResponseMessage CreateOperationResponseMessageImplementation()
 {
     this.WritePendingMessageData(true);
     this.CurrentOperationResponseMessage = ODataBatchOperationResponseMessage.CreateWriteMessage(this.rawOutputContext.OutputStream, this, this.urlResolver.BatchMessageUrlResolver);
     this.SetState(BatchWriterState.OperationCreated);
     this.WriteStartBoundaryForOperation();
     ODataBatchWriterUtils.WriteResponsePreamble(this.rawOutputContext.TextWriter);
     return(this.CurrentOperationResponseMessage);
 }
Esempio n. 4
0
        private void WriteEndChangesetImplementation()
        {
            this.WritePendingMessageData(true);
            string changeSetBoundary = this.changeSetBoundary;

            this.SetState(BatchWriterState.ChangeSetCompleted);
            ODataBatchWriterUtils.WriteEndBoundary(this.rawOutputContext.TextWriter, changeSetBoundary, !this.changesetStartBoundaryWritten);
            this.urlResolver.Reset();
            this.currentOperationContentId = null;
        }
Esempio n. 5
0
 private void WriteStartChangesetImplementation()
 {
     this.WritePendingMessageData(true);
     this.SetState(BatchWriterState.ChangeSetStarted);
     this.ResetChangeSetSize();
     this.InterceptException(new Action(this.IncreaseBatchSize));
     ODataBatchWriterUtils.WriteStartBoundary(this.rawOutputContext.TextWriter, this.batchBoundary, !this.batchStartBoundaryWritten);
     this.batchStartBoundaryWritten = true;
     ODataBatchWriterUtils.WriteChangeSetPreamble(this.rawOutputContext.TextWriter, this.changeSetBoundary);
     this.changesetStartBoundaryWritten = false;
 }
Esempio n. 6
0
 private void WriteStartBoundaryForOperation()
 {
     if (this.changeSetBoundary == null)
     {
         ODataBatchWriterUtils.WriteStartBoundary(this.rawOutputContext.TextWriter, this.batchBoundary, !this.batchStartBoundaryWritten);
         this.batchStartBoundaryWritten = true;
     }
     else
     {
         ODataBatchWriterUtils.WriteStartBoundary(this.rawOutputContext.TextWriter, this.changeSetBoundary, !this.changesetStartBoundaryWritten);
         this.changesetStartBoundaryWritten = true;
     }
 }
Esempio n. 7
0
        private void SetState(BatchWriterState newState)
        {
            this.InterceptException(() => this.ValidateTransition(newState));
            switch (newState)
            {
            case BatchWriterState.ChangeSetStarted:
                this.changeSetBoundary = ODataBatchWriterUtils.CreateChangeSetBoundary(this.rawOutputContext.WritingResponse);
                break;

            case BatchWriterState.ChangeSetCompleted:
                this.changeSetBoundary = null;
                break;
            }
            this.state = newState;
        }
Esempio n. 8
0
 private ODataBatchOperationRequestMessage CreateOperationRequestMessageImplementation(string method, Uri uri)
 {
     if (this.changeSetBoundary == null)
     {
         this.InterceptException(new Action(this.IncreaseBatchSize));
     }
     else
     {
         this.InterceptException(new Action(this.IncreaseChangeSetSize));
     }
     this.WritePendingMessageData(true);
     if (this.currentOperationContentId != null)
     {
         this.urlResolver.AddContentId(this.currentOperationContentId);
     }
     this.InterceptException(delegate {
         uri = ODataBatchUtils.CreateOperationRequestUri(uri, this.rawOutputContext.MessageWriterSettings.BaseUri, this.urlResolver);
     });
     this.CurrentOperationRequestMessage = ODataBatchOperationRequestMessage.CreateWriteMessage(this.rawOutputContext.OutputStream, method, uri, this, this.urlResolver);
     this.SetState(BatchWriterState.OperationCreated);
     this.WriteStartBoundaryForOperation();
     ODataBatchWriterUtils.WriteRequestPreamble(this.rawOutputContext.TextWriter, method, uri);
     return(this.CurrentOperationRequestMessage);
 }