private static object CallInstance(Type classType, string funcName, MonoTargetType targetType, string[] args)
        {
            MethodInfo[] methods = ExtractMethods(classType, funcName);
            MethodInfo   method  = GetIdealOverload(methods, false, args.Length);

            object[]             parsedArgs = CreateArgs(method, args);
            IEnumerable <object> targets    = InvocationTargetFactory.FindTargets(classType, targetType);

            return(InvocationTargetFactory.InvokeOnTargets(method, targets, parsedArgs));
        }
Пример #2
0
 private static object InvokeAndUnwrapException(this MethodInfo method, IEnumerable <object> targets, object[] args)
 {
     try
     {
         return(InvocationTargetFactory.InvokeOnTargets(method, targets, args));
     }
     catch (TargetInvocationException e)
     {
         throw e.InnerException;
     }
 }
Пример #3
0
        private static IEnumerator <ICommandAction> KillAction()
        {
            Robot robot = default;
            IEnumerable <Robot> robots = InvocationTargetFactory.FindTargets <Robot>(MonoTargetType.All);

            yield return(new Value("Please select a robot"));

            yield return(new Choice <Robot>(robots, r => robot = r));

            robot.Die();
            yield return(new Typewriter($"{robot.name} has been killed"));
        }
        private static object CallInstance(
            [CommandParameterDescription("Namespace qualified typename of the class.")] Type classType,
            [CommandParameterDescription("Name of the method or property.")] string funcName,
            [CommandParameterDescription("The MonoTargetType used to find the target instances.")] MonoTargetType targetType,
            [CommandParameterDescription("The arguments for the function call.")] string[] args,
            [CommandParameterDescription("The types of the arguments to resolve ambiguous overloads.")] Type[] argTypes)
        {
            MethodInfo[] methods = ExtractMethods(classType, funcName);
            MethodInfo   method  = GetIdealOverload(methods, false, argTypes);

            object[]             parsedArgs = CreateArgs(method, argTypes, args);
            IEnumerable <object> targets    = InvocationTargetFactory.FindTargets(classType, targetType);

            return(InvocationTargetFactory.InvokeOnTargets(method, targets, parsedArgs));
        }