コード例 #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);
            }
        }