@@ -49,7 +49,7 @@ public T Deserialize<T>(IRestResponse response)
49
49
else
50
50
{
51
51
var root = FindRoot ( response . Content ) ;
52
- Map ( target , ( IDictionary < string , object > ) root ) ;
52
+ target = ( T ) Map ( target , ( IDictionary < string , object > ) root ) ;
53
53
}
54
54
55
55
return target ;
@@ -67,7 +67,7 @@ private object FindRoot(string content)
67
67
return data ;
68
68
}
69
69
70
- private void Map ( object target , IDictionary < string , object > data )
70
+ private object Map ( object target , IDictionary < string , object > data )
71
71
{
72
72
var objType = target . GetType ( ) ;
73
73
var props = objType . GetProperties ( ) . Where ( p => p . CanWrite ) . ToList ( ) ;
@@ -108,6 +108,8 @@ private void Map(object target, IDictionary<string, object> data)
108
108
if ( value != null )
109
109
prop . SetValue ( target , ConvertValue ( type , value ) , null ) ;
110
110
}
111
+
112
+ return target ;
111
113
}
112
114
113
115
private IDictionary BuildDictionary ( Type type , object parent )
@@ -204,23 +206,27 @@ private object ConvertValue(Type type, object value)
204
206
{
205
207
return value . ChangeType ( type , Culture ) ;
206
208
}
207
- else if ( type . IsEnum )
209
+
210
+ if ( type . IsEnum )
208
211
{
209
212
return type . FindEnumValue ( stringValue , Culture ) ;
210
213
}
211
- else if ( type == typeof ( Uri ) )
214
+
215
+ if ( type == typeof ( Uri ) )
212
216
{
213
217
return new Uri ( stringValue , UriKind . RelativeOrAbsolute ) ;
214
218
}
215
- else if ( type == typeof ( string ) )
219
+
220
+ if ( type == typeof ( string ) )
216
221
{
217
222
return stringValue ;
218
223
}
219
- else if ( type == typeof ( DateTime )
224
+
225
+ if ( type == typeof ( DateTime )
220
226
#if ! PocketPC
221
- || type == typeof ( DateTimeOffset )
227
+ || type == typeof ( DateTimeOffset )
222
228
#endif
223
- )
229
+ )
224
230
{
225
231
DateTime dt ;
226
232
@@ -241,7 +247,8 @@ private object ConvertValue(Type type, object value)
241
247
{
242
248
return dt ;
243
249
}
244
- else if ( type == typeof ( DateTimeOffset ) )
250
+
251
+ if ( type == typeof ( DateTimeOffset ) )
245
252
{
246
253
return ( DateTimeOffset ) dt ;
247
254
}
@@ -270,7 +277,8 @@ private object ConvertValue(Type type, object value)
270
277
{
271
278
return BuildList ( type , value ) ;
272
279
}
273
- else if ( genericTypeDef == typeof ( Dictionary < , > ) )
280
+
281
+ if ( genericTypeDef == typeof ( Dictionary < , > ) )
274
282
{
275
283
var keyType = type . GetGenericArguments ( ) [ 0 ] ;
276
284
0 commit comments