Fix error on element/property list is null.

This commit is contained in:
2023-04-08 13:39:00 +08:00
parent 8907dd19b0
commit 4bc921d47e

View File

@@ -271,7 +271,9 @@ namespace Cryville.Common.Pdt {
if (prop == null) throw new MissingMemberException(string.Format("The property \"{0}\" is not found", pkey));
Type ptype = ReflectionHelper.GetMemberType(prop);
if (flag) {
using (var collection = new PairCollection(ReflectionHelper.GetValue(prop, result))) {
var origCollection = ReflectionHelper.GetValue(prop, result);
if (origCollection == null) origCollection = Activator.CreateInstance(ptype);
using (var collection = new PairCollection(origCollection)) {
var ktype = ptype.GetGenericArguments()[0];
var vtype = ptype.GetGenericArguments()[1];
object key = _binder.ChangeType(pkey, ktype, null);