2
// Copyright (c) 2007 James Newton-King
4
// Permission is hereby granted, free of charge, to any person
5
// obtaining a copy of this software and associated documentation
6
// files (the "Software"), to deal in the Software without
7
// restriction, including without limitation the rights to use,
8
// copy, modify, merge, publish, distribute, sublicense, and/or sell
9
// copies of the Software, and to permit persons to whom the
10
// Software is furnished to do so, subject to the following
13
// The above copyright notice and this permission notice shall be
14
// included in all copies or substantial portions of the Software.
16
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23
// OTHER DEALINGS IN THE SOFTWARE.
28
namespace Newtonsoft.Json.Serialization
31
/// Maps a JSON property to a .NET member.
33
public class JsonProperty
36
/// Gets the name of the property.
38
/// <value>The name of the property.</value>
39
public string PropertyName { get; set; }
42
/// Gets the <see cref="IValueProvider"/> that will get and set the <see cref="JsonProperty"/> during serialization.
44
/// <value>The <see cref="IValueProvider"/> that will get and set the <see cref="JsonProperty"/> during serialization.</value>
45
public IValueProvider ValueProvider { get; set; }
48
/// Gets or sets the type of the property.
50
/// <value>The type of the property.</value>
51
public Type PropertyType { get; set; }
54
/// Gets or sets the <see cref="JsonConverter" /> for the property.
55
/// If set this converter takes presidence over the contract converter for the property type.
57
/// <value>The converter.</value>
58
public JsonConverter Converter { get; set; }
61
/// Gets a value indicating whether this <see cref="JsonProperty"/> is ignored.
63
/// <value><c>true</c> if ignored; otherwise, <c>false</c>.</value>
64
public bool Ignored { get; set; }
67
/// Gets a value indicating whether this <see cref="JsonProperty"/> is readable.
69
/// <value><c>true</c> if readable; otherwise, <c>false</c>.</value>
70
public bool Readable { get; set; }
73
/// Gets a value indicating whether this <see cref="JsonProperty"/> is writable.
75
/// <value><c>true</c> if writable; otherwise, <c>false</c>.</value>
76
public bool Writable { get; set; }
79
/// Gets the member converter.
81
/// <value>The member converter.</value>
82
public JsonConverter MemberConverter { get; set; }
85
/// Gets the default value.
87
/// <value>The default value.</value>
88
public object DefaultValue { get; set; }
91
/// Gets a value indicating whether this <see cref="JsonProperty"/> is required.
93
/// <value>A value indicating whether this <see cref="JsonProperty"/> is required.</value>
94
public Required Required { get; set; }
97
/// Gets a value indicating whether this property preserves object references.
100
/// <c>true</c> if this instance is reference; otherwise, <c>false</c>.
102
public bool? IsReference { get; set; }
105
/// Gets the property null value handling.
107
/// <value>The null value handling.</value>
108
public NullValueHandling? NullValueHandling { get; set; }
111
/// Gets the property default value handling.
113
/// <value>The default value handling.</value>
114
public DefaultValueHandling? DefaultValueHandling { get; set; }
117
/// Gets the property reference loop handling.
119
/// <value>The reference loop handling.</value>
120
public ReferenceLoopHandling? ReferenceLoopHandling { get; set; }
123
/// Gets the property object creation handling.
125
/// <value>The object creation handling.</value>
126
public ObjectCreationHandling? ObjectCreationHandling { get; set; }
129
/// Gets or sets the type name handling.
131
/// <value>The type name handling.</value>
132
public TypeNameHandling? TypeNameHandling { get; set; }
135
/// Gets or sets a predicate used to determine whether the property should be serialize.
137
/// <value>A predicate used to determine whether the property should be serialize.</value>
138
public Predicate<object> ShouldSerialize { get; set; }
141
/// Returns a <see cref="String"/> that represents this instance.
144
/// A <see cref="String"/> that represents this instance.
146
public override string ToString()
2
// Copyright (c) 2007 James Newton-King
4
// Permission is hereby granted, free of charge, to any person
5
// obtaining a copy of this software and associated documentation
6
// files (the "Software"), to deal in the Software without
7
// restriction, including without limitation the rights to use,
8
// copy, modify, merge, publish, distribute, sublicense, and/or sell
9
// copies of the Software, and to permit persons to whom the
10
// Software is furnished to do so, subject to the following
13
// The above copyright notice and this permission notice shall be
14
// included in all copies or substantial portions of the Software.
16
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23
// OTHER DEALINGS IN THE SOFTWARE.
28
using Newtonsoft.Json.Utilities.LinqBridge;
31
namespace Newtonsoft.Json.Serialization
34
/// Maps a JSON property to a .NET member or constructor parameter.
36
public class JsonProperty
38
internal Required? _required;
40
// use to cache contract during deserialization
41
internal JsonContract PropertyContract { get; set; }
44
/// Gets or sets the name of the property.
46
/// <value>The name of the property.</value>
47
public string PropertyName { get; set; }
50
/// Gets or sets the type that declared this property.
52
/// <value>The type that declared this property.</value>
53
public Type DeclaringType { get; set; }
56
/// Gets or sets the order of serialization and deserialization of a member.
58
/// <value>The numeric order of serialization or deserialization.</value>
59
public int? Order { get; set; }
62
/// Gets or sets the name of the underlying member or parameter.
64
/// <value>The name of the underlying member or parameter.</value>
65
public string UnderlyingName { get; set; }
68
/// Gets the <see cref="IValueProvider"/> that will get and set the <see cref="JsonProperty"/> during serialization.
70
/// <value>The <see cref="IValueProvider"/> that will get and set the <see cref="JsonProperty"/> during serialization.</value>
71
public IValueProvider ValueProvider { get; set; }
74
/// Gets or sets the type of the property.
76
/// <value>The type of the property.</value>
77
public Type PropertyType { get; set; }
80
/// Gets or sets the <see cref="JsonConverter" /> for the property.
81
/// If set this converter takes presidence over the contract converter for the property type.
83
/// <value>The converter.</value>
84
public JsonConverter Converter { get; set; }
87
/// Gets the member converter.
89
/// <value>The member converter.</value>
90
public JsonConverter MemberConverter { get; set; }
93
/// Gets a value indicating whether this <see cref="JsonProperty"/> is ignored.
95
/// <value><c>true</c> if ignored; otherwise, <c>false</c>.</value>
96
public bool Ignored { get; set; }
99
/// Gets a value indicating whether this <see cref="JsonProperty"/> is readable.
101
/// <value><c>true</c> if readable; otherwise, <c>false</c>.</value>
102
public bool Readable { get; set; }
105
/// Gets a value indicating whether this <see cref="JsonProperty"/> is writable.
107
/// <value><c>true</c> if writable; otherwise, <c>false</c>.</value>
108
public bool Writable { get; set; }
111
/// Gets a value indicating whether this <see cref="JsonProperty"/> has a member attribute.
113
/// <value><c>true</c> if has a member attribute; otherwise, <c>false</c>.</value>
114
public bool HasMemberAttribute { get; set; }
117
/// Gets the default value.
119
/// <value>The default value.</value>
120
public object DefaultValue { get; set; }
123
/// Gets a value indicating whether this <see cref="JsonProperty"/> is required.
125
/// <value>A value indicating whether this <see cref="JsonProperty"/> is required.</value>
126
public Required Required
128
get { return _required ?? Required.Default; }
129
set { _required = value; }
133
/// Gets a value indicating whether this property preserves object references.
136
/// <c>true</c> if this instance is reference; otherwise, <c>false</c>.
138
public bool? IsReference { get; set; }
141
/// Gets the property null value handling.
143
/// <value>The null value handling.</value>
144
public NullValueHandling? NullValueHandling { get; set; }
147
/// Gets the property default value handling.
149
/// <value>The default value handling.</value>
150
public DefaultValueHandling? DefaultValueHandling { get; set; }
153
/// Gets the property reference loop handling.
155
/// <value>The reference loop handling.</value>
156
public ReferenceLoopHandling? ReferenceLoopHandling { get; set; }
159
/// Gets the property object creation handling.
161
/// <value>The object creation handling.</value>
162
public ObjectCreationHandling? ObjectCreationHandling { get; set; }
165
/// Gets or sets the type name handling.
167
/// <value>The type name handling.</value>
168
public TypeNameHandling? TypeNameHandling { get; set; }
171
/// Gets or sets a predicate used to determine whether the property should be serialize.
173
/// <value>A predicate used to determine whether the property should be serialize.</value>
174
public Predicate<object> ShouldSerialize { get; set; }
177
/// Gets or sets a predicate used to determine whether the property should be serialized.
179
/// <value>A predicate used to determine whether the property should be serialized.</value>
180
public Predicate<object> GetIsSpecified { get; set; }
183
/// Gets or sets an action used to set whether the property has been deserialized.
185
/// <value>An action used to set whether the property has been deserialized.</value>
186
public Action<object, object> SetIsSpecified { get; set; }
189
/// Returns a <see cref="String"/> that represents this instance.
192
/// A <see cref="String"/> that represents this instance.
194
public override string ToString()
200
/// Gets or sets the converter used when serializing the property's collection items.
202
/// <value>The collection's items converter.</value>
203
public JsonConverter ItemConverter { get; set; }
206
/// Gets or sets whether this property's collection items are serialized as a reference.
208
/// <value>Whether this property's collection items are serialized as a reference.</value>
209
public bool? ItemIsReference { get; set; }
212
/// Gets or sets the the type name handling used when serializing the property's collection items.
214
/// <value>The collection's items type name handling.</value>
215
public TypeNameHandling? ItemTypeNameHandling { get; set; }
218
/// Gets or sets the the reference loop handling used when serializing the property's collection items.
220
/// <value>The collection's items reference loop handling.</value>
221
public ReferenceLoopHandling? ItemReferenceLoopHandling { get; set; }
b'\\ No newline at end of file'