/// <summary>Constructor.</summary>
 /// <param name="messageInfo">The context information for the message.</param>
 /// <param name="messageReaderSettings">Configuration settings of the OData reader.</param>
 public ODataJsonLightInputContext(
     ODataMessageInfo messageInfo,
     ODataMessageReaderSettings messageReaderSettings)
     : this(CreateTextReader(messageInfo.MessageStream, messageInfo.Encoding), messageInfo, messageReaderSettings)
 {
     Debug.Assert(messageInfo.MessageStream != null, "messageInfo.MessageStream != null");
     this.stream = messageInfo.MessageStream;
 }
Example #2
0
 internal VCardOutputContext(
     ODataFormat format,
     ODataMessageInfo messageInfo,
     ODataMessageWriterSettings messageWriterSettings)
     : base(format, messageInfo, messageWriterSettings)
 {
     this.writer       = new VCardWriter(new StreamWriter(messageInfo.MessageStream, messageInfo.Encoding));
     this.outputStream = messageInfo.MessageStream;
 }
        /// <summary>
        /// Creates an instance of the output context for this format.
        /// </summary>
        /// <param name="messageInfo">The context information for the message.</param>
        /// <param name="messageWriterSettings">Configuration settings of the OData writer.</param>
        /// <returns>The newly created output context.</returns>
        public override ODataOutputContext CreateOutputContext(
            ODataMessageInfo messageInfo,
            ODataMessageWriterSettings messageWriterSettings)
        {
            ExceptionUtils.CheckArgumentNotNull(messageInfo, "messageInfo");
            ExceptionUtils.CheckArgumentNotNull(messageWriterSettings, "messageWriterSettings");

            return(new ODataMultipartMixedBatchOutputContext(this, messageInfo, messageWriterSettings));
        }
 internal ODataAvroOutputContext(
     ODataFormat format,
     ODataMessageInfo messageInfo,
     ODataMessageWriterSettings messageWriterSettings)
     : base(format, messageInfo, messageWriterSettings)
 {
     this.outputStream = messageInfo.MessageStream;
     this.AvroWriter   = new AvroWriter(new StreamWrapper(outputStream));
 }
Example #5
0
        /// <summary>
        /// Creates an instance of the output context for this format.
        /// </summary>
        /// <param name="messageInfo">The context information for the message.</param>
        /// <param name="messageWriterSettings">Configuration settings of the OData writer.</param>
        /// <returns>The newly created output context.</returns>
        public override ODataOutputContext CreateOutputContext(
            ODataMessageInfo messageInfo,
            ODataMessageWriterSettings messageWriterSettings)
        {
            ExceptionUtils.CheckArgumentNotNull(messageInfo, "messageInfo");
            ExceptionUtils.CheckArgumentNotNull(messageWriterSettings, "messageWriterSettings");

            return(new ODataJsonLightOutputContext(messageInfo, messageWriterSettings));
        }
Example #6
0
 public CsvOutputContext(
     ODataFormat format,
     ODataMessageWriterSettings settings,
     ODataMessageInfo messageInfo,
     bool synchronous)
     : base(format, settings, messageInfo.IsResponse, synchronous, messageInfo.Model, messageInfo.UrlResolver)
 {
     this.stream = messageInfo.GetMessageStream();
     this.Writer = new StreamWriter(this.stream);
 }
Example #7
0
        /// <summary>
        /// Asynchronously creates an instance of the input context for this format.
        /// </summary>
        /// <param name="messageInfo">The context information for the message.</param>
        /// <param name="messageReaderSettings">Configuration settings of the OData reader.</param>
        /// <returns>Task which when completed returned the newly created input context.</returns>
        public override Task <ODataInputContext> CreateInputContextAsync(
            ODataMessageInfo messageInfo,
            ODataMessageReaderSettings messageReaderSettings)
        {
            ExceptionUtils.CheckArgumentNotNull(messageInfo, "messageInfo");
            ExceptionUtils.CheckArgumentNotNull(messageReaderSettings, "messageReaderSettings");

            return(Task.FromResult <ODataInputContext>(
                       new ODataJsonLightInputContext(messageInfo, messageReaderSettings)));
        }
