-
Notifications
You must be signed in to change notification settings - Fork 0
/
JsonSerializerSettingsProvider.cs
60 lines (57 loc) · 2.7 KB
/
JsonSerializerSettingsProvider.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// <copyright file="JsonSerializerSettingsProvider.cs" company="Endjin Limited">
// Copyright (c) Endjin Limited. All rights reserved.
// </copyright>
namespace Corvus.Extensions.Json.Internal
{
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Newtonsoft.Json;
/// <summary>
/// Initializes a new instance of the <see cref="JsonSerializerSettingsProvider"/> class.
/// </summary>
public class JsonSerializerSettingsProvider : IJsonSerializerSettingsProvider
{
/// <summary>
/// Initializes a new instance of the <see cref="JsonSerializerSettingsProvider"/> class.
/// </summary>
/// <param name="converters">The list of JsonConverters to add.</param>
/// <remarks>
/// You should not modify these settings directly. They are shared by all users.
/// </remarks>
public JsonSerializerSettingsProvider(IEnumerable<JsonConverter> converters)
{
this.Instance = new JsonSerializerSettings
{
ContractResolver = StandardContractResolver.Instance,
MissingMemberHandling = MissingMemberHandling.Ignore,
ReferenceLoopHandling = ReferenceLoopHandling.Error,
NullValueHandling = NullValueHandling.Ignore,
ObjectCreationHandling = ObjectCreationHandling.Auto,
PreserveReferencesHandling = PreserveReferencesHandling.None,
ConstructorHandling = ConstructorHandling.Default,
TypeNameHandling = TypeNameHandling.None,
MetadataPropertyHandling = MetadataPropertyHandling.Default,
Formatting = Formatting.None,
DateFormatHandling = DateFormatHandling.IsoDateFormat,
DateTimeZoneHandling = DateTimeZoneHandling.RoundtripKind,
DateParseHandling = DateParseHandling.None,
FloatParseHandling = FloatParseHandling.Double,
FloatFormatHandling = FloatFormatHandling.String,
StringEscapeHandling = StringEscapeHandling.Default,
CheckAdditionalContent = false,
DateFormatString = "yyyy'-'MM'-'dd'T'HH':'mm':'ss.FFFFFFFK",
Converters = converters.ToList(),
ReferenceResolverProvider = null,
Context = default,
Culture = CultureInfo.InvariantCulture,
MaxDepth = 4096,
DefaultValueHandling = DefaultValueHandling.Include,
};
}
/// <summary>
/// Gets the instance of JsonSerializerSettings to use as the default.
/// </summary>
public JsonSerializerSettings Instance { get; }
}
}