Skip to content

Class TypeInvoke ​

Namespace: Tool.Utils.ActionDelegate
Assembly: Tool.Net.dll

用于对指定的类的方法进行调用,中级封装

csharp
public sealed class TypeInvoke

Inheritance ​

object ← TypeInvoke

Inherited Members ​

object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object?, object?), object.ToString()

Extension Methods ​

ObjectExtension.Add<T>(object, object, object), ObjectExtension.CopyEntity(object, object, params string[]), ObjectExtension.EntityToJson(object), ObjectExtension.EntityToJson(object, bool), ObjectExtension.EntityToJson(object, bool, string), DictionaryExtension.GetDictionary(object), TypeExtension.GetFieldKey(object, string, out bool), TypeExtension.GetFieldKey<T>(object, string, out bool), TypeExtension.GetFieldKey(object, Type, string, out bool), ObjectExtension.GetIntPtr(object), ObjectExtension.GetIntPtrInt(object), TypeExtension.GetPropertieFind(object, string, bool), TypeExtension.GetProperties(object), TypeExtension.GetPropertyKey(object, string, out bool), TypeExtension.GetPropertyKey<T>(object, string, out bool), TypeExtension.GetPropertyKey(object, Type, string, out bool), TypeExtension.GetValue(object, PropertyDescriptor), TypeExtension.GetValue(object, string, bool), TypeExtension.GetValue(object, string), ObjectExtension.Read<T>(object, object, int, int), ObjectExtension.Read<T>(object, int, object, int, int), DictionaryExtension.SetDictionary(object, IDictionary<string, object>), TypeExtension.SetFieldKey(object, string, object), TypeExtension.SetFieldKey<T>(object, string, object), TypeExtension.SetFieldKey(object, Type, string, object), TypeExtension.SetPropertyKey(object, string, object), TypeExtension.SetPropertyKey<T>(object, string, object), TypeExtension.SetPropertyKey(object, Type, string, object), TypeExtension.SetValue(object, PropertyDescriptor, object), TypeExtension.SetValue(object, string, object, bool), TypeExtension.SetValue(object, string, object), ObjectExtension.ToBase64String(object), ObjectExtension.ToBytes(object), ObjectExtension.ToBytes(object, out Type), DictionaryExtension.ToDictionary(object), DictionaryExtension.ToDictionary<T>(object), DictionaryExtension.ToIDictionary(object), DictionaryExtension.ToIDictionary<T>(object), ObjectExtension.ToJson(object), ObjectExtension.ToJson(object, JsonSerializerOptions), ObjectExtension.ToJsonWeb(object), ObjectExtension.ToJsonWeb(object, Action<JsonSerializerOptions>), ObjectExtension.ToTryVar<T>(object, T), ObjectExtension.ToVar<T>(object), ObjectExtension.ToVar(object, Type, bool), ObjectExtension.ToVar(object, string), ObjectExtension.ToXml(object)

Remarks ​

代码由逆血提供支持

Constructors ​

TypeInvoke(string) ​

初始化,并赋值

csharp
public TypeInvoke(string type)

Parameters ​

type string

(访问程序集下面指定的类路径)要获取的类型的程序集限定名称。 如果该类型位于当前正在执行的程序集中或者 Mscorlib.dll 中,则提供由命名空间限定的类型名称就足够了。

TypeInvoke(string, params object[]) ​

初始化,并赋值

csharp
public TypeInvoke(string type, params object[] args)

Parameters ​

type string

(访问程序集下面指定的类路径)要获取的类型的程序集限定名称。 如果该类型位于当前正在执行的程序集中或者 Mscorlib.dll 中,则提供由命名空间限定的类型名称就足够了。

args object[]

与要调用构造函数的参数数量、顺序和类型匹配的参数数组。 如果 args 为空数组或 null,则调用不带任何参数的构造函数(默认构造函数)。

TypeInvoke(string, string) ​

加载指定路径下的dll中的类对象(无参构造)

