Пример #1
0
 public override System.Threading.Tasks.Task<ODataInputContext> CreateInputContextAsync(ODataMessageInfo messageInfo, ODataMessageReaderSettings messageReaderSettings)
 {
     return messageInfo.GetMessageStreamAsync()
         .ContinueWith(
             (streamTask) => (ODataInputContext) new VCardInputContext(
                 this,
                 streamTask.Result,
                 messageInfo.MediaType,
                 messageInfo.Encoding,
                 messageReaderSettings,
                 messageInfo.IsResponse,
                 /*sync*/ false,
                 messageInfo.Model,
                 messageInfo.UrlResolver),
             TaskContinuationOptions.NotOnFaulted);
 }
Пример #2
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.IsResponse
         ? messageInfo.GetMessageStreamAsync()
            .FollowOnSuccessWith(streamTask => DetectPayloadKindImplementation(
                                     streamTask.Result,
                                     new ODataPayloadKindDetectionInfo(
                                         messageInfo.MediaType,
                                         messageInfo.Encoding,
                                         settings,
                                         messageInfo.Model)))
         : TaskUtils.GetCompletedTask(Enumerable.Empty <ODataPayloadKind>()));
 }
Пример #3
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 ODataRawOutputContext(
                           this,
                           streamTask.Result,
                           messageInfo.Encoding,
                           messageWriterSettings,
                           messageInfo.IsResponse,
                           /*synchronous*/ false,
                           messageInfo.Model,
                           messageInfo.UrlResolver)));
        }
Пример #4
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 ODataRawOutputContext(
                        this,
                        streamTask.Result,
                        messageInfo.Encoding,
                        messageWriterSettings,
                        messageInfo.IsResponse,
                        /*synchronous*/ false,
                        messageInfo.Model,
                        messageInfo.UrlResolver));
        }
Пример #5
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.IsResponse
         ? messageInfo.GetMessageStreamAsync()
             .FollowOnSuccessWith(streamTask => DetectPayloadKindImplementation(
                     streamTask.Result,
                     new ODataPayloadKindDetectionInfo(
                         messageInfo.MediaType,
                         messageInfo.Encoding,
                         settings,
                         messageInfo.Model)))
         : TaskUtils.GetCompletedTask(Enumerable.Empty<ODataPayloadKind>());
 }