我有一个主类,我在其中循环遍历我的夹板类属性中的每个内部属性。我的夹板类中的每个内部属性都是类型BeltProperty
(另一个包含值和 id 等信息的类)。
private ObservableCollection<Cleats> _Cleats = new ObservableCollection<Cleats>();
/// <summary>
/// Cleats
/// </summary>
public ObservableCollection<Cleats> Cleats { get { return _Cleats; } }
foreach (PropertyInfo prop in typeof(Cleats)
.GetProperties(BindingFlags.Instance | BindingFlags.NonPublic))
{
BeltProperty bp = new BeltProperty();
bp = (BeltProperty)Cleats[Configurator_2016.Cleats.SelectedConfigurationIndex]
.GetType().GetProperty(prop.Name, BindingFlags.Instance | BindingFlags.NonPublic)
.GetValue(this, null);
//rest of the code...
}
在第一次BeltProperty
它发现它抛出一个System.Reflection.TargetException
. 我想知道是否有另一种/更好的方法可以从我的夹板类中获取属性。提前感谢您的任何帮助或建议。