~ubuntu-branches/ubuntu/trusty/smuxi/trusty-proposed

« back to all changes in this revision

Viewing changes to lib/Newtonsoft.Json/Src/Newtonsoft.Json/Serialization/JsonProperty.cs

  • Committer: Package Import Robot
  • Author(s): Mirco Bauer
  • Date: 2013-05-25 22:11:31 UTC
  • mfrom: (1.2.12)
  • Revision ID: package-import@ubuntu.com-20130525221131-nd2mc0kzubuwyx20
Tags: 0.8.11-1
* [22d13d5] Imported Upstream version 0.8.11
* [6d2b95a] Refreshed patches
* [89eb66e] Added ServiceStack libraries to smuxi-engine package
* [848ab10] Enable Campfire engine
* [c6dbdc7] Always build db4o for predictable build result
* [13ec489] Exclude OS X specific libraries from dh_clideps

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#region License
2
 
// Copyright (c) 2007 James Newton-King
3
 
//
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
11
 
// conditions:
12
 
//
13
 
// The above copyright notice and this permission notice shall be
14
 
// included in all copies or substantial portions of the Software.
15
 
//
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.
24
 
#endregion
25
 
 
26
 
using System;
27
 
 
28
 
namespace Newtonsoft.Json.Serialization
29
 
