/// <summary> /// Asynchronously creates an instance of the input context for the specified format. /// </summary> /// <param name="format">The format to create the context for.</param> /// <param name="readerPayloadKind">The <see cref="ODataPayloadKind"/> to read.</param> /// <param name="message">The message to use.</param> /// <param name="encoding">The encoding to use.</param> /// <param name="messageReaderSettings">Configuration settings of the OData reader.</param> /// <param name="version">The OData protocol version to be used for reading the payload.</param> /// <param name="readingResponse">true if reading a response message; otherwise false.</param> /// <param name="model">The model to use.</param> /// <param name="urlResolver">The optional URL resolver to perform custom URL resolution for URLs read from the payload.</param> /// <returns>Task which when completed returned the newly created input context.</returns> internal static Task <ODataInputContext> CreateInputContextAsync( ODataFormat format, ODataPayloadKind readerPayloadKind, ODataMessage message, Encoding encoding, ODataMessageReaderSettings messageReaderSettings, ODataVersion version, bool readingResponse, IEdmModel model, IODataUrlResolver urlResolver) { DebugUtils.CheckNoExternalCallers(); Debug.Assert(format != ODataFormat.Metadata, "Async reading of metadata documents is not supported."); Debug.Assert(readerPayloadKind != ODataPayloadKind.MetadataDocument, "Async reading of metadata documents is not supported."); if (format == ODataFormat.Atom) { return(ODataAtomInputContext.CreateAsync( format, message, encoding, messageReaderSettings, version, readingResponse, model, urlResolver)); } if (format == ODataFormat.VerboseJson) { return(ODataJsonInputContext.CreateAsync( format, message, encoding, messageReaderSettings, version, readingResponse, model, urlResolver)); } if (format == ODataFormat.Batch || format == ODataFormat.RawValue) { return(ODataRawInputContext.CreateAsync( format, message, encoding, messageReaderSettings, version, readingResponse, model, urlResolver, readerPayloadKind)); } throw new ODataException(Strings.General_InternalError(InternalErrorCodes.ODataInputContext_CreateInputContext_UnrecognizedFormat)); }
internal static Task <ODataInputContext> CreateInputContextAsync(ODataFormat format, ODataPayloadKind readerPayloadKind, ODataMessage message, Encoding encoding, ODataMessageReaderSettings messageReaderSettings, ODataVersion version, bool readingResponse, IEdmModel model, IODataUrlResolver urlResolver) { if (format == ODataFormat.Atom) { return(ODataAtomInputContext.CreateAsync(format, message, encoding, messageReaderSettings, version, readingResponse, model, urlResolver)); } if (format == ODataFormat.VerboseJson) { return(ODataJsonInputContext.CreateAsync(format, message, encoding, messageReaderSettings, version, readingResponse, model, urlResolver)); } if ((format != ODataFormat.Batch) && (format != ODataFormat.RawValue)) { throw new ODataException(Microsoft.Data.OData.Strings.General_InternalError(InternalErrorCodes.ODataInputContext_CreateInputContext_UnrecognizedFormat)); } return(ODataRawInputContext.CreateAsync(format, message, encoding, messageReaderSettings, version, readingResponse, model, urlResolver, readerPayloadKind)); }