-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQuickAccess.StaticAction.cs
41 lines (35 loc) · 1.57 KB
/
QuickAccess.StaticAction.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
using System;
namespace QuickAccess
{
public partial class QuickAccess
{
public static Action<object[]> GetStaticAction(this Type type, string methodName, params Type[] paramTypes)
{
return type.GetMethodInfo(methodName, paramTypes)?.CreateDelegate<Action<object[]>>(true);
}
public static Action<object> GetStaticAction(this Type type, string methodName, Type paramType)
{
return type.GetMethodInfo(methodName, paramType)?.CreateDelegate<Action<object>>(true);
}
public static Action<TParam1, TParam2, TParam3> GetStaticAction<TParam1, TParam2, TParam3>(this Type type,
string methodName)
{
return type.GetMethodInfo(methodName, typeof(TParam1), typeof(TParam2), typeof(TParam3))?
.CreateDelegate<Action<TParam1, TParam2, TParam3>>(true);
}
public static Action<TParam1, TParam2> GetStaticAction<TParam1, TParam2>(this Type type, string methodName)
{
return type.GetMethodInfo(methodName, typeof(TParam1), typeof(TParam2))?
.CreateDelegate<Action<TParam1, TParam2>>(true);
}
public static Action<TParam> GetStaticAction<TParam>(this Type type, string methodName)
{
return type.GetMethodInfo(methodName, typeof(TParam))?
.CreateDelegate<Action<TParam>>(true);
}
public static Action GetStaticAction(this Type type, string methodName)
{
return type.GetMethodInfo(methodName)?.CreateDelegate<Action>(true);
}
}
}