| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. See License.txt in the project root for |
| | 3 | | // license information. |
| | 4 | |
|
| | 5 | | using Microsoft.Spatial; |
| | 6 | | using Newtonsoft.Json; |
| | 7 | | using Newtonsoft.Json.Linq; |
| | 8 | | using System.Collections; |
| | 9 | | using System.Collections.Generic; |
| | 10 | |
|
| | 11 | | namespace Microsoft.Azure.Search.Serialization.Internal |
| | 12 | | { |
| | 13 | | /// <summary> |
| | 14 | | /// Provides access to custom <c cref="JsonConverter">JsonConverter</c> instances used by the Azure |
| | 15 | | /// Search .NET SDK. For test purposes only. |
| | 16 | | /// </summary> |
| | 17 | | /// <remarks> |
| | 18 | | /// This class is part of the internal implementation of the Azure Cognitive Search .NET SDK. It is not |
| | 19 | | /// intended to be used directly by application code. |
| | 20 | | /// </remarks> |
| | 21 | | public static class CustomJsonConverters |
| | 22 | | { |
| | 23 | | /// <summary> |
| | 24 | | /// Creates a new converter that converts between dates serialized in ISO 8601 format in JSON strings and |
| | 25 | | /// <c cref="System.DateTime">System.DateTime</c> instances. |
| | 26 | | /// </summary> |
| | 27 | | /// <returns>A JSON converter.</returns> |
| 58 | 28 | | public static JsonConverter CreateDateTimeConverter() => new Iso8601DateTimeConverter(); |
| | 29 | |
|
| | 30 | | /// <summary> |
| | 31 | | /// Creates a new converter that deserializes JSON objects and arrays to .NET types instead |
| | 32 | | /// of <c cref="JObject">JObject</c> and <c cref="JArray">JArray</c>. |
| | 33 | | /// </summary> |
| | 34 | | /// <returns>A JSON converter.</returns> |
| 2 | 35 | | public static JsonConverter CreateDocumentConverter() => new DocumentConverter(); |
| | 36 | |
|
| | 37 | | /// <summary> |
| | 38 | | /// Creates a new converter that serializes doubles to and from the OData EDM wire format. |
| | 39 | | /// </summary> |
| | 40 | | /// <returns>A JSON converter.</returns> |
| 26 | 41 | | public static JsonConverter CreateDoubleConverter() => new EdmDoubleConverter(); |
| | 42 | |
|
| | 43 | | /// <summary> |
| | 44 | | /// Creates a new converter that converts between |
| | 45 | | /// <c cref="GeographyPoint">Microsoft.Spatial.GeographyPoint</c> objects and Geo-JSON points. |
| | 46 | | /// </summary> |
| | 47 | | /// <returns>A JSON converter.</returns> |
| 28 | 48 | | public static JsonConverter CreateGeoJsonPointConverter() => new GeoJsonPointConverter(); |
| | 49 | |
|
| | 50 | | /// <summary> |
| | 51 | | /// Creates a collection of all custom converters. |
| | 52 | | /// </summary> |
| | 53 | | /// <returns>An enumerable sequence of JSON converters.</returns> |
| | 54 | | public static IEnumerable<JsonConverter> CreateAllConverters() |
| | 55 | | { |
| 2 | 56 | | yield return CreateDateTimeConverter(); |
| 2 | 57 | | yield return CreateDocumentConverter(); |
| 2 | 58 | | yield return CreateDoubleConverter(); |
| 2 | 59 | | yield return CreateGeoJsonPointConverter(); |
| 2 | 60 | | } |
| | 61 | | } |
| | 62 | | } |