Example #8
0
 public VCardInputContext(
     ODataFormat format,
     ODataMessageInfo messageInfo,
     ODataMessageReaderSettings messageReaderSettings)
     : base(format, messageInfo, messageReaderSettings)
 {
     this.stream = messageInfo.MessageStream;
     this.reader = new VCardReader(new StreamReader(messageInfo.MessageStream, messageInfo.Encoding));
     this.throwExceptionOnDuplicatedPropertyNames = false;
 }
Example #9
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="format">The format for this output context.</param>
 /// <param name="messageInfo">The context information for the message.</param>
 /// <param name="messageWriterSettings">Configuration settings of the OData writer.</param>
 internal ODataMultipartMixedBatchOutputContext(
     ODataFormat format,
     ODataMessageInfo messageInfo,
     ODataMessageWriterSettings messageWriterSettings)
     : base(format, messageInfo, messageWriterSettings)
 {
     Debug.Assert(messageInfo.MessageStream != null, "messageInfo.MessageStream != null");
     Debug.Assert(messageInfo.MediaType != null, "Media type should have been set in messageInfo prior to creating Raw Input Context for Batch");
     this.batchBoundary = ODataMultipartMixedBatchWriterUtils.GetBatchBoundaryFromMediaType(messageInfo.MediaType);
 }
Example #10
0
        /// <summary>
        /// Detects the payload kind(s) from the message stream.
        /// </summary>
        /// <param name="messageInfo">The context information for the message.</param>
        /// <param name="settings">Configuration settings of the OData reader.</param>
        /// <returns>An enumerable of zero, one or more payload kinds that were detected from looking at the payload in the message stream.</returns>
        private static IEnumerable <ODataPayloadKind> DetectPayloadKindImplementation(
            ODataMessageInfo messageInfo,
            ODataMessageReaderSettings settings)
        {
            var detectionInfo = new ODataPayloadKindDetectionInfo(messageInfo, settings);

            messageInfo.Encoding = detectionInfo.GetEncoding();
            using (var jsonLightInputContext = new ODataJsonLightInputContext(messageInfo, settings))
            {
                return(jsonLightInputContext.DetectPayloadKind(detectionInfo));
            }
        }
Example #11
0
        private ODataJsonLightInputContext CreateJsonLightInputContext(string payload, bool isAsync = false)
        {
            var messageInfo = new ODataMessageInfo
            {
                Encoding   = Encoding.UTF8,
                IsResponse = true,
                MediaType  = new ODataMediaType("application", "json"),
                IsAsync    = isAsync,
                Model      = new EdmModel(),
            };

            return(new ODataJsonLightInputContext(new StringReader(payload), messageInfo, this.messageReaderSettings));
        }
        /// <summary>Constructor.</summary>
        /// <param name="textReader">The text reader to use.</param>
        /// <param name="messageInfo">The context information for the message.</param>
        /// <param name="messageReaderSettings">Configuration settings of the OData reader.</param>
        internal ODataJsonLightInputContext(
            TextReader textReader,
            ODataMessageInfo messageInfo,
            ODataMessageReaderSettings messageReaderSettings)
            : base(ODataFormat.Json, messageInfo, messageReaderSettings)
        {
            Debug.Assert(messageInfo.MediaType != null, "messageInfo.MediaType != null");

            try
            {
                this.textReader = textReader;
                var innerReader = CreateJsonReader(this.Container, this.textReader, messageInfo.MediaType.HasIeee754CompatibleSetToTrue());
                if (messageReaderSettings.ArrayPool != null)
                {
                    // make sure customer also can use reading setting if without DI.
                    JsonReader jsonReader = innerReader as JsonReader;
                    if (jsonReader != null && jsonReader.ArrayPool == null)
                    {
                        jsonReader.ArrayPool = messageReaderSettings.ArrayPool;
                    }
                }

                if (messageInfo.MediaType.HasStreamingSetToTrue())
                {
                    this.jsonReader = new BufferingJsonReader(
                        innerReader,
                        JsonLightConstants.ODataErrorPropertyName,
                        messageReaderSettings.MessageQuotas.MaxNestingDepth);
                }
                else
                {
                    // If we have a non-streaming Json Light content type we need to use the re-ordering Json reader
                    this.jsonReader = new ReorderingJsonReader(innerReader, messageReaderSettings.MessageQuotas.MaxNestingDepth);
                }
            }
            catch (Exception e)
            {
                // Dispose the message stream if we failed to create the input context.
                if (ExceptionUtils.IsCatchableExceptionType(e) && this.textReader != null)
                {
                    this.textReader.Dispose();
                }

                throw;
            }

            // don't know how to get MetadataDocumentUri uri here, messageReaderSettings do not have one
            // Uri metadataDocumentUri = messageReaderSettings..MetadataDocumentUri == null ? null : messageReaderSettings.MetadataDocumentUri.BaseUri;
            // the uri here is used here to create the FullMetadataLevel can pass null in
            this.metadataLevel = JsonLightMetadataLevel.Create(messageInfo.MediaType, null, this.Model, this.ReadingResponse);
        }
