Skip to content

Class DispatcherCore ​

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

创建通用调用函数模型

csharp
public static class DispatcherCore

Inheritance ​

object ← DispatcherCore

Inherited Members ​

object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), 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 ​

代码由逆血提供支持

Methods ​

AddMake(MethodInfo, params Type[]) ​

给无形参的方法指定参数类型

csharp
public static MethodInfo AddMake(this MethodInfo method, params Type[] typeArguments)

Parameters ​

method MethodInfo

方法

typeArguments Type[]

指定形参

Returns ​

MethodInfo

返回具有形参的方法

Exceptions ​

ArgumentNullException

值为空

AsAction<T, TResult>(IActionDispatcher) ​

动态获取通用模型原型

csharp
public static ActionDispatcher<T, TResult> AsAction<T, TResult>(this IActionDispatcher action)

Parameters ​

action IActionDispatcher

Returns ​

ActionDispatcher<T, TResult>

原始模型

Type Parameters ​

T

类泛型

TResult

返回值泛型

AsAction<T, TResult>(IActionDispatcher<T>) ​

动态获取通用模型原型

csharp
public static ActionDispatcher<T, TResult> AsAction<T, TResult>(this IActionDispatcher<T> action)

Parameters ​

action IActionDispatcher<T>

Returns ​

ActionDispatcher<T, TResult>

原始模型

Type Parameters ​

T

类泛型

TResult

返回值泛型

GetExecutor<TResult>(MethodInfo, Type) ​

创建不同的委托

csharp
public static Delegate GetExecutor<TResult>(MethodInfo methodInfo, Type classtype)

Parameters ​

methodInfo MethodInfo

方法对象

classtype Type

调用的返回类

Returns ​

Delegate

调用委托

Type Parameters ​

TResult

调用返回类型

GetExecutor<E, TResult>(MethodInfo) ​

创建不同的委托

csharp
public static Delegate GetExecutor<E, TResult>(MethodInfo methodInfo)

Parameters ​

methodInfo MethodInfo

方法对象

Returns ​

Delegate

调用委托

Type Parameters ​

E

调用函数使用类

TResult

调用返回类型

GetExecutor(MethodInfo) ​

创建不同的委托

csharp
public static Delegate GetExecutor(MethodInfo methodInfo)

Parameters ​

methodInfo MethodInfo

Returns ​

Delegate

返回委托类型

GetExecutor(MethodInfo, Type) ​

创建不同的委托

csharp
public static Delegate GetExecutor(MethodInfo methodInfo, Type classtype)

Parameters ​

methodInfo MethodInfo

方法对象

classtype Type

调用的返回类

Returns ​

Delegate

调用委托

GetExecutor<E, TResult>(MethodInfo, Type, params Type[]) ​

创建不同的委托(泛型方法版)

csharp
public static Delegate GetExecutor<E, TResult>(MethodInfo methodInfo, Type classtype, params Type[] typeArguments)

Parameters ​

methodInfo MethodInfo

方法对象

classtype Type

调用的返回类

typeArguments Type[]

未泛型方法提供的形参

Returns ​

Delegate

调用委托

Type Parameters ​

E

调用函数使用类

TResult

调用返回类型

GetExecutor<E, TResult>(MethodInfo, Type) ​

创建不同的委托

csharp
public static Delegate GetExecutor<E, TResult>(MethodInfo methodInfo, Type classtype)

Parameters ​

methodInfo MethodInfo

方法对象

classtype Type

调用的返回类

Returns ​

Delegate

调用委托

Type Parameters ​

E

调用函数使用类

TResult

调用返回类型

IsAssignableFrom<T>(Type) ​

判断是否存在继承关系 -> T=ReturnType

csharp
public static bool IsAssignableFrom<T>(Type ReturnType)

Parameters ​

ReturnType Type

判断类型

Returns ​

bool

Type Parameters ​

T

原始信息

IsTask(Type) ​

判断是否是无返回结果的异步类型

csharp
public static bool IsTask(Type ReturnType)

Parameters ​

ReturnType Type

Returns ​

bool

IsTask<T>(MethodInfo) ​

判断有返回值的方法

csharp
public static bool IsTask<T>(MethodInfo method)

Parameters ​

method MethodInfo

方法信息

Returns ​

bool

是或否

Type Parameters ​

T

返回值是否与他有关

Exceptions ​

ArgumentNullException

IsTaskTuple(Type) ​

是否是含返回值异步类型

csharp
public static bool IsTaskTuple(Type ReturnType)

Parameters ​

ReturnType Type

Returns ​

bool

IsVoid(Type) ​

是否是无返回值的方法

csharp
public static bool IsVoid(Type ReturnType)

Parameters ​

ReturnType Type

Returns ​

bool

MethodIsTask(Type, out bool) ​

判断一个类型是是不是 or or or

csharp
public static bool MethodIsTask(Type ReturnType, out bool isvoid)

Parameters ​

ReturnType Type

类型

isvoid bool

有无返回值

Returns ​

bool

MethodIsValueTask(Type) ​

判断是否是 or

csharp
public static bool MethodIsValueTask(Type ReturnType)

Parameters ​

ReturnType Type

Returns ​

bool

ObjectAsync<TResult, T>(Task<TResult>) ​

有用转换

csharp
public static Task<T> ObjectAsync<TResult, T>(Task<TResult> task)

Parameters ​

task Task<TResult>

Returns ​

Task<T>

Type Parameters ​

TResult

T

ObjectValueAsync<TResult, T>(ValueTask<TResult>) ​

有用转换

csharp
public static Task<T> ObjectValueAsync<TResult, T>(ValueTask<TResult> task)

Parameters ​

task ValueTask<TResult>

Returns ​

Task<T>

Type Parameters ​

TResult

T

基于Apache-2.0协议开源