说明
Provides information about the characteristics for a component, such as its attributes, properties, and events. This class cannot be inherited.
提供了一些关于组件特征的一些信息,例如:属性(attributes),属性(properties),事件,该类不能被集成。
GetProperties(Object)
Returns the collection of properties for a specified component.
针对某一特定组件,返回该组件的所有属性集合。
TypeDescriptor is an extensible inspection mechanism for components: those classes that implement the IComponent interface. Unlike reflection, it does not inspect for methods. TypeDescriptor can be dynamically extended by several services available through the target component's Site. The following table shows these services.
得到特定属性(Attribute)的值
PropertyDescriporCollection myPropertyDescriporCollection = TypeDescripor.GetProperties(this);
for(PropertyDescripor myPropertyDescripor in myPropertyDescriporCollection)
{
FieldAttribute myFieldAttribute = myPropertyDescripor.Attributes(typeof(FieldAttribute)) as FunctionParameterAttribute
string fieldName = TableAttribute.FieldName;//User
DbType fileDbType = TableAttribute.DbType;// DbType.String
}
public Class User
{
[Filed("User",DbType.String)]
public string User { get; set; }
}
public Class FieldAttrubute:Attribute
{
public FieldAttrubute(string name,DbType dbType)
{
Name = name;
FieldDbType = dbType;
}
public string Name{ get; set; }
public DbType FieldDbType { get; set; }
}
复制代码