-Added even more detail to no root XML element exception message when converting JSON to XML. Seriously, if you still get stuck here you're an idiot
-Added NullValueHandling, DefaultValueHandling and ReferenceLoopHandling to JsonPropertyAttribute -Change JsonMemberMapping from a struct to a class. Now has too many properties for a struct
This commit is contained in:
@@ -8,24 +8,37 @@ namespace Newtonsoft.Json
|
||||
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = false)]
|
||||
public sealed class JsonPropertyAttribute : Attribute
|
||||
{
|
||||
private string _propertyName;
|
||||
private bool _isRequired;
|
||||
// yuck. can't set nullable properties on an attribute in C#
|
||||
// have to use this approach to get an unset default state
|
||||
internal NullValueHandling? _nullValueHandling;
|
||||
internal DefaultValueHandling? _defaultValueHandling;
|
||||
internal ReferenceLoopHandling? _referenceLoopHandling;
|
||||
|
||||
public NullValueHandling NullValueHandling
|
||||
{
|
||||
get { return _nullValueHandling ?? default(NullValueHandling); }
|
||||
set { _nullValueHandling = value; }
|
||||
}
|
||||
|
||||
public DefaultValueHandling DefaultValueHandling
|
||||
{
|
||||
get { return _defaultValueHandling ?? default(DefaultValueHandling); }
|
||||
set { _defaultValueHandling = value; }
|
||||
}
|
||||
|
||||
public ReferenceLoopHandling ReferenceLoopHandling
|
||||
{
|
||||
get { return _referenceLoopHandling ?? default(ReferenceLoopHandling); }
|
||||
set { _referenceLoopHandling = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the property.
|
||||
/// </summary>
|
||||
/// <value>The name of the property.</value>
|
||||
public string PropertyName
|
||||
{
|
||||
get { return _propertyName; }
|
||||
set { _propertyName = value; }
|
||||
}
|
||||
public string PropertyName { get; set; }
|
||||
|
||||
public bool IsRequired
|
||||
{
|
||||
get { return _isRequired; }
|
||||
set { _isRequired = value; }
|
||||
}
|
||||
public bool IsRequired { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="JsonPropertyAttribute"/> class.
|
||||
@@ -40,7 +53,7 @@ namespace Newtonsoft.Json
|
||||
/// <param name="propertyName">Name of the property.</param>
|
||||
public JsonPropertyAttribute(string propertyName)
|
||||
{
|
||||
_propertyName = propertyName;
|
||||
PropertyName = propertyName;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user