C# Class Com.Aote.ObjectTools.CustomType

自定义类型,包含一个基础类型,即对象自身的class类型,一些常用的内容都直接调用这个基础类型的方法 完成,只是在获取属性等方面才做自己的实现过程。
Inheritance: System.Type
显示文件 Open project: DuBin1988/restv2 Class Usage Examples

Public Properties

Property Type Description
_customProperties List

Public Methods

Method Description
AddProperty ( string name ) : void

增加一个属性,类型为string

AddProperty ( string name, Type propertyType ) : void

增加一个属性,类型为给的值

AddProperty ( string name, Type propertyType, List attributes ) : void

增加一个属性,除名称及类型外,还有声明,不太常用

CustomType ( Type delegatingType ) : System

用基础类型构造用户类型。

GetConstructors ( BindingFlags bindingAttr ) : System.Reflection.ConstructorInfo[]
GetCustomAttributes ( Type attributeType, bool inherit ) : object[]
GetCustomAttributes ( bool inherit ) : object[]
GetElementType ( ) : Type
GetEvent ( string name, BindingFlags bindingAttr ) : EventInfo
GetEvents ( BindingFlags bindingAttr ) : System.Reflection.EventInfo[]
GetField ( string name, BindingFlags bindingAttr ) : FieldInfo
GetFields ( BindingFlags bindingAttr ) : System.Reflection.FieldInfo[]
GetInterface ( string name, bool ignoreCase ) : Type
GetInterfaces ( ) : System.Type[]
GetMembers ( BindingFlags bindingAttr ) : System.Reflection.MemberInfo[]
GetMethods ( BindingFlags bindingAttr ) : System.Reflection.MethodInfo[]
GetNestedType ( string name, BindingFlags bindingAttr ) : Type
GetNestedTypes ( BindingFlags bindingAttr ) : System.Type[]
GetProperties ( BindingFlags bindingAttr ) : System.Reflection.PropertyInfo[]

获得所有属性信息,包括clr属性以及自定义属性。

InvokeMember ( string name, BindingFlags invokeAttr, Binder binder, object target, object args, ParameterModifier modifiers, System culture, string namedParameters ) : object
IsDefined ( Type attributeType, bool inherit ) : bool

Protected Methods

Method Description
GetAttributeFlagsImpl ( ) : TypeAttributes
GetConstructorImpl ( BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type types, ParameterModifier modifiers ) : ConstructorInfo
GetMethodImpl ( string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type types, ParameterModifier modifiers ) : MethodInfo
GetPropertyImpl ( string name, BindingFlags bindingAttr, Binder binder, Type returnType, Type types, ParameterModifier modifiers ) : PropertyInfo

实际获取某个属性的属性信息的实现过程。

HasElementTypeImpl ( ) : bool
IsArrayImpl ( ) : bool
IsByRefImpl ( ) : bool
IsCOMObjectImpl ( ) : bool
IsPointerImpl ( ) : bool
IsPrimitiveImpl ( ) : bool

Private Methods

Method Description
CheckIfNameExists ( string name ) : bool

检查属性是否存在,以避免重复添加属性。如果属性已经存在,将抛出属性名存在异常。

Method Details

AddProperty() public method

增加一个属性,类型为string
public AddProperty ( string name ) : void
name string 属性名
return void

AddProperty() public method

增加一个属性,类型为给的值
public AddProperty ( string name, Type propertyType ) : void
name string 属性名
propertyType System.Type 属性类型
return void

AddProperty() public method

增加一个属性,除名称及类型外,还有声明,不太常用
public AddProperty ( string name, Type propertyType, List attributes ) : void
name string 属性名
propertyType System.Type 属性类型
attributes List 声明
return void

CustomType() public method

用基础类型构造用户类型。
public CustomType ( Type delegatingType ) : System
delegatingType System.Type 基础类型
return System

GetAttributeFlagsImpl() protected method

protected GetAttributeFlagsImpl ( ) : TypeAttributes
return TypeAttributes

GetConstructorImpl() protected method

protected GetConstructorImpl ( BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type types, ParameterModifier modifiers ) : ConstructorInfo
bindingAttr BindingFlags
binder System.Reflection.Binder
callConvention CallingConventions
types System.Type
modifiers System.Reflection.ParameterModifier
return System.Reflection.ConstructorInfo

GetConstructors() public method

public GetConstructors ( BindingFlags bindingAttr ) : System.Reflection.ConstructorInfo[]
bindingAttr BindingFlags
return System.Reflection.ConstructorInfo[]