Example #13
0
 /// <summary>
 /// Detects the payload kinds supported by this format for the specified message payload.
 /// </summary>
 /// <param name="messageInfo">The context information for the message.</param>
 /// <param name="settings">Configuration settings of the OData reader.</param>
 /// <returns>The set of <see cref="ODataPayloadKind"/>s that are supported with the specified payload.</returns>
 public override IEnumerable<ODataPayloadKind> DetectPayloadKind(
     ODataMessageInfo messageInfo,
     ODataMessageReaderSettings settings)
 {
     ExceptionUtils.CheckArgumentNotNull(messageInfo, "messageInfo");
     return this.DetectPayloadKindImplementation(
             messageInfo.GetMessageStream(),
             messageInfo.IsResponse,
             new ODataPayloadKindDetectionInfo(
                 messageInfo.MediaType,
                 messageInfo.Encoding,
                 settings,
                 messageInfo.Model));
 }
        private ODataMultipartMixedBatchOutputContext CreateMultipartMixedBatchOutputContext(bool writingRequest = true, bool asynchronous = false)
        {
            var messageInfo = new ODataMessageInfo
            {
                MessageStream = this.stream,
                MediaType     = this.mediaType,
                // Async writer needs the default encoding to not use the preamble.
                Encoding   = MediaTypeUtils.EncodingUtf8NoPreamble,
                IsResponse = !writingRequest,
                IsAsync    = asynchronous
            };

            return(new ODataMultipartMixedBatchOutputContext(ODataFormat.Batch, messageInfo, this.settings));
        }
Example #15
0
        private ODataJsonLightOutputContext CreateJsonLightOutputContext(bool isAsync = true)
        {
            var messageInfo = new ODataMessageInfo
            {
                MessageStream = new NonDisposingStream(this.stream),
                MediaType     = new ODataMediaType("application", "json"),
                Encoding      = Encoding.UTF8,
                IsResponse    = true,
                IsAsync       = isAsync,
                Model         = this.model
            };

            return(new ODataJsonLightOutputContext(messageInfo, this.messageWriterSettings));
        }
Example #16
0
 /// <summary>
 /// Detects the payload kinds supported by this format for the specified message payload.
 /// </summary>
 /// <param name="messageInfo">The context information for the message.</param>
 /// <param name="settings">Configuration settings of the OData reader.</param>
 /// <returns>The set of <see cref="ODataPayloadKind"/>s that are supported with the specified payload.</returns>
 public override IEnumerable <ODataPayloadKind> DetectPayloadKind(
     ODataMessageInfo messageInfo,
     ODataMessageReaderSettings settings)
 {
     ExceptionUtils.CheckArgumentNotNull(messageInfo, "messageInfo");
     return(this.DetectPayloadKindImplementation(
                messageInfo.GetMessageStream(),
                messageInfo.IsResponse,
                new ODataPayloadKindDetectionInfo(
                    messageInfo.MediaType,
                    messageInfo.Encoding,
                    settings,
                    messageInfo.Model)));
 }
