/// <summary> /// Writes a single top-level Uri in response to a $links query. /// </summary> /// <param name="jsonWriter">The <see cref="JsonWriter"/> to write to.</param> /// <param name="baseUri">The base Uri used for writing.</param> /// <param name="link">The associated entity link to write out.</param> /// <param name="writingResponse">Flag indicating whether a request or a response is being written.</param> internal static void WriteAssociatedEntityLink(JsonWriter jsonWriter, Uri baseUri, ODataAssociatedEntityLink link, bool writingResponse) { DebugUtils.CheckNoExternalCallers(); Debug.Assert(jsonWriter != null, "jsonWriter != null"); Debug.Assert(link != null, "link != null"); ODataJsonWriterUtils.WriteDataWrapper( jsonWriter, writingResponse, () => WriteAssociatedEntityLink(jsonWriter, baseUri, link)); }
/// <summary> /// Writes a set of links (Uris) in response to a $links query; includes optional count and next-page-link information. /// </summary> /// <param name="jsonWriter">The <see cref="JsonWriter"/> to write to.</param> /// <param name="baseUri">The base Uri used for writing.</param> /// <param name="associatedEntityLinks">The set of associated entity links to write out.</param> /// <param name="version">The protocol version used for writing.</param> /// <param name="writingResponse">Flag indicating whether a request or a response is being written.</param> internal static void WriteAssociatedEntityLinks(JsonWriter jsonWriter, Uri baseUri, ODataAssociatedEntityLinks associatedEntityLinks, ODataVersion version, bool writingResponse) { DebugUtils.CheckNoExternalCallers(); Debug.Assert(jsonWriter != null, "jsonWriter != null"); Debug.Assert(associatedEntityLinks != null, "associatedEntityLinks != null"); ODataJsonWriterUtils.WriteDataWrapper( jsonWriter, writingResponse, () => WriteAssociatedEntityLinks(jsonWriter, baseUri, associatedEntityLinks, version >= ODataVersion.V2 && writingResponse)); }
/// <summary> /// Write an <see cref="ODataProperty" /> to the given stream. This method creates an /// async buffered stream and writes the property to it. /// </summary> /// <param name="jsonWriter">The <see cref="JsonWriter"/> to write to.</param> /// <param name="metadata">The metadata provider to use or null if no metadata is available.</param> /// <param name="property">The property to write.</param> /// <param name="owningType">The type owning the property (or null if no metadata is available).</param> /// <param name="version">The protocol version used for writing.</param> /// <param name="writingResponse">Flag indicating whether a request or a response is being written.</param> internal static void WriteTopLevelProperty( JsonWriter jsonWriter, DataServiceMetadataProviderWrapper metadata, ODataProperty property, ResourceType owningType, ODataVersion version, bool writingResponse) { DebugUtils.CheckNoExternalCallers(); Debug.Assert(jsonWriter != null, "jsonWriter != null"); Debug.Assert(property != null, "property != null"); ODataJsonWriterUtils.WriteDataWrapper( jsonWriter, writingResponse, () => { jsonWriter.StartObjectScope(); WriteProperty(jsonWriter, metadata, property, owningType, version); jsonWriter.EndObjectScope(); }); }