-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQuickAccess.Func.cs
79 lines (67 loc) · 3.1 KB
/
QuickAccess.Func.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
using System;
namespace QuickAccess
{
public partial class QuickAccess
{
public static Func<object, object[], object> GetFunc(this Type type, string methodName,
params Type[] paramTypes)
{
return type.GetFunc<object, object>(methodName, paramTypes);
}
public static Func<object, object, object> GetFunc(this Type type, string methodName, Type paramType)
{
return type.GetFunc<object, object>(methodName, paramType);
}
public static Func<object, object> GetFunc(this Type type, string methodName)
{
return type.GetFunc<object, object>(methodName);
}
public static Func<object, object[], TReturn> GetFunc<TReturn>(this Type type, string methodName,
params Type[] paramTypes)
{
return type.GetFunc<object, TReturn>(methodName, paramTypes);
}
public static Func<object, object, TReturn> GetFunc<TReturn>(this Type type, string methodName, Type paramType)
{
return type.GetFunc<object, TReturn>(methodName, paramType);
}
public static Func<object, TReturn> GetFunc<TReturn>(this Type type, string methodName)
{
return type.GetFunc<object, TReturn>(methodName);
}
public static Func<TObject, object[], TReturn> GetFunc<TObject, TReturn>(this Type type, string methodName,
params Type[] paramTypes)
{
return type.GetMethodInfo(methodName, paramTypes)?
.CreateDelegate<Func<TObject, object[], TReturn>>(false);
}
public static Func<TObject, object, TReturn> GetFunc<TObject, TReturn>(this Type type, string methodName,
Type paramType)
{
return type.GetMethodInfo(methodName, paramType)?
.CreateDelegate<Func<TObject, object, TReturn>>(false);
}
public static Func<TObject, TReturn> GetFunc<TObject, TReturn>(this Type type, string methodName)
{
return type.GetMethodInfo(methodName)?.CreateDelegate<Func<TObject, TReturn>>(false);
}
public static Func<TObject, TParam, TReturn> GetFunc<TObject, TParam, TReturn>(this Type type,
string methodName)
{
return GetMethodInfo(type, methodName, typeof(TParam))?
.CreateDelegate<Func<TObject, TParam, TReturn>>(false);
}
public static Func<TObject, TParam1, TParam2, TReturn> GetFunc<TObject, TParam1, TParam2, TReturn>(
this Type type, string methodName)
{
return type.GetMethodInfo(methodName, typeof(TParam1), typeof(TParam2))?
.CreateDelegate<Func<TObject, TParam1, TParam2, TReturn>>(false);
}
public static Func<TObject, TParam1, TParam2, TParam3, TReturn> GetFunc<TObject, TParam1, TParam2, TParam3,
TReturn>(this Type type, string methodName)
{
return type.GetMethodInfo(methodName, typeof(TParam1), typeof(TParam2), typeof(TParam3))?
.CreateDelegate<Func<TObject, TParam1, TParam2, TParam3, TReturn>>(false);
}
}
}