Example #17
0
        private ODataJsonLightOutputContext CreateJsonLightOutputContext(bool writingRequest = true, bool asynchronous = false)
        {
            var messageInfo = new ODataMessageInfo
            {
                MessageStream = this.stream,
                MediaType     = this.mediaType,
                Encoding      = this.encoding,
                IsResponse    = !writingRequest,
                IsAsync       = asynchronous,
                Model         = this.model
            };

            return(new ODataJsonLightOutputContext(messageInfo, this.settings));
        }
Example #18
0
        public async Task ExecuteChangeSet_Throws_IfRequestIsNull()
        {
            // Arrange
            ODataMessageInfo            messageInfo  = new ODataMessageInfo();
            ODataMessageReaderSettings  settings     = new ODataMessageReaderSettings();
            Mock <ODataInputContext>    inputContext = new Mock <ODataInputContext>(ODataFormat.Batch, messageInfo, settings);
            Mock <ODataBatchReader>     batchReader  = new Mock <ODataBatchReader>(inputContext.Object, false);
            UnbufferedODataBatchHandler batchHandler = new UnbufferedODataBatchHandler();

            // Act & Assert
            await ExceptionAssert.ThrowsArgumentNullAsync(
                () => batchHandler.ExecuteChangeSetAsync(batchReader.Object, Guid.NewGuid(), null, null),
                "originalRequest");
        }
Example #19
0
        public ODataAvroInputContext(
            ODataFormat format,
            ODataMessageInfo messageInfo,
            ODataMessageReaderSettings messageReaderSettings)
            : base(format, messageInfo, messageReaderSettings)
        {
            this.stream = messageInfo.MessageStream;

            MemoryStream st = new MemoryStream();

            stream.CopyTo(st);
            st.Seek(0, SeekOrigin.Begin);
            this.AvroReader = new AvroReader(AvroContainer.CreateGenericReader(st));
        }
Example #20
0
        /// <summary>
        /// Detects the payload kind(s) from the message stream.
        /// </summary>
        /// <param name="messageInfo">The context information for the message.</param>
        /// <param name="settings">Configuration settings of the OData reader.</param>
        /// <returns>An enumerable of zero, one or more payload kinds that were detected from looking at the payload in the message stream.</returns>
        private static Task <IEnumerable <ODataPayloadKind> > DetectPayloadKindImplementationAsync(
            ODataMessageInfo messageInfo,
            ODataMessageReaderSettings settings)
        {
            var detectionInfo = new ODataPayloadKindDetectionInfo(messageInfo, settings);

            messageInfo.Encoding = detectionInfo.GetEncoding();
            var jsonLightInputContext = new ODataJsonLightInputContext(messageInfo, settings);

            return(jsonLightInputContext.DetectPayloadKindAsync(detectionInfo)
                   .FollowAlwaysWith(t =>
            {
                jsonLightInputContext.Dispose();
            }));
        }
Example #21
0
 /// <summary>
 /// Asynchronously detects the payload kinds supported by this format for the specified message payload.
 /// </summary>
 /// <param name="messageInfo">The context information for the message.</param>
 /// <param name="settings">Configuration settings of the OData reader.</param>
 /// <returns>A task that when completed returns the set of <see cref="ODataPayloadKind"/>s
 /// that are supported with the specified payload.</returns>
 public override Task <IEnumerable <ODataPayloadKind> > DetectPayloadKindAsync(
     ODataMessageInfo messageInfo,
     ODataMessageReaderSettings settings)
 {
     ExceptionUtils.CheckArgumentNotNull(messageInfo, "messageInfo");
     return(messageInfo.GetMessageStreamAsync()
            .FollowOnSuccessWithTask(streamTask => this.DetectPayloadKindImplementationAsync(
                                         streamTask.Result,
                                         /*readingResponse*/ messageInfo.IsResponse,
                                         new ODataPayloadKindDetectionInfo(
                                             messageInfo.MediaType,
                                             messageInfo.Encoding,
                                             settings,
                                             messageInfo.Model))));
 }
        private ODataJsonLightInputContext GetInputContext(string payload, IEdmModel model = null)
        {
            var messageInfo = new ODataMessageInfo
            {
                IsResponse = true,
                MediaType  = JsonLightUtils.JsonLightStreamingMediaType,
                IsAsync    = false,
                Model      = model ?? new EdmModel(),
            };

            return(new ODataJsonLightInputContext(
                       new StringReader(payload),
                       messageInfo,
                       new ODataMessageReaderSettings()));
        }
