BlingBag.BlingDispatcherBase.InvokeMethod C# (CSharp) Метод

InvokeMethod() приватный Метод

private InvokeMethod ( string methodName, object invokableObject, object methodArg ) : System.Threading.Tasks.Task
methodName string
invokableObject object
methodArg object
Результат System.Threading.Tasks.Task
        async Task InvokeMethod(string methodName, object invokableObject, object methodArg)
        {
            try
            {
                MethodInfo handlerMethod =
                    invokableObject.GetType()
                        .GetMethods()
                        .FirstOrDefault(
                            x =>
                                x.Name == methodName &&
                                x.GetParameters().Any(p => p.ParameterType == methodArg.GetType()));

                if (handlerMethod == null) throw new Exception("No matching 'Handle' method found on handler.");

                await (Task) handlerMethod.Invoke(invokableObject, new[] {methodArg});
            }
            catch (AggregateException ex)
            {
                throw ex.InnerException;
            }
            catch (TargetInvocationException ex)
            {
                throw ex.InnerException;
            }
            catch (Exception ex)
            {
                throw ex.GetBaseException();
            }
        }