GetCustomAttributes() public method

public GetCustomAttributes ( Type attributeType, bool inherit ) : object[]
attributeType System.Type
inherit bool
return object[]

GetCustomAttributes() public method

public GetCustomAttributes ( bool inherit ) : object[]
inherit bool
return object[]

GetElementType() public method

public GetElementType ( ) : Type
return System.Type

GetEvent() public method

public GetEvent ( string name, BindingFlags bindingAttr ) : EventInfo
name string
bindingAttr BindingFlags
return System.Reflection.EventInfo

GetEvents() public method

public GetEvents ( BindingFlags bindingAttr ) : System.Reflection.EventInfo[]
bindingAttr BindingFlags
return System.Reflection.EventInfo[]

GetField() public method

public GetField ( string name, BindingFlags bindingAttr ) : FieldInfo
name string
bindingAttr BindingFlags
return System.Reflection.FieldInfo

GetFields() public method

public GetFields ( BindingFlags bindingAttr ) : System.Reflection.FieldInfo[]
bindingAttr BindingFlags
return System.Reflection.FieldInfo[]

GetInterface() public method

public GetInterface ( string name, bool ignoreCase ) : Type
name string
ignoreCase bool
return System.Type

GetInterfaces() public method

public GetInterfaces ( ) : System.Type[]
return System.Type[]

GetMembers() public method

public GetMembers ( BindingFlags bindingAttr ) : System.Reflection.MemberInfo[]
bindingAttr BindingFlags
return System.Reflection.MemberInfo[]

GetMethodImpl() protected method

protected GetMethodImpl ( string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type types, ParameterModifier modifiers ) : MethodInfo
name string
bindingAttr BindingFlags
binder System.Reflection.Binder
callConvention CallingConventions
types System.Type
modifiers System.Reflection.ParameterModifier
return System.Reflection.MethodInfo

GetMethods() public method

public GetMethods ( BindingFlags bindingAttr ) : System.Reflection.MethodInfo[]
bindingAttr BindingFlags
return System.Reflection.MethodInfo[]

GetNestedType() public method

public GetNestedType ( string name, BindingFlags bindingAttr ) : Type
name string
bindingAttr BindingFlags
return System.Type

GetNestedTypes() public method

public GetNestedTypes ( BindingFlags bindingAttr ) : System.Type[]
bindingAttr BindingFlags
return System.Type[]

GetProperties() public method

获得所有属性信息,包括clr属性以及自定义属性。
public GetProperties ( BindingFlags bindingAttr ) : System.Reflection.PropertyInfo[]
bindingAttr BindingFlags 未知
return System.Reflection.PropertyInfo[]

GetPropertyImpl() protected method

实际获取某个属性的属性信息的实现过程。
protected GetPropertyImpl ( string name, BindingFlags bindingAttr, Binder binder, Type returnType, Type types, ParameterModifier modifiers ) : PropertyInfo
name string 属性名
bindingAttr BindingFlags 未知
binder System.Reflection.Binder 未知
returnType System.Type 未知
types System.Type 未知
modifiers System.Reflection.ParameterModifier 未知
return System.Reflection.PropertyInfo

HasElementTypeImpl() protected method

protected HasElementTypeImpl ( ) : bool
return bool

InvokeMember() public method

public InvokeMember ( string name, BindingFlags invokeAttr, Binder binder, object target, object args, ParameterModifier modifiers, System culture, string namedParameters ) : object
name string
invokeAttr BindingFlags
binder System.Reflection.Binder
target object
args object
modifiers System.Reflection.ParameterModifier
culture System
namedParameters string
return object

IsArrayImpl() protected method

protected IsArrayImpl ( ) : bool
return bool

IsByRefImpl() protected method

protected IsByRefImpl ( ) : bool
return bool

IsCOMObjectImpl() protected method

protected IsCOMObjectImpl ( ) : bool
return bool

IsDefined() public method

public IsDefined ( Type attributeType, bool inherit ) : bool
attributeType System.Type
inherit bool
return bool

IsPointerImpl() protected method

protected IsPointerImpl ( ) : bool
return bool

IsPrimitiveImpl() protected method

protected IsPrimitiveImpl ( ) : bool
return bool

Property Details

_customProperties public_oe property

保存类型的属性信息,属性信息实现了PropertyInfo,可以当做正常的PropertyInfo使用。
public List _customProperties
return List