public object Invoke(object arg0, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, object arg8) { if (cache.TryGet(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, out var result)) { return(result(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)); } var method = Dispatch.BindToMethod(BindingFlags.Public | BindingFlags.Instance, Target, MemberName, new [] { arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8 }); if (method != null) { var f = DelegateHelpers.GetMethodDelegate09(method); cache.CacheMethod(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, f); return(f(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)); } throw new ArgumentException($"Could not invoke static method `{MemberName}` on type {Target} with argument types {arg0.GetType()}, {arg1.GetType()}, {arg2.GetType()}, {arg3.GetType()}, {arg4.GetType()}, {arg5.GetType()}, {arg6.GetType()}, {arg7.GetType()}, {arg8.GetType()}."); }
public object Invoke(object target, object arg0, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7) { if (cache.TryGet(target, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, out var result)) { return(result(target, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7)); } var method = Dispatch.BindToMethod(BindingFlags.Public | BindingFlags.Instance, target.GetType(), MemberName, new [] { arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7 }); if (method != null) { var f = DelegateHelpers.GetMethodDelegate09(method); cache.CacheMethod(target, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, f); return(f(target, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7)); } throw new ArgumentException($"Could not invoke instance member method `{MemberName}` on target {target.ToString()} ({target.GetType()}) with argument types {arg0.GetType()}, {arg1.GetType()}, {arg2.GetType()}, {arg3.GetType()}, {arg4.GetType()}, {arg5.GetType()}, {arg6.GetType()}, {arg7.GetType()}."); }
public T Invoke(object arg0, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, object arg8) { if (cache.TryGet(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, out var result)) { return((T)result(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)); } var ctor = Dispatch.BindToConstructor(typeof(T), new [] { arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8 }); if (ctor != null) { var f = DelegateHelpers.GetMethodDelegate09(ctor); cache.CacheMethod(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, f); return((T)f(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)); } throw new ArgumentException($"Could not invoke constructor `{typeof(T)}` with types {arg0.GetType()}, {arg1.GetType()}, {arg2.GetType()}, {arg3.GetType()}, {arg4.GetType()}, {arg5.GetType()}, {arg6.GetType()}, {arg7.GetType()}, {arg8.GetType()}."); }