{
30
 
  /// <summary>
31
 
  /// Maps a JSON property to a .NET member.
32
 
  /// </summary>
33
 
  public class JsonProperty
34
 
  {
35
 
    /// <summary>
36
 
    /// Gets the name of the property.
37
 
    /// </summary>
38
 
    /// <value>The name of the property.</value>
39
 
    public string PropertyName { get; set; }
40
 
 
41
 
    /// <summary>
42
 
    /// Gets the <see cref="IValueProvider"/> that will get and set the <see cref="JsonProperty"/> during serialization.
43
 
    /// </summary>
44
 
    /// <value>The <see cref="IValueProvider"/> that will get and set the <see cref="JsonProperty"/> during serialization.</value>
45
 
    public IValueProvider ValueProvider { get; set; }
46
 
 
47
 
    /// <summary>
48
 
    /// Gets or sets the type of the property.
49
 
    /// </summary>
50
 
    /// <value>The type of the property.</value>
51
 
    public Type PropertyType { get; set; }
52
 
 
53
 
    /// <summary>
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.
56
 
    /// </summary>
57
 
    /// <value>The converter.</value>
58
 
    public JsonConverter Converter { get; set; }
59
 
 
60
 
    /// <summary>
61
 
    /// Gets a value indicating whether this <see cref="JsonProperty"/> is ignored.
62
 
    /// </summary>
63
 
    /// <value><c>true</c> if ignored; otherwise, <c>false</c>.</value>
64
 
    public bool Ignored { get; set; }
65
 
 
66
 
    /// <summary>
67
 
    /// Gets a value indicating whether this <see cref="JsonProperty"/> is readable.
68
 
    /// </summary>
69
 
    /// <value><c>true</c> if readable; otherwise, <c>false</c>.</value>
70
 
    public bool Readable { get; set; }
71
 
 
72
 
    /// <summary>
73
 
    /// Gets a value indicating whether this <see cref="JsonProperty"/> is writable.
74
 
    /// </summary>
75
 
    /// <value><c>true</c> if writable; otherwise, <c>false</c>.</value>
76
 
    public bool Writable { get; set; }
77
 
 
78
 
    /// <summary>
79
 
    /// Gets the member converter.
80
 
    /// </summary>
81
 
    /// <value>The member converter.</value>
82
 
    public JsonConverter MemberConverter { get; set; }
83
 
 
84
 
    /// <summary>
85
 
    /// Gets the default value.
86
 
    /// </summary>
87
 
    /// <value>The default value.</value>
88
 
    public object DefaultValue { get; set; }
89
 
 
90
 
    /// <summary>
91
 
    /// Gets a value indicating whether this <see cref="JsonProperty"/> is required.
92
 
    /// </summary>
93
 
    /// <value>A value indicating whether this <see cref="JsonProperty"/> is required.</value>
94
 
    public Required Required { get; set; }
95
 
 
96
 
    /// <summary>
97
 
    /// Gets a value indicating whether this property preserves object references.
98
 
    /// </summary>
99
 
    /// <value>
100
 
    ///         <c>true</c> if this instance is reference; otherwise, <c>false</c>.
101
 
    /// </value>
102
 
    public bool? IsReference { get; set; }
103
 
 
104
 
    /// <summary>
105
 
    /// Gets the property null value handling.
106
 
    /// </summary>
107
 
    /// <value>The null value handling.</value>
108
 
    public NullValueHandling? NullValueHandling { get; set; }
109
 
 
110
 
    /// <summary>
111
 
    /// Gets the property default value handling.
112
 
    /// </summary>
113
 
    /// <value>The default value handling.</value>
114
 
    public DefaultValueHandling? DefaultValueHandling { get; set; }
115
 
 
116
 
    /// <summary>
117
 
    /// Gets the property reference loop handling.
118
 
    /// </summary>
119
 
    /// <value>The reference loop handling.</value>
120
 
    public ReferenceLoopHandling? ReferenceLoopHandling { get; set; }
121
 
 
122
 
    /// <summary>
123
 
    /// Gets the property object creation handling.
124
 
    /// </summary>
125
 
    /// <value>The object creation handling.</value>
126
 
    public ObjectCreationHandling? ObjectCreationHandling { get; set; }
127
 
 
128
 
    /// <summary>
129
 
    /// Gets or sets the type name handling.
130
 
    /// </summary>
131
 
    /// <value>The type name handling.</value>
132
 
    public TypeNameHandling? TypeNameHandling { get; set; }
133
 
 
134
 
    /// <summary>
135
 
    /// Gets or sets a predicate used to determine whether the property should be serialize.
136
 
    /// </summary>
137
 
    /// <value>A predicate used to determine whether the property should be serialize.</value>
138
 
    public Predicate<object> ShouldSerialize { get; set; }
139
 
 
140
 
    /// <summary>
141
 
    /// Returns a <see cref="String"/> that represents this instance.
142
 
    /// </summary>
143
 
    /// <returns>
144
 
    /// A <see cref="String"/> that represents this instance.
145
 
    /// </returns>
146
 
    public override string ToString()
147
 
    {
148
 
      return PropertyName;
149
 
    }
150
 
  }
 
1
#region License
 
2
// Copyright (c) 2007 James Newton-King
 
3
//
 
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
 
11
// conditions:
 
12
//
 
13
// The above copyright notice and this permission notice shall be
 
14
// included in all copies or substantial portions of the Software.
 
15
//
 
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.
 
24
#endregion
 
25
 
 
26
using System;
 
27
#if NET20
 
28
using Newtonsoft.Json.Utilities.LinqBridge;
 
29
#endif
 
30
 
 
31
namespace Newtonsoft.Json.Serialization
 
32
{
 
33
  /// <summary>
 
34
  /// Maps a JSON property to a .NET member or constructor parameter.
 
35
  /// </summary>
 
36
  public class JsonProperty
 
37
  {
 
38
    internal Required? _required;
 
39
 
 
40
    // use to cache contract during deserialization
 
41
    internal JsonContract PropertyContract { get; set; }
 
42
    
 
43
    /// <summary>
 
44
    /// Gets or sets the name of the property.
 
45
    /// </summary>
 
46
    /// <value>The name of the property.</value>
 
47
    public string PropertyName { get; set; }
 
48
 
 
49
    /// <summary>
 
50
    /// Gets or sets the type that declared this property.
 
51
    /// </summary>
 
52
    /// <value>The type that declared this property.</value>
 
53
    public Type DeclaringType { get; set; }
 
54
 
 
55
    /// <summary>
 
56
    /// Gets or sets the order of serialization and deserialization of a member.
 
57
    /// </summary>
 
58
    /// <value>The numeric order of serialization or deserialization.</value>
 
59
    public int? Order { get; set; }
 
60
 
 
61
    /// <summary>
 
62
    /// Gets or sets the name of the underlying member or parameter.
 
63
    /// </summary>
 
64
    /// <value>The name of the underlying member or parameter.</value>
 
65
    public string UnderlyingName { get; set; }
 
66
 
 
67
    /// <summary>
 
68
    /// Gets the <see cref="IValueProvider"/> that will get and set the <see cref="JsonProperty"/> during serialization.
 
69
    /// </summary>
 
70
    /// <value>The <see cref="IValueProvider"/> that will get and set the <see cref="JsonProperty"/> during serialization.</value>
 
71
    public IValueProvider ValueProvider { get; set; }
 
72
 
 
73
    /// <summary>
 
74
    /// Gets or sets the type of the property.
 
75
    /// </summary>
 
76
    /// <value>The type of the property.</value>
 
77
    public Type PropertyType { get; set; }
 
78
 
 
79
    /// <summary>
 
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.
 
82
    /// </summary>
 
83
    /// <value>The converter.</value>
 
84
    public JsonConverter Converter { get; set; }
 
85
 
 
86
    /// <summary>
 
87
    /// Gets the member converter.
 
88
    /// </summary>
 
89
    /// <value>The member converter.</value>
 
90
    public JsonConverter MemberConverter { get; set; }
 
91
 
 
92
    /// <summary>
 
93
    /// Gets a value indicating whether this <see cref="JsonProperty"/> is ignored.
 
94
    /// </summary>
 
95
    /// <value><c>true</c> if ignored; otherwise, <c>false</c>.</value>
 
96
    public bool Ignored { get; set; }
 
97
 
 
98
    /// <summary>
 
99
    /// Gets a value indicating whether this <see cref="JsonProperty"/> is readable.
 
100
    /// </summary>
 
101
    /// <value><c>true</c> if readable; otherwise, <c>false</c>.</value>
 
102
    public bool Readable { get; set; }
 
103
 
 
104
    /// <summary>
 
105
    /// Gets a value indicating whether this <see cref="JsonProperty"/> is writable.
 
106
    /// </summary>
 
107
    /// <value><c>true</c> if writable; otherwise, <c>false</c>.</value>
 
108
    public bool Writable { get; set; }
 
109
 
 
110
    /// <summary>
 
111
    /// Gets a value indicating whether this <see cref="JsonProperty"/> has a member attribute.
 
112
    /// </summary>
 
113
    /// <value><c>true</c> if has a member attribute; otherwise, <c>false</c>.</value>
 
114
    public bool HasMemberAttribute { get; set; }
 
115
 
 
116
    /// <summary>
 
117
    /// Gets the default value.
 
118
    /// </summary>
 
119
    /// <value>The default value.</value>
 
120
    public object DefaultValue { get; set; }
 
121
 
 
122
    /// <summary>
 
123
    /// Gets a value indicating whether this <see cref="JsonProperty"/> is required.
 
124
    /// </summary>
 
125
    /// <value>A value indicating whether this <see cref="JsonProperty"/> is required.</value>
 
126
    public Required Required
 
127
    {
 
128
      get { return _required ?? Required.Default; }
 
129
      set { _required = value; }
 
130
    }
 
131
 
 
132
    /// <summary>
 
133
    /// Gets a value indicating whether this property preserves object references.
 
134
    /// </summary>
 
135
    /// <value>
 
136
    ///         <c>true</c> if this instance is reference; otherwise, <c>false</c>.
 
137
    /// </value>
 
138
    public bool? IsReference { get; set; }
 
139
 
 
140
    /// <summary>
 
141
    /// Gets the property null value handling.
 
142
    /// </summary>
 
143
    /// <value>The null value handling.</value>
 
144
    public NullValueHandling? NullValueHandling { get; set; }
 
145
 
 
146
    /// <summary>
 
147
    /// Gets the property default value handling.
 
148
    /// </summary>
 
149
    /// <value>The default value handling.</value>
 
150
    public DefaultValueHandling? DefaultValueHandling { get; set; }
 
151
 
 
152
    /// <summary>
 
153
    /// Gets the property reference loop handling.
 
154
    /// </summary>
 
155
    /// <value>The reference loop handling.</value>
 
156
    public ReferenceLoopHandling? ReferenceLoopHandling { get; set; }
 
157
 
 
158
    /// <summary>
 
159
    /// Gets the property object creation handling.
 
160
    /// </summary>
 
161
    /// <value>The object creation handling.</value>
 
162
    public ObjectCreationHandling? ObjectCreationHandling { get; set; }
 
163
 
 
164
    /// <summary>
 
165
    /// Gets or sets the type name handling.
 
166
    /// </summary>
 
167
    /// <value>The type name handling.</value>
 
168
    public TypeNameHandling? TypeNameHandling { get; set; }
 
169
 
 
170
    /// <summary>
 
171
    /// Gets or sets a predicate used to determine whether the property should be serialize.
 
172
    /// </summary>
 
173
    /// <value>A predicate used to determine whether the property should be serialize.</value>
 
174
    public Predicate<object> ShouldSerialize { get; set; }
 
175
 
 
176
    /// <summary>
 
177
    /// Gets or sets a predicate used to determine whether the property should be serialized.
 
178
    /// </summary>
 
179
    /// <value>A predicate used to determine whether the property should be serialized.</value>
 
180
    public Predicate<object> GetIsSpecified { get; set; }
 
181
 
 
182
    /// <summary>
 
183
    /// Gets or sets an action used to set whether the property has been deserialized.
 
184
    /// </summary>
 
185
    /// <value>An action used to set whether the property has been deserialized.</value>
 
186
    public Action<object, object> SetIsSpecified { get; set; }
 
187
 
 
188
    /// <summary>
 
189
    /// Returns a <see cref="String"/> that represents this instance.
 
190
    /// </summary>
 
191
    /// <returns>
 
192
    /// A <see cref="String"/> that represents this instance.
 
193
    /// </returns>
 
194
    public override string ToString()
 
195
    {
 
196
      return PropertyName;
 
197
    }
 
198
 
 
199
    /// <summary>
 
200
    /// Gets or sets the converter used when serializing the property's collection items.
 
201
    /// </summary>
 
202
    /// <value>The collection's items converter.</value>
 
203
    public JsonConverter ItemConverter { get; set; }
 
204
 
 
205
    /// <summary>
 
206
    /// Gets or sets whether this property's collection items are serialized as a reference.
 
207
    /// </summary>
 
208
    /// <value>Whether this property's collection items are serialized as a reference.</value>
 
209
    public bool? ItemIsReference { get; set; }
 
210
 
 
211
    /// <summary>
 
212
    /// Gets or sets the the type name handling used when serializing the property's collection items.
 
213
    /// </summary>
 
214
    /// <value>The collection's items type name handling.</value>
 
215
    public TypeNameHandling? ItemTypeNameHandling { get; set; }
 
216
 
 
217
    /// <summary>
 
218
    /// Gets or sets the the reference loop handling used when serializing the property's collection items.
 
219
    /// </summary>
 
220
    /// <value>The collection's items reference loop handling.</value>
 
221
    public ReferenceLoopHandling? ItemReferenceLoopHandling { get; set; }
 
222
  }
151
223
}
 
 
b'\\ No newline at end of file'