/// <summary> /// Sets the 'DataServiceVersion' HTTP header on the message based on the protocol version specified in the settings. /// </summary> /// <param name="message">The message to set the data service version header on.</param> /// <param name="settings">The <see cref="ODataWriterSettings"/> determining the protocol version to use.</param> internal static void SetDataServiceVersion(ODataMessage message, ODataWriterSettings settings) { DebugUtils.CheckNoExternalCallers(); Debug.Assert(message != null, "message != null"); Debug.Assert(settings != null, "settings != null"); // TODO: Bug 112260: What to do with the optional user agent string? string userAgentString = string.Empty; string dataServiceVersionString = settings.Version.VersionString() + ";" + userAgentString; message.SetHeader(ODataHttpHeaders.DataServiceVersion, dataServiceVersionString); }
/// <summary> /// Sets the 'DataServiceVersion' HTTP header on the message based on the protocol version specified in the settings. /// </summary> /// <param name="message">The message to set the data service version header on.</param> /// <param name="settings">The <see cref="ODataWriterSettings"/> determining the protocol version to use.</param> internal static void SetDataServiceVersion(ODataMessage message, ODataWriterSettings settings) { DebugUtils.CheckNoExternalCallers(); Debug.Assert(message != null, "message != null"); Debug.Assert(settings != null, "settings != null"); // TODO: Bug 112260: What to do with the optional user agent string? string userAgentString = string.Empty; string dataServiceVersionString = settings.Version.VersionString() + ";" + userAgentString; message.SetHeader(ODataHttpHeaders.DataServiceVersion, dataServiceVersionString); }
/// <summary> /// Create a func which creates an <see cref="ODataBatchWriter"/> for a given message and stream. /// </summary> /// <param name="message">The message to create the writer for.</param> /// <param name="settings">Configuration settings for the writer to create.</param> /// <param name="writingResponse">A flag indicating whether we are writing a request or a response message.</param> /// <param name="batchBoundary">The batch boundary string used when writing the batch payload.</param> /// <param name="synchronous">True if the writer is created for synchronous operation; false for asynchronous.</param> /// <returns>A func which creates the batch writer given a stream to write to.</returns> internal static Func <Stream, ODataBatchWriter> Create( ODataMessage message, ODataWriterSettings settings, bool writingResponse, string batchBoundary, bool synchronous) { DebugUtils.CheckNoExternalCallers(); ExceptionUtils.CheckArgumentNotNull(message, "message"); ExceptionUtils.CheckArgumentNotNull(settings, "settings"); ExceptionUtils.CheckArgumentNotNull(batchBoundary, "batchBoundary"); return((stream) => CreateBatchWriter(batchBoundary, stream, settings, writingResponse, synchronous)); }
/// <summary> /// Create a func which created an <see cref="ODataCollectionWriter"/> for a given request message and stream. /// </summary> /// <param name="message">The message to create the writer for.</param> /// <param name="settings">Configuration settings for the writer to create.</param> /// <param name="format">The OData format used for serialization of the payload.</param> /// <param name="encoding">The encoding used for serialization of the payload.</param> /// <param name="metadataProvider">The metadata provider to use.</param> /// <param name="synchronous">True if the writer is created for synchronous operation; false for asynchronous.</param> /// <returns>A task returning an OData collection writer to write the payload of the request/response.</returns> internal static Func <Stream, ODataCollectionWriter> Create( ODataMessage message, ODataWriterSettings settings, ODataFormat format, Encoding encoding, DataServiceMetadataProviderWrapper metadataProvider, bool synchronous) { DebugUtils.CheckNoExternalCallers(); ExceptionUtils.CheckArgumentNotNull(message, "message"); ExceptionUtils.CheckArgumentNotNull(settings, "settings"); return((stream) => CreateCollectionWriter(format, encoding, stream, settings, metadataProvider, synchronous)); }
/// <summary> /// Creates a new ODataMessageWriter for the given request message and writer settings. /// </summary> /// <param name="requestMessage">The request message for which to create the writer.</param> /// <param name="settings">The writer settings to use for writing the message payload.</param> /// <param name="metadataProvider">The metadata provider to use.</param> public ODataMessageWriter(IODataRequestMessage requestMessage, ODataWriterSettings settings, IDataServiceMetadataProvider metadataProvider) { ExceptionUtils.CheckArgumentNotNull(requestMessage, "requestMessage"); ExceptionUtils.CheckArgumentNotNull(settings, "settings"); ODataVersionChecker.CheckVersionSupported(settings.Version); this.writingResponse = false; this.message = new ODataRequestMessage(requestMessage); this.settings = settings; if (metadataProvider != null) { this.metadataProvider = new DataServiceMetadataProviderWrapper(metadataProvider); } }
/// <summary> /// Create a func which creates an <see cref="ODataBatchWriter"/> for a given message and stream. /// </summary> /// <param name="message">The message to create the writer for.</param> /// <param name="settings">Configuration settings for the writer to create.</param> /// <param name="writingResponse">A flag indicating whether we are writing a request or a response message.</param> /// <param name="batchBoundary">The batch boundary string used when writing the batch payload.</param> /// <param name="synchronous">True if the writer is created for synchronous operation; false for asynchronous.</param> /// <returns>A func which creates the batch writer given a stream to write to.</returns> internal static Func<Stream, ODataBatchWriter> Create( ODataMessage message, ODataWriterSettings settings, bool writingResponse, string batchBoundary, bool synchronous) { DebugUtils.CheckNoExternalCallers(); ExceptionUtils.CheckArgumentNotNull(message, "message"); ExceptionUtils.CheckArgumentNotNull(settings, "settings"); ExceptionUtils.CheckArgumentNotNull(batchBoundary, "batchBoundary"); return (stream) => CreateBatchWriter(batchBoundary, stream, settings, writingResponse, synchronous); }
/// <summary> /// Create a func which creates an ODataWriter for a given request message and stream. /// </summary> /// <param name="message">The message to create the writer for.</param> /// <param name="settings">Configuration settings for the writer to create.</param> /// <param name="format">The OData format used for serialization of the payload.</param> /// <param name="encoding">The encoding used for serialization of the payload.</param> /// <param name="writingResponse">True if the message writing a response message; otherwise false.</param> /// <param name="metadataProvider">The metadata provider to use.</param> /// <param name="writingFeed">True when creating a writer to write a feed; false when creating a writer to write an entry.</param> /// <param name="synchronous">True if the writer is created for synchronous operation; false for asynchronous.</param> /// <returns>A func which creates the writer given a stream to write to.</returns> internal static Func<Stream, ODataWriter> Create( ODataMessage message, ODataWriterSettings settings, ODataFormat format, Encoding encoding, bool writingResponse, DataServiceMetadataProviderWrapper metadataProvider, bool writingFeed, bool synchronous) { DebugUtils.CheckNoExternalCallers(); ExceptionUtils.CheckArgumentNotNull(message, "message"); ExceptionUtils.CheckArgumentNotNull(settings, "settings"); return (stream) => CreateWriter(format, encoding, stream, settings, writingResponse, metadataProvider, writingFeed, synchronous); }