我得到以下代码来生成 DLL:
public class QtObject : DependencyObject
{
public int speedSimu
{
get { return (int)GetValue(speedSimuProperty); }
set { SetValue(speedSimuProperty, value); }
}
public static readonly DependencyProperty speedSimuProperty =
DependencyProperty.Register("speedSimu", typeof(int), typeof(QtObject), new PropertyMetadata(0));
public int rpmSimu
{
get { return (int)GetValue(rpmSimuProperty); }
set { SetValue(rpmSimuProperty, value); }
}
public static readonly DependencyProperty rpmSimuProperty =
DependencyProperty.Register("rpmSimu", typeof(int), typeof(QtObject), new PropertyMetadata(0));
public int nbSimu;
}
public class Timer : DependencyObject
{
public string description
{
get { return (string)GetValue(descriptionProperty); }
set { SetValue(descriptionProperty, value); }
}
public static readonly DependencyProperty descriptionProperty =
DependencyProperty.Register("description", typeof(string), typeof(Timer), new PropertyMetadata("This is a time"));
public bool isActive
{
get { return (bool)GetValue(isActiveProperty); }
set { SetValue(isActiveProperty, value); }
}
public static readonly DependencyProperty isActiveProperty =
DependencyProperty.Register("isActive", typeof(bool), typeof(Timer), new PropertyMetadata(true));
}
public class AnotherClass
{
//blaaa
}
我现在只想获得 DependencyObject/Properties。(即没有属性“nbSimu”且没有对象“AnotherClass”)
这是我的代码:
var library = Assembly.LoadFrom(libraryPath);
IEnumerable<Type> types = library.GetTypes();
var libs = types.Where(t => true);
foreach (Type type in libs)
{
foreach (PropertyInfo property in type.GetProperties())
{
//TODO
}
}
在第三行我试过:
var libs = types.Where(t => t.BaseType == typeof(DependencyObject));
它没有说任何错误,但没有过滤任何东西......
关于过滤 DependencyProperties,我只是不知道该怎么做......
提前感谢您在这两个问题上的任何帮助。