Example #1
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 #2
0
        /// <summary>
        /// Detects the payload kind(s) from the message stream.
        /// </summary>
        /// <param name="messageStream">The message stream to read from for payload kind detection.</param>
        /// <param name="readingResponse">true if reading a response message; otherwise false.</param>
        /// <param name="detectionInfo">Additional information available for the payload kind detection.</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 Task <IEnumerable <ODataPayloadKind> > DetectPayloadKindImplementationAsync(
            Stream messageStream,
            bool readingResponse,
            ODataPayloadKindDetectionInfo detectionInfo)
        {
            ODataJsonLightInputContext jsonLightInputContext = new ODataJsonLightInputContext(
                this,
                messageStream,
                detectionInfo.ContentType,
                detectionInfo.GetEncoding(),
                detectionInfo.MessageReaderSettings,
                readingResponse,
                /*synchronous*/ false,
                detectionInfo.Model,
                /*urlResolver*/ null);

            return(jsonLightInputContext.DetectPayloadKindAsync(detectionInfo)
                   .FollowAlwaysWith(t =>
            {
                jsonLightInputContext.Dispose();
            }));
        }