Skip to content

Commit 94b1090

Browse files
committed
SetPropertyValues better handles Dictionaries
1 parent 02ef616 commit 94b1090

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

core/Helpers/ObjectDumper.cs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,8 @@ public static void SetPropertyValues(object obj,bool onlyPopulateListEditorLists
580580

581581
var subObject = Activator.CreateInstance(propType);
582582

583-
if (propType.IsGenericType /*&&
583+
if (propType.IsGenericType && propType.GetGenericArguments().Length == 1
584+
/*&&
584585
propType.GetGenericTypeDefinition()
585586
== typeof(IList<>)*/)
586587
{
@@ -594,11 +595,11 @@ public static void SetPropertyValues(object obj,bool onlyPopulateListEditorLists
594595
{
595596
listItem = (Single?)0f;
596597
}
597-
else if (itemType==typeof(Char?))
598+
else if (itemType == typeof(Char?))
598599
{
599600
listItem = (Char?)' ';
600601
}
601-
else if (itemType==typeof(Decimal?))
602+
else if (itemType == typeof(Decimal?))
602603
{
603604
listItem = (Decimal?)0m;
604605
}
@@ -625,13 +626,18 @@ public static void SetPropertyValues(object obj,bool onlyPopulateListEditorLists
625626
else
626627
listItem = Activator.CreateInstance(itemType);
627628
subObject.GetType().GetMethod("Add").Invoke(subObject, new[] { listItem });
628-
if(depth<SetPropertyValuesMaxDepth && listItem!=null)
629-
SetPropertyValues(listItem,onlyPopulateListEditorLists:onlyPopulateListEditorLists,depth:depth+1,setNullableFields:setNullableFields);
629+
if (depth < SetPropertyValuesMaxDepth && listItem != null)
630+
SetPropertyValues(listItem, onlyPopulateListEditorLists: onlyPopulateListEditorLists, depth: depth + 1, setNullableFields: setNullableFields);
630631
}
631632
property.SetValue(obj, subObject, null);
632633
}
633-
634-
634+
else if (propType.GetGenericArguments().Length > 1) {
635+
if (propType.GetGenericArguments().Length == 2) {
636+
//likely a dictionary
637+
Type keyType = propType.GetGenericArguments()[0];
638+
//TODO, handle dictionaries
639+
}
640+
}
635641
}
636642
else
637643
if (property.PropertyType.IsClass && property.PropertyType != typeof(string))

0 commit comments

Comments
 (0)