尝试为 Microsoft Office 对象创建映射器到 POCO's,发现了这个:
// doesn't work
// returns an empty array where o is a RCW on an office object
foreach(var pi in o.GetType().GetProperties() )
tgt.SetValue(rc, pi.GetValue(o, null));
所以不得不采取这种方法
foreach(var field in tgt.GetFields() ){
var pv = o.InvokeMember(field.Name, System.Reflection.BindingFlags.GetProperty, null, o, null);
i.SetValue(rc, pv);
}
这个方法暂时可用,但不知道为什么这里不能使用 RCW.GetProperties()
方法?