csharp
public TypeInvoke(string absolutepath, string type)

Parameters ​

absolutepath string

dll的绝对路径

type string

访问程序集下面指定的类路径

TypeInvoke(string, string, params object[]) ​

加载指定路径下的dll中的类对象(有参构造)

csharp
public TypeInvoke(string absolutepath, string type, params object[] args)

Parameters ​

absolutepath string

dll的绝对路径

type string

访问程序集下面指定的类路径

args object[]

TypeInvoke(string, object) ​

初始化,并赋值

csharp
public TypeInvoke(string type, object args)

Parameters ​

type string

(访问程序集下面指定的类路径)要获取的类型的程序集限定名称。 如果该类型位于当前正在执行的程序集中或者 Mscorlib.dll 中,则提供由命名空间限定的类型名称就足够了。

args object

当前实例化的对象。

TypeInvoke(Type) ​

初始化,并赋值

csharp
public TypeInvoke(Type type)

Parameters ​

type Type

表示类型声明:类类型、接口类型、数组类型、值类型、枚举类型、类型参数、泛型类型定义,以及开放或封闭构造的泛型类型。

TypeInvoke(object) ​

初始化,并赋值

csharp
public TypeInvoke(object obj)

Parameters ​

obj object

必须是对象

TypeInvoke(Type, params object[]) ​

初始化,并赋值

csharp
public TypeInvoke(Type type, params object[] args)

Parameters ​

type Type

表示类型声明:类类型、接口类型、数组类型、值类型、枚举类型、类型参数、泛型类型定义,以及开放或封闭构造的泛型类型。

args object[]

与要调用构造函数的参数数量、顺序和类型匹配的参数数组。 如果 args 为空数组或 null,则调用不带任何参数的构造函数(默认构造函数)。

TypeInvoke(Type, object) ​

初始化,并赋值

csharp
public TypeInvoke(Type type, object args)

Parameters ​

type Type

表示类型声明:类类型、接口类型、数组类型、值类型、枚举类型、类型参数、泛型类型定义,以及开放或封闭构造的泛型类型。

args object

当前实例化的对象。

Methods ​

GetAttribute<T>(out string[], bool) ​

获取该类以及下面的所有类型(包涵,方法变量,字段,接口等等)

csharp
public T[] GetAttribute<T>(out string[] Methods, bool only = true)

Parameters ​

Methods string[]

返回名称

only bool

获取父类的吗?默认包含

Returns ​

T[]

返回一个类型实体

Type Parameters ​

T

类型

GetAttribute<T>(out string[], BindingFlags) ​

获取该类以及下面的所有类型(包涵,方法变量,字段,接口等等)

csharp
public T[] GetAttribute<T>(out string[] Methods, BindingFlags bindingFlags)

Parameters ​

Methods string[]

返回名称

bindingFlags BindingFlags

自定义返回内容

Returns ​

T[]

返回一个类型实体

Type Parameters ​

T

类型

GetAttribute<T>(BindingFlags) ​

获取该类以及下面的所有类型(包涵,方法变量,字段,接口等等)

csharp
public Dictionary<string, T> GetAttribute<T>(BindingFlags bindingFlags)

Parameters ​

bindingFlags BindingFlags

自定义返回内容

Returns ​

Dictionary<string, T>

返回一个类型实体

Type Parameters ​

T

类型

GetAttributeParameterInfo<T>() ​

获取该类以及下面的所有类型(字段)

csharp
public Dictionary<string, T> GetAttributeParameterInfo<T>()

Returns ​

Dictionary<string, T>

返回一个类型实体

Type Parameters ​

T

类型

GetAttributeParameterInfo<T>(BindingFlags) ​

获取该类以及下面的所有类型(字段)

csharp
public Dictionary<string, T> GetAttributeParameterInfo<T>(BindingFlags bindingFlags)

Parameters ​

bindingFlags BindingFlags

自定义返回内容

Returns ​

Dictionary<string, T>

返回一个类型实体

Type Parameters ​

