Fix error on element/property list is null. (2)

This commit is contained in:
2023-04-14 20:32:00 +08:00
parent 5887b1267a
commit 17d620ff0c

View File

@@ -272,7 +272,9 @@ namespace Cryville.Common.Pdt {
Type ptype = ReflectionHelper.GetMemberType(prop);
if (flag) {
var origCollection = ReflectionHelper.GetValue(prop, result);
if (origCollection == null) origCollection = Activator.CreateInstance(ptype);
if (origCollection == null) {
ReflectionHelper.SetValue(prop, result, origCollection = Activator.CreateInstance(ptype));
}
using (var collection = new PairCollection(origCollection)) {
var ktype = ptype.GetGenericArguments()[0];
var vtype = ptype.GetGenericArguments()[1];