Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit b4bc95b

Browse files
KevinHowardmythz
authored andcommitted
Changed FromObjectDictionary<T> to return T (#501)
Changed FromObjectDictionary<T> to return T instead of an object.
1 parent fd722f7 commit b4bc95b

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/ServiceStack.Text/PlatformExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,9 +1347,9 @@ public static object FromObjectDictionary(this Dictionary<string, object> values
13471347
return to;
13481348
}
13491349

1350-
public static object FromObjectDictionary<T>(this Dictionary<string, object> values)
1350+
public static T FromObjectDictionary<T>(this Dictionary<string, object> values)
13511351
{
1352-
return values.FromObjectDictionary(typeof(T));
1352+
return (T)values.FromObjectDictionary(typeof(T));
13531353
}
13541354

13551355
private static ObjectDictionaryDefinition CreateObjectDictionaryDefinition(Type type)

tests/ServiceStack.Text.Tests/AutoMappingObjectDictionaryTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public void Can_convert_Cart_to_ObjectDictionary()
3737
Assert.That(((Car)map["Car"]).Age, Is.EqualTo(dto.Car.Age));
3838
Assert.That(((Car)map["Car"]).Name, Is.EqualTo(dto.Car.Name));
3939

40-
var fromDict = (User)map.FromObjectDictionary(typeof(User));
40+
var fromDict = map.FromObjectDictionary<User>();
4141
Assert.That(fromDict.FirstName, Is.EqualTo(dto.FirstName));
4242
Assert.That(fromDict.LastName, Is.EqualTo(dto.LastName));
4343
Assert.That(fromDict.Car.Age, Is.EqualTo(dto.Car.Age));

0 commit comments

Comments
 (0)