| | 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 Newtonsoft.Json; |
| | 6 | |
|
| | 7 | | namespace Microsoft.Azure.EventGrid |
| | 8 | | { |
| | 9 | | static class JsonSerializerExtensions |
| | 10 | | { |
| | 11 | | public static JsonSerializerSettings GetJsonSerializerSettings(this JsonSerializer serializer) |
| | 12 | | { |
| 84 | 13 | | var jsonSerializerSettings = new JsonSerializerSettings |
| 84 | 14 | | { |
| 84 | 15 | | Context = serializer.Context, |
| 84 | 16 | | Culture = serializer.Culture, |
| 84 | 17 | | ContractResolver = serializer.ContractResolver, |
| 84 | 18 | | ConstructorHandling = serializer.ConstructorHandling, |
| 84 | 19 | | CheckAdditionalContent = serializer.CheckAdditionalContent, |
| 84 | 20 | | DateFormatHandling = serializer.DateFormatHandling, |
| 84 | 21 | | DateFormatString = serializer.DateFormatString, |
| 84 | 22 | | DateParseHandling = serializer.DateParseHandling, |
| 84 | 23 | | DateTimeZoneHandling = serializer.DateTimeZoneHandling, |
| 84 | 24 | | DefaultValueHandling = serializer.DefaultValueHandling, |
| 84 | 25 | | FloatFormatHandling = serializer.FloatFormatHandling, |
| 84 | 26 | | Formatting = serializer.Formatting, |
| 84 | 27 | | FloatParseHandling = serializer.FloatParseHandling, |
| 84 | 28 | | MaxDepth = serializer.MaxDepth, |
| 84 | 29 | | MetadataPropertyHandling = serializer.MetadataPropertyHandling, |
| 84 | 30 | | MissingMemberHandling = serializer.MissingMemberHandling, |
| 84 | 31 | | NullValueHandling = serializer.NullValueHandling, |
| 84 | 32 | | ObjectCreationHandling = serializer.ObjectCreationHandling, |
| 84 | 33 | | PreserveReferencesHandling = serializer.PreserveReferencesHandling, |
| 84 | 34 | | ReferenceResolver = serializer.ReferenceResolver, |
| 84 | 35 | | ReferenceLoopHandling = serializer.ReferenceLoopHandling, |
| 84 | 36 | | StringEscapeHandling = serializer.StringEscapeHandling, |
| 84 | 37 | | TraceWriter = serializer.TraceWriter, |
| 84 | 38 | | TypeNameHandling = serializer.TypeNameHandling, |
| 84 | 39 | | }; |
| | 40 | |
|
| 502 | 41 | | foreach (JsonConverter converter in serializer.Converters) |
| | 42 | | { |
| 167 | 43 | | jsonSerializerSettings.Converters.Add(converter); |
| | 44 | | } |
| | 45 | |
|
| 84 | 46 | | return jsonSerializerSettings; |
| | 47 | | } |
| | 48 | | } |
| | 49 | | } |