| | 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 System; |
| | 6 | | using System.Reflection; |
| | 7 | | using Microsoft.Spatial; |
| | 8 | | using Newtonsoft.Json; |
| | 9 | |
|
| | 10 | | namespace Microsoft.Azure.Search.Serialization |
| | 11 | | { |
| | 12 | | /// <summary> |
| | 13 | | /// Converts between <c cref="GeographyPoint">Microsoft.Spatial.GeographyPoint</c> objects and Geo-JSON points. |
| | 14 | | /// </summary> |
| | 15 | | internal class GeoJsonPointConverter : JsonConverter |
| | 16 | | { |
| | 17 | | public override bool CanConvert(Type objectType) => |
| 311638 | 18 | | typeof(GeographyPoint).GetTypeInfo().IsAssignableFrom(objectType.GetTypeInfo()); |
| | 19 | |
|
| | 20 | | public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer seriali |
| 576 | 21 | | reader.ReadGeoJsonPoint(); |
| | 22 | |
|
| | 23 | | public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) => |
| 1994 | 24 | | writer.WriteGeoJsonPoint((GeographyPoint)value); |
| | 25 | | } |
| | 26 | | } |