last ...
This commit is contained in:
@@ -14,20 +14,17 @@ namespace xCommons.Helpers
|
|||||||
/// <param name="source"></param>
|
/// <param name="source"></param>
|
||||||
/// <param name="methodName"></param>
|
/// <param name="methodName"></param>
|
||||||
/// <param name="runtimeType"></param>
|
/// <param name="runtimeType"></param>
|
||||||
/// <param name="bindingAttr"></param>
|
|
||||||
/// <param name="args"></param>
|
/// <param name="args"></param>
|
||||||
public static void InvokeGenericMethod(
|
public static void InvokeGenericMethod(
|
||||||
this Type source,
|
this Type source,
|
||||||
string methodName,
|
string methodName,
|
||||||
Type runtimeType,
|
Type runtimeType,
|
||||||
BindingFlags bindingAttr = BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic,
|
|
||||||
params object[] args
|
params object[] args
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
var overLoads = source.GetGenericMethodInfo(
|
var overLoads = source.GetGenericMethodInfo(
|
||||||
methodName: methodName,
|
methodName: methodName
|
||||||
bindingAttr: bindingAttr
|
|
||||||
);
|
);
|
||||||
if (!overLoads.HasChild())
|
if (!overLoads.HasChild())
|
||||||
{
|
{
|
||||||
@@ -39,15 +36,7 @@ namespace xCommons.Helpers
|
|||||||
MethodInfo genericMethod = method.MakeGenericMethod(runtimeType);
|
MethodInfo genericMethod = method.MakeGenericMethod(runtimeType);
|
||||||
|
|
||||||
//
|
//
|
||||||
var gParams = new object[]
|
genericMethod.Invoke(null, args);
|
||||||
{
|
|
||||||
source
|
|
||||||
}
|
|
||||||
.Concat(args)
|
|
||||||
.ToArray();
|
|
||||||
|
|
||||||
//
|
|
||||||
genericMethod.Invoke(null, gParams);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -55,17 +44,18 @@ namespace xCommons.Helpers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="source"></param>
|
/// <param name="source"></param>
|
||||||
/// <param name="methodName"></param>
|
/// <param name="methodName"></param>
|
||||||
/// <param name="bindingAttr"></param>
|
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static List<MethodInfo> GetGenericMethodInfo(
|
public static List<MethodInfo> GetGenericMethodInfo(
|
||||||
this Type source,
|
this Type source,
|
||||||
string methodName,
|
string methodName
|
||||||
BindingFlags bindingAttr = BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
var result = source
|
var methods = source
|
||||||
.GetMethods(bindingAttr)
|
.GetMethods();
|
||||||
|
|
||||||
|
//
|
||||||
|
var result = methods
|
||||||
.Where(mi =>
|
.Where(mi =>
|
||||||
mi.Name == methodName &&
|
mi.Name == methodName &&
|
||||||
mi.IsGenericMethodDefinition)
|
mi.IsGenericMethodDefinition)
|
||||||
|
|||||||
Reference in New Issue
Block a user