T

类型

GetMethod(string, bool) ​

获取该方法类型(“包含非公开”、“包含实例成员”和“包含公开”)

csharp
public Method GetMethod(string name, bool only = true)

Parameters ​

name string

方法名(注意该方法必须是非静态方法)

only bool

获取父类的吗?默认包含

Returns ​

Method

返回一个类型实体

GetMethod(MethodInfo) ​

获取该方法类型(“包含非公开”、“包含实例成员”和“包含公开”)

csharp
public static Method GetMethod(MethodInfo method)

Parameters ​

method MethodInfo

对象

Returns ​

Method

返回一个类型实体

GetMethodInfo<T>(string) ​

获取类下面的可调用方法

csharp
public static MethodInfo GetMethodInfo<T>(string MethodName)

Parameters ​

MethodName string

方法名

Returns ​

MethodInfo

返回对象

Type Parameters ​

T

类

GetMethodInfo(Type, string, bool) ​

获取类下面的可调用方法

csharp
public static MethodInfo GetMethodInfo(Type type, string MethodName, bool only = true)

Parameters ​

type Type

类Type

MethodName string

方法名

only bool

获取父类的吗?默认包含

Returns ​

MethodInfo

返回对象

GetMethods(bool) ​

获取该类下的所有方法(“包含非公开”、“包含实例成员”和“包含公开”)

csharp
public Method[] GetMethods(bool only = true)

Parameters ​

only bool

获取父类的吗?默认包含

Returns ​

Method[]

返回一个类型实体

GetObj() ​

获取当前被实例化的类

csharp
public object GetObj()

Returns ​

object

返回实例化的类

GetParameter(string) ​

获取该方法需要的参数

csharp
public Parameter[] GetParameter(string name)

Parameters ​

name string

方法名(注意该方法必须是非静态方法)

Returns ​

Parameter[]

返回所有的参数

GetParameter(MethodInfo) ​

获取该方法需要的参数

csharp
public static Parameter[] GetParameter(MethodInfo method)

Parameters ​

method MethodInfo

对象

Returns ​

Parameter[]

返回所有的参数

GetParameter(params ParameterInfo[]) ​

获取该方法需要的参数

csharp
public static Parameter[] GetParameter(params ParameterInfo[] member)

Parameters ​

member ParameterInfo[]

对象

Returns ​

Parameter[]

返回所有的参数

GetProperty(string) ​

获取该类指定的变量的值。

csharp
public object GetProperty(string name)

Parameters ​

name string

变量名

Returns ​

object

返回该方法的值

GetType() ​

获取当前被实例化的类的Type

csharp
public Type GetType()

Returns ​

Type

返回Type

Invoke(string) ​

调起该方法(“包含非公开”、“包含实例成员”和“包含公开”)

csharp
public object Invoke(string name)

Parameters ​

name string

方法名(注意该方法必须是非静态方法)

Returns ​

object

返回该方法执行后的结果

Invoke(string, params object[]) ​

调起该方法(“包含非公开”、“包含实例成员”和“包含公开”)

csharp
public object Invoke(string name, params object[] parameters)

Parameters ​

name string

方法名(注意该方法必须是非静态方法)

parameters object[]

该方法的指定参数

Returns ​

object

返回该方法执行后的结果

IsMethod(string, bool) ​

判断该方法是否存在 (“包含非公开”、“包含实例成员”和“包含公开”)

csharp
public bool IsMethod(string name, bool only = true)

Parameters ​

name string

方法名(注意该方法必须是非静态方法)

only bool

获取父类的吗?默认包含

Returns ​

bool

返回是否存在

SetProperty(string, object) ​

对该类指定的变量赋值。

csharp
public void SetProperty(string name, object parameter)

Parameters ​

name string

变量名

parameter object

值

ToString() ​

获取当前被实例化的类的,名称包含命名空间

csharp
public override string ToString()

Returns ​

string

返回类的名称包含命名空间

基于Apache-2.0协议开源