您好,我需要将两个集合作为 XpCollections,但是“cMemberInfo.GetValue(this)”给我输入“DevExpress.Xpo.XPCollection`1”是否可以以某种方式将其转换为 DevExpress.Xpo.XPCollection?
XPCollection cColl1 = cMemberInfo.GetValue(this) as XPCollection;
XPCollection cColl2 = cMemberInfo.GetValue(cObject) as XPCollection;
由于没有转换类型,两个 cColl 都是 null
有使用这些集合的代码的完整部分
foreach (XPMemberInfo cMemberInfo in ClassInfo.CollectionProperties)
{
XPCollection cColl1 = cMemberInfo.GetValue(this) as XPCollection;
XPCollection cColl2 = cMemberInfo.GetValue(cObject) as XPCollection;
if (cColl1 == null || cColl2 == null) { Debug.Assert(false); return false; }
if (cColl1.Count != cColl2.Count) { return false; }
for (int i = 0; i < cColl1.Count; ++i)
{
XPOBase cObj1 = cColl1[i] as XPOBase;
XPOBase cObj2 = cColl2[i] as XPOBase;
bRet &= cObj1.IsDataEqual(cObj2);
}
}
如果我在 XPCollection 的情况下使用 XPBaseCollection,我无法声明 cColl1[i] 或 cColl2[i]