7
7
8
8
namespace Newtonsoft . Json . Converters
9
9
{
10
+ /// <summary>
11
+ /// Converts a <see cref="KeyValuePair{TKey,TValue}"/> to and from JSON.
12
+ /// </summary>
10
13
public class KeyValuePairConverter : JsonConverter
11
14
{
15
+ /// <summary>
16
+ /// Writes the JSON representation of the object.
17
+ /// </summary>
18
+ /// <param name="writer">The <see cref="JsonWriter"/> to write to.</param>
19
+ /// <param name="value">The value.</param>
20
+ /// <param name="serializer">The calling serializer.</param>
12
21
public override void WriteJson ( JsonWriter writer , object value , JsonSerializer serializer )
13
22
{
14
23
Type t = value . GetType ( ) ;
@@ -23,6 +32,14 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s
23
32
writer . WriteEndObject ( ) ;
24
33
}
25
34
35
+ /// <summary>
36
+ /// Reads the JSON representation of the object.
37
+ /// </summary>
38
+ /// <param name="reader">The <see cref="JsonReader"/> to read from.</param>
39
+ /// <param name="objectType">Type of the object.</param>
40
+ /// <param name="existingValue">The existing value of object being read.</param>
41
+ /// <param name="serializer">The calling serializer.</param>
42
+ /// <returns>The object value.</returns>
26
43
public override object ReadJson ( JsonReader reader , Type objectType , object existingValue , JsonSerializer serializer )
27
44
{
28
45
IList < Type > genericArguments = objectType . GetGenericArguments ( ) ;
@@ -40,6 +57,13 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist
40
57
return ReflectionUtils . CreateInstance ( objectType , key , value ) ;
41
58
}
42
59
60
+ /// <summary>
61
+ /// Determines whether this instance can convert the specified object type.
62
+ /// </summary>
63
+ /// <param name="objectType">Type of the object.</param>
64
+ /// <returns>
65
+ /// <c>true</c> if this instance can convert the specified object type; otherwise, <c>false</c>.
66
+ /// </returns>
43
67
public override bool CanConvert ( Type objectType )
44
68
{
45
69
if ( objectType . IsValueType && objectType . IsGenericType )
0 commit comments