18 lines
589 B
C#
18 lines
589 B
C#
using System.Reflection;
|
|
using System.Runtime.CompilerServices;
|
|
|
|
namespace AyCode.Services.Server.SignalRs;
|
|
|
|
public static class ExtensionMethods
|
|
{
|
|
public static object? InvokeMethod(this MethodInfo methodInfo, object obj, params object[]? parameters)
|
|
{
|
|
if (methodInfo.GetCustomAttribute(typeof(AsyncStateMachineAttribute)) is AsyncStateMachineAttribute isAsyncTask)
|
|
{
|
|
dynamic awaitable = methodInfo.Invoke(obj, parameters)!;
|
|
return awaitable.GetAwaiter().GetResult();
|
|
}
|
|
|
|
return methodInfo.Invoke(obj, parameters);
|
|
}
|
|
} |