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 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 #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 IEnumerable <ODataPayloadKind> DetectPayloadKindImplementation(
     Stream messageStream,
     bool readingResponse,
     ODataPayloadKindDetectionInfo detectionInfo)
 {
     using (ODataJsonLightInputContext jsonLightInputContext = new ODataJsonLightInputContext(
                this,
                messageStream,
                detectionInfo.ContentType,
                detectionInfo.GetEncoding(),
                detectionInfo.MessageReaderSettings,
                readingResponse,
                /*synchronous*/ true,
                detectionInfo.Model,
                /*urlResolver*/ null))
     {
         return(jsonLightInputContext.DetectPayloadKind(detectionInfo));
     }
 }