Example #23
0
        private ODataJsonLightInputContext CreateJsonLightInputContext(string payload, IEdmModel model = null, bool isAsync = false)
        {
            var messageInfo = new ODataMessageInfo
            {
                IsResponse = true,
                MediaType  = JsonLightUtils.JsonLightStreamingMediaType,
                IsAsync    = isAsync,
                Model      = model ?? EdmCoreModel.Instance,
            };

            return(new ODataJsonLightInputContext(
                       new StringReader(payload),
                       messageInfo,
                       new ODataMessageReaderSettings()));
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="textWriter">The text writer to write to.</param>
        /// <param name="messageInfo">The context information for the message.</param>
        /// <param name="messageWriterSettings">Configuration settings of the OData writer.</param>
        internal ODataJsonLightOutputContext(
            TextWriter textWriter,
            ODataMessageInfo messageInfo,
            ODataMessageWriterSettings messageWriterSettings)
            : base(ODataFormat.Json, messageInfo, messageWriterSettings)
        {
            Debug.Assert(!this.WritingResponse, "Expecting WritingResponse to always be false for this constructor, so no need to validate the MetadataDocumentUri on the writer settings.");
            Debug.Assert(textWriter != null, "textWriter != null");
            Debug.Assert(messageWriterSettings != null, "messageWriterSettings != null");

            this.textWriter           = textWriter;
            this.jsonWriter           = CreateJsonWriter(messageInfo.Container, textWriter, true /*isIeee754Compatible*/);
            this.metadataLevel        = new JsonMinimalMetadataLevel();
            this.propertyCacheHandler = new PropertyCacheHandler();
        }
Example #25
0
        private ODataAvroOutputContext CreateOutputContext(Stream stream)
        {
            var messageInfo = new ODataMessageInfo
            {
                MessageStream = stream,
                Encoding      = Encoding.UTF8,
                IsAsync       = false,
                IsResponse    = true,
            };

            return(new ODataAvroOutputContext(
                       AvroFormat.Avro,
                       messageInfo,
                       new ODataMessageWriterSettings()));
        }
Example #26
0
        private ODataAvroInputContext CreateODataInputContext(Stream stream)
        {
            var messageInfo = new ODataMessageInfo
            {
                MessageStream = stream,
                MediaType     = new ODataMediaType("avro", "binary"),
                Encoding      = Encoding.UTF8,
                IsAsync       = false,
                IsResponse    = true,
            };

            return(new ODataAvroInputContext(
                       AvroFormat.Avro,
                       messageInfo,
                       new ODataMessageReaderSettings()));
        }
Example #27
0
        /// <summary>
        /// Creates an instance of the input context for this format.
        /// </summary>
        /// <param name="messageInfo">The context information for the message.</param>
        /// <param name="messageReaderSettings">Configuration settings of the OData reader.</param>
        /// <returns>The newly created input context.</returns>
        public override ODataInputContext CreateInputContext(
            ODataMessageInfo messageInfo,
            ODataMessageReaderSettings messageReaderSettings)
        {
            ExceptionUtils.CheckArgumentNotNull(messageInfo, "messageInfo");
            ExceptionUtils.CheckArgumentNotNull(messageReaderSettings, "messageReaderSettings");

            return new ODataAtomInputContext(
                this,
                messageInfo.GetMessageStream(),
                messageInfo.Encoding,
                messageReaderSettings,
                messageInfo.IsResponse,
                /*synchronous*/ true,
                messageInfo.Model,
                messageInfo.UrlResolver);
        }
Example #28
0
        /// <summary>
        /// Creates an instance of the output context for this format.
        /// </summary>
        /// <param name="messageInfo">The context information for the message.</param>
        /// <param name="messageWriterSettings">Configuration settings of the OData writer.</param>
        /// <returns>The newly created output context.</returns>
        public override ODataOutputContext CreateOutputContext(
            ODataMessageInfo messageInfo,
            ODataMessageWriterSettings messageWriterSettings)
        {
            ExceptionUtils.CheckArgumentNotNull(messageInfo, "messageInfo");
            ExceptionUtils.CheckArgumentNotNull(messageWriterSettings, "messageWriterSettings");

            return(new ODataAtomOutputContext(
                       this,
                       messageInfo.GetMessageStream(),
                       messageInfo.Encoding,
                       messageWriterSettings,
                       messageInfo.IsResponse,
                       /*synchronous*/ true,
                       messageInfo.Model,
                       messageInfo.UrlResolver));
        }
        private ODataJsonLightInputContext CreateJsonLightInputContext(string payload, bool isAsync = false, bool isResponse = true)
        {
            var messageInfo = new ODataMessageInfo
            {
                MediaType = new ODataMediaType("application", "json"),
#if NETCOREAPP1_1
                Encoding = Encoding.GetEncoding(0),
#else
                Encoding = Encoding.Default,
#endif
                IsResponse = isResponse,
                IsAsync    = isAsync,
                Model      = this.model
            };

            return(new ODataJsonLightInputContext(new StringReader(payload), messageInfo, this.messageReaderSettings));
        }
Example #30
0
        private ODataJsonLightServiceDocumentDeserializer CreateODataJsonServiceDocumentDeserializer(MemoryStream stream, IODataPayloadUriConverter urlResolver = null)
        {
            var messageInfo = new ODataMessageInfo
            {
                Encoding            = Encoding.UTF8,
                IsResponse          = true,
                MediaType           = new ODataMediaType("application", "json"),
                IsAsync             = false,
                Model               = new EdmModel(),
                PayloadUriConverter = urlResolver,
                MessageStream       = stream
            };

            var inputContext = new ODataJsonLightInputContext(messageInfo, new ODataMessageReaderSettings());

            return(new ODataJsonLightServiceDocumentDeserializer(inputContext));
        }
Example #31
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="messageInfo">The context information for the message.</param>
        /// <param name="messageWriterSettings">Configuration settings of the OData writer.</param>
        public ODataJsonLightOutputContext(
            ODataMessageInfo messageInfo,
            ODataMessageWriterSettings messageWriterSettings)
            : base(ODataFormat.Json, messageInfo, messageWriterSettings)
        {
            Debug.Assert(messageInfo.MessageStream != null, "messageInfo.MessageStream != null");
            Debug.Assert(messageInfo.MediaType != null, "messageInfo.MediaType != null");

            try
            {
                this.messageOutputStream = messageInfo.MessageStream;

                Stream outputStream;
                if (this.Synchronous)
                {
                    outputStream = this.messageOutputStream;
                }
                else
                {
                    this.asynchronousOutputStream = new AsyncBufferedStream(this.messageOutputStream);
                    outputStream = this.asynchronousOutputStream;
                }

                this.textWriter = new StreamWriter(outputStream, messageInfo.Encoding);

                // COMPAT 2: JSON indentation - WCFDS indents only partially, it inserts newlines but doesn't actually insert spaces for indentation
                // in here we allow the user to specify if true indentation should be used or if the limited functionality is enough.
                this.jsonWriter = CreateJsonWriter(this.Container, this.textWriter, messageInfo.MediaType.HasIeee754CompatibleSetToTrue(), messageWriterSettings);
            }
            catch (Exception e)
            {
                // Dispose the message stream if we failed to create the input context.
                if (ExceptionUtils.IsCatchableExceptionType(e))
                {
                    this.messageOutputStream.Dispose();
                }

                throw;
            }

            Uri  metadataDocumentUri = messageWriterSettings.MetadataDocumentUri;
            bool alwaysAddTypeAnnotationsForDerivedTypes = messageWriterSettings.AlwaysAddTypeAnnotationsForDerivedTypes;

            this.metadataLevel        = JsonLightMetadataLevel.Create(messageInfo.MediaType, metadataDocumentUri, alwaysAddTypeAnnotationsForDerivedTypes, this.Model, this.WritingResponse);
            this.propertyCacheHandler = new PropertyCacheHandler();
        }
Example #32
0
        private static ODataBatchReaderStream CreateBatchReaderStream(string inputString)
        {
            var messageInfo = new ODataMessageInfo
            {
                Encoding      = Encoding.UTF8,
                IsResponse    = false,
                IsAsync       = false,
                PayloadKind   = ODataPayloadKind.Batch,
                MessageStream = new MemoryStream(Encoding.UTF8.GetBytes(inputString))
            };
            var inputContext = new ODataRawInputContext(
                ODataFormat.Batch,
                messageInfo,
                new ODataMessageReaderSettings());
            var batchStream = new ODataBatchReaderStream(inputContext, "batch_862fb28e-dc50-4af1-aad5-9608647761d1", Encoding.UTF8);

            return(batchStream);
        }
 public override System.Threading.Tasks.Task<ODataOutputContext> CreateOutputContextAsync(ODataMessageInfo messageInfo, ODataMessageWriterSettings messageWriterSettings)
 {
     throw new NotImplementedException();
 }
Example #34
0
        /// <summary>
        /// Creates an instance of the output context for this format.
        /// </summary>
        /// <param name="messageInfo">The context information for the message.</param>
        /// <param name="messageWriterSettings">Configuration settings of the OData writer.</param>
        /// <returns>Task which represents the pending create operation.</returns>
        public override Task<ODataOutputContext> CreateOutputContextAsync(
            ODataMessageInfo messageInfo,
            ODataMessageWriterSettings messageWriterSettings)
        {
            ExceptionUtils.CheckArgumentNotNull(messageInfo, "messageInfo");
            ExceptionUtils.CheckArgumentNotNull(messageWriterSettings, "messageWriterSettings");

            return messageInfo.GetMessageStreamAsync()
                .FollowOnSuccessWith(
                    (streamTask) => (ODataOutputContext)new ODataAtomOutputContext(
                        this,
                        streamTask.Result,
                        messageInfo.Encoding,
                        messageWriterSettings,
                        messageInfo.IsResponse,
                        /*synchronous*/ false,
                        messageInfo.Model,
                        messageInfo.UrlResolver));
        }
Example #35
0
 /// <summary>
 /// Asynchronously detects the payload kinds supported by this format for the specified message payload.
 /// </summary>
 /// <param name="messageInfo">The context information for the message.</param>
 /// <param name="settings">Configuration settings of the OData reader.</param>
 /// <returns>A task that when completed returns the set of <see cref="ODataPayloadKind"/>s 
 /// that are supported with the specified payload.</returns>
 public override Task<IEnumerable<ODataPayloadKind>> DetectPayloadKindAsync(
     ODataMessageInfo messageInfo,
     ODataMessageReaderSettings settings)
 {
     ExceptionUtils.CheckArgumentNotNull(messageInfo, "messageInfo");
     return messageInfo.GetMessageStreamAsync()
          .FollowOnSuccessWith(
             streamTask => this.DetectPayloadKindImplementation(
                             streamTask.Result,
                             /*readingResponse*/ messageInfo.IsResponse,
                             /*synchronous*/ false,
                             new ODataPayloadKindDetectionInfo(
                                 messageInfo.MediaType,
                                 messageInfo.Encoding,
                                 settings,
                                 messageInfo.Model)));
 }
 public override IEnumerable<ODataPayloadKind> DetectPayloadKind(ODataMessageInfo messageInfo, ODataMessageReaderSettings settings)
 {
     throw new System.NotImplementedException();
 }
 public override ODataOutputContext CreateOutputContext(ODataMessageInfo messageInfo, ODataMessageWriterSettings messageWriterSettings)
 {
     throw new NotImplementedException();
 }
 public override System.Threading.Tasks.Task<IEnumerable<ODataPayloadKind>> DetectPayloadKindAsync(ODataMessageInfo messageInfo, ODataMessageReaderSettings settings)
 {
     throw new NotImplementedException();
 }