-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQuickAccess.Action.cs
50 lines (49 loc) · 2.25 KB
/
QuickAccess.Action.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System;
namespace QuickAccess
{
public partial class QuickAccess
{
public static Action<object, object[]> GetAction(this Type type, string methodName,
params Type[] paramTypes)
{
return type.GetAction<object>(methodName, paramTypes);
}
public static Action<object, object> GetAction(this Type type, string methodName, Type paramType)
{
return type.GetAction<object>(methodName, paramType);
}
public static Action<object> GetAction(this Type type, string methodName)
{
return type.GetAction<object>(methodName);
}
public static Action<TObject, object[]> GetAction<TObject>(this Type type, string methodName,
params Type[] paramTypes)
{
return type.GetMethodInfo(methodName, paramTypes)?.CreateDelegate<Action<TObject, object[]>>(false);
}
public static Action<TObject, TParam> GetAction<TObject, TParam>(this Type type, string methodName)
{
return type.GetMethodInfo(methodName, typeof(TParam))?.CreateDelegate<Action<TObject, TParam>>(false);
}
public static Action<TObject, TParam1, TParam2> GetAction<TObject, TParam1, TParam2>(this Type type,
string methodName)
{
return type.GetMethodInfo(methodName, typeof(TParam1), typeof(TParam2))
?.CreateDelegate<Action<TObject, TParam1, TParam2>>(false);
}
public static Action<TObject, TParam1, TParam2, TParam3> GetAction<TObject, TParam1, TParam2, TParam3>(
this Type type, string methodName)
{
return type.GetMethodInfo(methodName, typeof(TParam1), typeof(TParam2), typeof(TParam3))
?.CreateDelegate<Action<TObject, TParam1, TParam2, TParam3>>(false);
}
public static Action<TObject, object> GetAction<TObject>(this Type type, string methodName, Type paramType)
{
return type.GetMethodInfo(methodName, paramType)?.CreateDelegate<Action<TObject, object>>(false);
}
public static Action<TObject> GetAction<TObject>(this Type type, string methodName)
{
return type.GetMethodInfo(methodName)?.CreateDelegate<Action<TObject>>(false);
}
}
}