Skip to content

Commit 98863df

Browse files
committed
Undo cosmetic changes
1 parent b215a4e commit 98863df

File tree

2 files changed

+26
-25
lines changed

2 files changed

+26
-25
lines changed

RestSharp.Tests/JsonTests.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@
1212
// distributed under the License is distributed on an "AS IS" BASIS,
1313
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1414
// See the License for the specific language governing permissions and
15-
// limitations under the License.
15+
// limitations under the License.
1616

17-
#endregion License
17+
#endregion
1818

19-
using NUnit.Framework;
20-
using RestSharp.Deserializers;
21-
using RestSharp.Tests.SampleClasses;
2219
using System;
2320
using System.Collections;
2421
using System.Collections.Generic;
2522
using System.Globalization;
2623
using System.IO;
2724
using System.Linq;
25+
using NUnit.Framework;
26+
using RestSharp.Deserializers;
27+
using RestSharp.Tests.SampleClasses;
2828

2929
namespace RestSharp.Tests
3030
{
@@ -195,7 +195,7 @@ public void Can_Deserialize_List_of_Guid()
195195
data["Ids"] = new JsonArray { id1, id2 };
196196

197197
JsonDeserializer d = new JsonDeserializer();
198-
RestResponse response = new RestResponse { Content = data.ToString() };
198+
RestResponse response = new RestResponse { Content = data.ToString() };
199199
GuidList p = d.Deserialize<GuidList>(response);
200200

201201
Assert.AreEqual(2, p.Ids.Count);
@@ -792,6 +792,7 @@ public void Can_Deserialize_Dictionary_with_Null()
792792
Assert.IsNull(dictionary["Null"]);
793793
}
794794

795+
795796
private static string CreateJsonWithUnderscores()
796797
{
797798
JsonObject doc = new JsonObject();
@@ -1025,4 +1026,4 @@ private static T GetPayLoad<T>(string fileName)
10251026
return d.Deserialize<T>(response);
10261027
}
10271028
}
1028-
}
1029+
}

RestSharp/Deserializers/JsonDeserializer.cs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
using RestSharp.Extensions;
2-
using System;
1+
using System;
32
using System.Collections;
43
using System.Collections.Generic;
54
using System.Globalization;
65
using System.Linq;
76
using System.Reflection;
7+
using RestSharp.Extensions;
88

99
namespace RestSharp.Deserializers
1010
{
@@ -37,34 +37,34 @@ public T Deserialize<T>(IRestResponse response)
3737
{
3838
object root = this.FindRoot(response.Content);
3939

40-
target = (T)this.BuildList(objType, root);
40+
target = (T) this.BuildList(objType, root);
4141
}
4242
else
4343
{
4444
object data = SimpleJson.DeserializeObject(response.Content);
4545

46-
target = (T)this.BuildList(objType, data);
46+
target = (T) this.BuildList(objType, data);
4747
}
4848
}
4949
else if (target is IDictionary)
5050
{
5151
object root = this.FindRoot(response.Content);
5252

53-
target = (T)this.BuildDictionary(target.GetType(), root);
53+
target = (T) this.BuildDictionary(target.GetType(), root);
5454
}
5555
else
5656
{
5757
object root = this.FindRoot(response.Content);
5858

59-
target = (T)this.Map(target, (IDictionary<string, object>)root);
59+
target = (T) this.Map(target, (IDictionary<string, object>) root);
6060
}
6161

6262
return target;
6363
}
6464

6565
private object FindRoot(string content)
6666
{
67-
IDictionary<string, object> data = (IDictionary<string, object>)SimpleJson.DeserializeObject(content);
67+
IDictionary<string, object> data = (IDictionary<string, object>) SimpleJson.DeserializeObject(content);
6868

6969
if (this.RootElement.HasValue() && data.ContainsKey(this.RootElement))
7070
{
@@ -89,7 +89,7 @@ private object Map(object target, IDictionary<string, object> data)
8989

9090
if (attributes.Length > 0)
9191
{
92-
DeserializeAsAttribute attribute = (DeserializeAsAttribute)attributes[0];
92+
DeserializeAsAttribute attribute = (DeserializeAsAttribute) attributes[0];
9393
name = attribute.Name;
9494
}
9595
else
@@ -117,7 +117,7 @@ private object Map(object target, IDictionary<string, object> data)
117117
}
118118
else
119119
{
120-
currentData = (IDictionary<string, object>)currentData[actualName];
120+
currentData = (IDictionary<string, object>) currentData[actualName];
121121
}
122122
}
123123

@@ -132,11 +132,11 @@ private object Map(object target, IDictionary<string, object> data)
132132

133133
private IDictionary BuildDictionary(Type type, object parent)
134134
{
135-
IDictionary dict = (IDictionary)Activator.CreateInstance(type);
135+
IDictionary dict = (IDictionary) Activator.CreateInstance(type);
136136
Type keyType = type.GetGenericArguments()[0];
137137
Type valueType = type.GetGenericArguments()[1];
138138

139-
foreach (KeyValuePair<string, object> child in (IDictionary<string, object>)parent)
139+
foreach (KeyValuePair<string, object> child in (IDictionary<string, object>) parent)
140140
{
141141
object key = keyType != typeof(string)
142142
? Convert.ChangeType(child.Key, keyType, CultureInfo.InvariantCulture)
@@ -161,15 +161,15 @@ private IDictionary BuildDictionary(Type type, object parent)
161161

162162
private IList BuildList(Type type, object parent)
163163
{
164-
IList list = (IList)Activator.CreateInstance(type);
164+
IList list = (IList) Activator.CreateInstance(type);
165165
Type listType = type.GetInterfaces()
166166
.First
167167
(x => x.IsGenericType && x.GetGenericTypeDefinition() == typeof(IList<>));
168168
Type itemType = listType.GetGenericArguments()[0];
169169

170170
if (parent is IList)
171171
{
172-
foreach (object element in (IList)parent)
172+
foreach (object element in (IList) parent)
173173
{
174174
if (itemType.IsPrimitive)
175175
{
@@ -276,14 +276,14 @@ private object ConvertValue(Type type, object value)
276276

277277
if (type == typeof(DateTimeOffset))
278278
{
279-
return (DateTimeOffset)dt;
279+
return (DateTimeOffset) dt;
280280
}
281281
}
282282
else if (type == typeof(decimal))
283283
{
284284
if (value is double)
285285
{
286-
return (decimal)((double)value);
286+
return (decimal) ((double) value);
287287
}
288288

289289
if (stringValue.Contains("e"))
@@ -343,7 +343,7 @@ private object ConvertValue(Type type, object value)
343343
}
344344
else if (type == typeof(JsonObject))
345345
{
346-
// simplify JsonObject into a Dictionary<string, object>
346+
// simplify JsonObject into a Dictionary<string, object>
347347
return this.BuildDictionary(typeof(Dictionary<string, object>), value);
348348
}
349349
else
@@ -359,9 +359,9 @@ private object CreateAndMap(Type type, object element)
359359
{
360360
object instance = Activator.CreateInstance(type);
361361

362-
this.Map(instance, (IDictionary<string, object>)element);
362+
this.Map(instance, (IDictionary<string, object>) element);
363363

364364
return instance;
365365
}
366366
}
367-
}
367+
}

0 commit comments

Comments
 (0)