我有一个这样定义的类:
public class Company
{
public Int32 OrganisationID {get;set;}
public CompanyStatus OrganisationStatus {get;set;}
// note that CompanyStatus is my custom type
}
然后我将代码编译成Entity.dll
. 当我使用下面的代码时,我 ((System.Reflection.MemberInfo)(properties[1])).Name
得到CompanyStatus
. 当我动态读取所有属性时,如何判断它是否是自定义类型?
Assembly objAssembly = Assembly.LoadFrom(@"Entities.dll");
var types1 = objAssembly.GetTypes();
foreach (Type type in types1)
{
string name = type.Name;
var properties = type.GetProperties(); // public properties
foreach (PropertyInfo objprop in properties)
{
// Code here
}
}