1
- using RestSharp . Extensions ;
2
- using System ;
1
+ using System ;
3
2
using System . Collections ;
4
3
using System . Collections . Generic ;
5
4
using System . Globalization ;
6
5
using System . Linq ;
7
6
using System . Reflection ;
7
+ using RestSharp . Extensions ;
8
8
9
9
namespace RestSharp . Deserializers
10
10
{
@@ -68,7 +68,7 @@ private object Map(object target, IDictionary<string, object> data)
68
68
69
69
if ( attributes . Length > 0 )
70
70
{
71
- DeserializeAsAttribute attribute = ( DeserializeAsAttribute ) attributes [ 0 ] ;
71
+ DeserializeAsAttribute attribute = ( DeserializeAsAttribute ) attributes [ 0 ] ;
72
72
name = attribute . Name ;
73
73
}
74
74
else
@@ -96,7 +96,7 @@ private object Map(object target, IDictionary<string, object> data)
96
96
}
97
97
else
98
98
{
99
- currentData = ( IDictionary < string , object > ) currentData [ actualName ] ;
99
+ currentData = ( IDictionary < string , object > ) currentData [ actualName ] ;
100
100
}
101
101
}
102
102
@@ -111,11 +111,11 @@ private object Map(object target, IDictionary<string, object> data)
111
111
112
112
private IDictionary BuildDictionary ( Type type , object parent )
113
113
{
114
- IDictionary dict = ( IDictionary ) Activator . CreateInstance ( type ) ;
114
+ IDictionary dict = ( IDictionary ) Activator . CreateInstance ( type ) ;
115
115
Type keyType = type . GetGenericArguments ( ) [ 0 ] ;
116
116
Type valueType = type . GetGenericArguments ( ) [ 1 ] ;
117
117
118
- foreach ( KeyValuePair < string , object > child in ( IDictionary < string , object > ) parent )
118
+ foreach ( KeyValuePair < string , object > child in ( IDictionary < string , object > ) parent )
119
119
{
120
120
object key = keyType != typeof ( string )
121
121
? Convert . ChangeType ( child . Key , keyType , CultureInfo . InvariantCulture )
@@ -140,15 +140,15 @@ private IDictionary BuildDictionary(Type type, object parent)
140
140
141
141
private IList BuildList ( Type type , object parent )
142
142
{
143
- IList list = ( IList ) Activator . CreateInstance ( type ) ;
143
+ IList list = ( IList ) Activator . CreateInstance ( type ) ;
144
144
Type listType = type . GetInterfaces ( )
145
145
. First
146
146
( x => x . IsGenericType && x . GetGenericTypeDefinition ( ) == typeof ( IList < > ) ) ;
147
147
Type itemType = listType . GetGenericArguments ( ) [ 0 ] ;
148
148
149
149
if ( parent is IList )
150
150
{
151
- foreach ( object element in ( IList ) parent )
151
+ foreach ( object element in ( IList ) parent )
152
152
{
153
153
if ( itemType . IsPrimitive )
154
154
{
@@ -251,14 +251,14 @@ private object ConvertValue(Type type, object value)
251
251
252
252
if ( type == typeof ( DateTimeOffset ) )
253
253
{
254
- return ( DateTimeOffset ) dt ;
254
+ return ( DateTimeOffset ) dt ;
255
255
}
256
256
}
257
257
else if ( type == typeof ( decimal ) )
258
258
{
259
259
if ( value is double )
260
260
{
261
- return ( decimal ) ( ( double ) value ) ;
261
+ return ( decimal ) ( ( double ) value ) ;
262
262
}
263
263
264
264
if ( stringValue . Contains ( "e" ) )
@@ -310,7 +310,7 @@ private object ConvertValue(Type type, object value)
310
310
}
311
311
else if ( type == typeof ( JsonObject ) )
312
312
{
313
- // simplify JsonObject into a Dictionary<string, object>
313
+ // simplify JsonObject into a Dictionary<string, object>
314
314
return this . BuildDictionary ( typeof ( Dictionary < string , object > ) , value ) ;
315
315
}
316
316
else
@@ -326,9 +326,9 @@ private object CreateAndMap(Type type, object element)
326
326
{
327
327
object instance = Activator . CreateInstance ( type ) ;
328
328
329
- this . Map ( instance , ( IDictionary < string , object > ) element ) ;
329
+ this . Map ( instance , ( IDictionary < string , object > ) element ) ;
330
330
331
331
return instance ;
332
332
}
333
333
}
334
- }
334
+ }
0 commit comments