using System;
using DPumpHydr.WinFrmUI.WenSkin.Json.Utilities;
namespace DPumpHydr.WinFrmUI.WenSkin.Json.Serialization
{
///
/// Maps a JSON property to a .NET member or constructor parameter.
///
public class JsonProperty
{
internal Required? _required;
internal bool _hasExplicitDefaultValue;
private object _defaultValue;
private bool _hasGeneratedDefaultValue;
private string _propertyName;
internal bool _skipPropertyNameEscape;
private Type _propertyType;
internal JsonContract PropertyContract { get; set; }
///
/// Gets or sets the name of the property.
///
/// The name of the property.
public string PropertyName
{
get
{
return _propertyName;
}
set
{
_propertyName = value;
_skipPropertyNameEscape = !JavaScriptUtils.ShouldEscapeJavaScriptString(_propertyName, JavaScriptUtils.HtmlCharEscapeFlags);
}
}
///
/// Gets or sets the type that declared this property.
///
/// The type that declared this property.
public Type DeclaringType { get; set; }
///
/// Gets or sets the order of serialization of a member.
///
/// The numeric order of serialization.
public int? Order { get; set; }
///
/// Gets or sets the name of the underlying member or parameter.
///
/// The name of the underlying member or parameter.
public string UnderlyingName { get; set; }
///
/// Gets the that will get and set the during serialization.
///
/// The that will get and set the during serialization.
public IValueProvider ValueProvider { get; set; }
///
/// Gets or sets the for this property.
///
/// The for this property.
public IAttributeProvider AttributeProvider { get; set; }
///
/// Gets or sets the type of the property.
///
/// The type of the property.
public Type PropertyType
{
get
{
return _propertyType;
}
set
{
if (_propertyType != value)
{
_propertyType = value;
_hasGeneratedDefaultValue = false;
}
}
}
///
/// Gets or sets the for the property.
/// If set this converter takes presidence over the contract converter for the property type.
///
/// The converter.
public JsonConverter Converter { get; set; }
///
/// Gets or sets the member converter.
///
/// The member converter.
public JsonConverter MemberConverter { get; set; }
///
/// Gets or sets a value indicating whether this is ignored.
///
/// true if ignored; otherwise, false.
public bool Ignored { get; set; }
///
/// Gets or sets a value indicating whether this is readable.
///
/// true if readable; otherwise, false.
public bool Readable { get; set; }
///
/// Gets or sets a value indicating whether this is writable.
///
/// true if writable; otherwise, false.
public bool Writable { get; set; }
///
/// Gets or sets a value indicating whether this has a member attribute.
///
/// true if has a member attribute; otherwise, false.
public bool HasMemberAttribute { get; set; }
///
/// Gets the default value.
///
/// The default value.
public object DefaultValue
{
get
{
if (!_hasExplicitDefaultValue)
{
return null;
}
return _defaultValue;
}
set
{
_hasExplicitDefaultValue = true;
_defaultValue = value;
}
}
///
/// Gets or sets a value indicating whether this is required.
///
/// A value indicating whether this is required.
public Required Required
{
get
{
return _required ?? Required.Default;
}
set
{
_required = value;
}
}
///
/// Gets or sets a value indicating whether this property preserves object references.
///
///
/// true if this instance is reference; otherwise, false.
///
public bool? IsReference { get; set; }
///
/// Gets or sets the property null value handling.
///
/// The null value handling.
public NullValueHandling? NullValueHandling { get; set; }
///
/// Gets or sets the property default value handling.
///
/// The default value handling.
public DefaultValueHandling? DefaultValueHandling { get; set; }
///
/// Gets or sets the property reference loop handling.
///
/// The reference loop handling.
public ReferenceLoopHandling? ReferenceLoopHandling { get; set; }
///
/// Gets or sets the property object creation handling.
///
/// The object creation handling.
public ObjectCreationHandling? ObjectCreationHandling { get; set; }
///
/// Gets or sets or sets the type name handling.
///
/// The type name handling.
public TypeNameHandling? TypeNameHandling { get; set; }
///
/// Gets or sets a predicate used to determine whether the property should be serialize.
///
/// A predicate used to determine whether the property should be serialize.
public Predicate