Json.NET
Code Coverage Statistics for Source File

Newtonsoft.Json\JsonSerializerSettings.cs

Symbol Coverage: 100.00% (13 of 13)

Branch Coverage: 93.55% (29 of 31)

Cyclomatic Complexity Avg: 1.00 Max:1

Code Lines: 13


L V Source
1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Runtime.Serialization.Formatters;
5
using System.Text;
6
using Newtonsoft.Json.Serialization;
7
using Newtonsoft.Json.Utilities;
8
using System.Runtime.Serialization;
9

  
10
namespace Newtonsoft.Json
11
{
12
  /// <summary>
13
  /// Specifies the settings on a <see cref="JsonSerializer"/> object.
14
  /// </summary>
15
  public class JsonSerializerSettings
16
  {
17
    internal const ReferenceLoopHandling DefaultReferenceLoopHandling = ReferenceLoopHandling.Error;
18
    internal const MissingMemberHandling DefaultMissingMemberHandling = MissingMemberHandling.Ignore;
19
    internal const NullValueHandling DefaultNullValueHandling = NullValueHandling.Include;
20
    internal const DefaultValueHandling DefaultDefaultValueHandling = DefaultValueHandling.Include;
21
    internal const ObjectCreationHandling DefaultObjectCreationHandling = ObjectCreationHandling.Auto;
22
    internal const PreserveReferencesHandling DefaultPreserveReferencesHandling = PreserveReferencesHandling.None;
23
    internal const ConstructorHandling DefaultConstructorHandling = ConstructorHandling.Default;
24
    internal const TypeNameHandling DefaultTypeNameHandling = TypeNameHandling.None;
25
    internal const FormatterAssemblyStyle DefaultTypeNameAssemblyFormat = FormatterAssemblyStyle.Simple;
26
 1
    internal static readonly StreamingContext DefaultContext = new StreamingContext();
27

  
28
    /// <summary>
29
    /// Gets or sets how reference loops (e.g. a class referencing itself) is handled.
30
    /// </summary>
31
    /// <value>Reference loop handling.</value>
32
    public ReferenceLoopHandling ReferenceLoopHandling { get; set; }
33

  
34
    /// <summary>
35
    /// Gets or sets how missing members (e.g. JSON contains a property that isn't a member on the object) are handled during deserialization.
36
    /// </summary>
37
    /// <value>Missing member handling.</value>
38
    public MissingMemberHandling MissingMemberHandling { get; set; }
39

  
40
    /// <summary>
41
    /// Gets or sets how objects are created during deserialization.
42
    /// </summary>
43
    /// <value>The object creation handling.</value>
44
    public ObjectCreationHandling ObjectCreationHandling { get; set; }
45

  
46
    /// <summary>
47
    /// Gets or sets how null values are handled during serialization and deserialization.
48
    /// </summary>
49
    /// <value>Null value handling.</value>
50
    public NullValueHandling NullValueHandling { get; set; }
51

  
52
    /// <summary>
53
    /// Gets or sets how null default are handled during serialization and deserialization.
54
    /// </summary>
55
    /// <value>The default value handling.</value>
56
    public DefaultValueHandling DefaultValueHandling { get; set; }
57

  
58
    /// <summary>
59
    /// Gets or sets a collection <see cref="JsonConverter"/> that will be used during serialization.
60
    /// </summary>
61
    /// <value>The converters.</value>
62
    public IList<JsonConverter> Converters { get; set; }
63

  
64
    /// <summary>
65
    /// Gets or sets how object references are preserved by the serializer.
66
    /// </summary>
67
    /// <value>The preserve references handling.</value>
68
    public PreserveReferencesHandling PreserveReferencesHandling { get; set; }
69

  
70
    /// <summary>
71
    /// Gets or sets how type name writing and reading is handled by the serializer.
72
    /// </summary>
73
    /// <value>The type name handling.</value>
74
    public TypeNameHandling TypeNameHandling { get; set; }
75

  
76
    /// <summary>
77
    /// Gets or sets how a type name assembly is written and resolved by the serializer.
78
    /// </summary>
79
    /// <value>The type name assembly format.</value>
80
    public FormatterAssemblyStyle TypeNameAssemblyFormat { get; set; }
81

  
82
    /// <summary>
83
    /// Gets or sets how constructors are used during deserialization.
84
    /// </summary>
85
    /// <value>The constructor handling.</value>
86
    public ConstructorHandling ConstructorHandling { get; set; }
87

  
88
    /// <summary>
89
    /// Gets or sets the contract resolver used by the serializer when
90
    /// serializing .NET objects to JSON and vice versa.
91
    /// </summary>
92
    /// <value>The contract resolver.</value>
93
    public IContractResolver ContractResolver { get; set; }
94

  
95
    /// <summary>
96
    /// Gets or sets the <see cref="IReferenceResolver"/> used by the serializer when resolving references.
97
    /// </summary>
98
    /// <value>The reference resolver.</value>
99
    public IReferenceResolver ReferenceResolver { get; set; }
100

  
101
    /// <summary>
102
    /// Gets or sets the <see cref="SerializationBinder"/> used by the serializer when resolving type names.
103
    /// </summary>
104
    /// <value>The binder.</value>
105
    public SerializationBinder Binder { get; set; }
106

  
107
    /// <summary>
108
    /// Gets or sets the error handler called during serialization and deserialization.
109
    /// </summary>
110
    /// <value>The error handler called during serialization and deserialization.</value>
111
    public EventHandler<ErrorEventArgs> Error { get; set; }
112

  
113
    /// <summary>
114
    /// Gets or sets the <see cref="StreamingContext"/> used by the serializer when invoking serialization callback methods.
115
    /// </summary>
116
    /// <value>The context.</value>
117
    public StreamingContext Context { get; set; }
118

  
119
    /// <summary>
120
    /// Initializes a new instance of the <see cref="JsonSerializerSettings"/> class.
121
    /// </summary>
122
 171
    public JsonSerializerSettings()
123
    {
124
 171
      ReferenceLoopHandling = DefaultReferenceLoopHandling;
125
 171
      MissingMemberHandling = DefaultMissingMemberHandling;
126
 171
      ObjectCreationHandling = DefaultObjectCreationHandling;
127
 171
      NullValueHandling = DefaultNullValueHandling;
128
 171
      DefaultValueHandling = DefaultDefaultValueHandling;
129
 171
      PreserveReferencesHandling = DefaultPreserveReferencesHandling;
130
 171
      TypeNameHandling = DefaultTypeNameHandling;
131
 171
      TypeNameAssemblyFormat = DefaultTypeNameAssemblyFormat;
132
 171
      Context = DefaultContext;
133
 171
      Converters = new List<JsonConverter>();
134
 171
    }
135
  }
136
}