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