using System; using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization.Formatters; using System.Text; using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Utilities; using System.Runtime.Serialization; namespace Newtonsoft.Json { /// /// Specifies the settings on a object. /// public class JsonSerializerSettings { internal const ReferenceLoopHandling DefaultReferenceLoopHandling = ReferenceLoopHandling.Error; internal const MissingMemberHandling DefaultMissingMemberHandling = MissingMemberHandling.Ignore; internal const NullValueHandling DefaultNullValueHandling = NullValueHandling.Include; internal const DefaultValueHandling DefaultDefaultValueHandling = DefaultValueHandling.Include; internal const ObjectCreationHandling DefaultObjectCreationHandling = ObjectCreationHandling.Auto; internal const PreserveReferencesHandling DefaultPreserveReferencesHandling = PreserveReferencesHandling.None; internal const ConstructorHandling DefaultConstructorHandling = ConstructorHandling.Default; internal const TypeNameHandling DefaultTypeNameHandling = TypeNameHandling.None; internal const FormatterAssemblyStyle DefaultTypeNameAssemblyFormat = FormatterAssemblyStyle.Simple; internal static readonly StreamingContext DefaultContext = new StreamingContext(); /// /// Gets or sets how reference loops (e.g. a class referencing itself) is handled. /// /// Reference loop handling. public ReferenceLoopHandling ReferenceLoopHandling { get; set; } /// /// Gets or sets how missing members (e.g. JSON contains a property that isn't a member on the object) are handled during deserialization. /// /// Missing member handling. public MissingMemberHandling MissingMemberHandling { get; set; } /// /// Gets or sets how objects are created during deserialization. /// /// The object creation handling. public ObjectCreationHandling ObjectCreationHandling { get; set; } /// /// Gets or sets how null values are handled during serialization and deserialization. /// /// Null value handling. public NullValueHandling NullValueHandling { get; set; } /// /// Gets or sets how null default are handled during serialization and deserialization. /// /// The default value handling. public DefaultValueHandling DefaultValueHandling { get; set; } /// /// Gets or sets a collection that will be used during serialization. /// /// The converters. public IList Converters { get; set; } /// /// Gets or sets how object references are preserved by the serializer. /// /// The preserve references handling. public PreserveReferencesHandling PreserveReferencesHandling { get; set; } /// /// Gets or sets how type name writing and reading is handled by the serializer. /// /// The type name handling. public TypeNameHandling TypeNameHandling { get; set; } /// /// Gets or sets how a type name assembly is written and resolved by the serializer. /// /// The type name assembly format. public FormatterAssemblyStyle TypeNameAssemblyFormat { get; set; } /// /// Gets or sets how constructors are used during deserialization. /// /// The constructor handling. public ConstructorHandling ConstructorHandling { get; set; } /// /// Gets or sets the contract resolver used by the serializer when /// serializing .NET objects to JSON and vice versa. /// /// The contract resolver. public IContractResolver ContractResolver { get; set; } /// /// Gets or sets the used by the serializer when resolving references. /// /// The reference resolver. public IReferenceResolver ReferenceResolver { get; set; } /// /// Gets or sets the used by the serializer when resolving type names. /// /// The binder. public SerializationBinder Binder { get; set; } /// /// Gets or sets the error handler called during serialization and deserialization. /// /// The error handler called during serialization and deserialization. public EventHandler Error { get; set; } /// /// Gets or sets the used by the serializer when invoking serialization callback methods. /// /// The context. public StreamingContext Context { get; set; } /// /// Initializes a new instance of the class. /// public JsonSerializerSettings() { ReferenceLoopHandling = DefaultReferenceLoopHandling; MissingMemberHandling = DefaultMissingMemberHandling; ObjectCreationHandling = DefaultObjectCreationHandling; NullValueHandling = DefaultNullValueHandling; DefaultValueHandling = DefaultDefaultValueHandling; PreserveReferencesHandling = DefaultPreserveReferencesHandling; TypeNameHandling = DefaultTypeNameHandling; TypeNameAssemblyFormat = DefaultTypeNameAssemblyFormat; Context = DefaultContext; Converters = new List(); } } }