< Summary

Class:Azure.Search.Documents.Models.SearchDocumentConverter
Assembly:Azure.Search.Documents
File(s):C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\SearchDocument\SearchDocumentConverter.cs
Covered lines:16
Uncovered lines:0
Coverable lines:16
Total lines:59
Line coverage:100% (16 of 16)
Covered branches:0
Total branches:0

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
get_Shared()-100%100%
.cctor()-100%100%
Write(...)-100%100%
Read(...)-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\SearchDocument\SearchDocumentConverter.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System;
 5using System.Text.Json;
 6using System.Text.Json.Serialization;
 7using Azure.Core;
 8
 9namespace Azure.Search.Documents.Models
 10{
 11    /// <summary>
 12    /// Convert JSON to and from a SearchDocument.
 13    /// </summary>
 14    internal class SearchDocumentConverter : JsonConverter<SearchDocument>
 15    {
 116        public static SearchDocumentConverter Shared { get; } =
 117            new SearchDocumentConverter();
 18
 19        /// <summary>
 20        /// Write a SearchDocument as JSON.
 21        /// </summary>
 22        /// <param name="writer">The JSON writer.</param>
 23        /// <param name="value">The document.</param>
 24        /// <param name="options">Serialization options.</param>
 25        public override void Write(
 26            Utf8JsonWriter writer,
 27            SearchDocument value,
 28            JsonSerializerOptions options)
 29        {
 1667030            Argument.AssertNotNull(writer, nameof(writer));
 1667031            Argument.AssertNotNull(value, nameof(value));
 1667032            Argument.AssertNotNull(options, nameof(options));
 1667033            JsonSerialization.WriteSearchDocument(
 1667034                writer,
 1667035                value,
 1667036                options);
 1667037        }
 38
 39        /// <summary>
 40        /// Parse JSON into a SearchDocument.
 41        /// </summary>
 42        /// <param name="reader">The JSON reader.</param>
 43        /// <param name="typeToConvert">The type to convert to.</param>
 44        /// <param name="options">Serialization options.</param>
 45        /// <returns>A deserialized SearchDocument.</returns>
 46        public override SearchDocument Read(
 47            ref Utf8JsonReader reader,
 48            Type typeToConvert,
 49            JsonSerializerOptions options)
 50        {
 874651            Argument.AssertNotNull(typeToConvert, nameof(typeToConvert));
 874652            Argument.AssertNotNull(options, nameof(options));
 874653            return JsonSerialization.ReadSearchDocument(
 874654                ref reader,
 874655                typeToConvert,
 874656                options);
 57        }
 58    }
 59}