Exemplo n.º 1
0
        public object Invoke(object[] paramData, Type[] genericTypeArguments)
        {
            object[] data = new object[paramData.Length + _defaultParameters.Length];
            Array.Copy(paramData, 0, data, 0, paramData.Length);
            Array.Copy(_defaultParameters, 0, data, paramData.Length, _defaultParameters.Length);

            MethodInfo invokingMethod = GetInvokingMethod(genericTypeArguments);

            if (IsStatic)
            {
                return(invokingMethod.Invoke(null, data));
            }

            IEnumerable <object> targets = InvocationTargetFactory.FindTargets(invokingMethod.DeclaringType, MonoTarget);

            return(InvocationTargetFactory.InvokeOnTargets(invokingMethod, targets, data));
        }
Exemplo n.º 2
0
        public object Invoke(object[] paramData, Type[] genericTypeArguments)
        {
            object[] data = new object[paramData.Length + _defaultParameters.Length];
            Array.Copy(paramData, 0, data, 0, paramData.Length);
            Array.Copy(_defaultParameters, 0, data, paramData.Length, _defaultParameters.Length);

            MethodInfo invokingMethod = MethodData;

            if (IsGeneric)
            {
                try { invokingMethod = MethodData.MakeGenericMethod(genericTypeArguments); }
                catch (ArgumentException) { throw new ArgumentException($"Supplied generic parameters did not satisfy the generic constraints imposed by '{CommandName}'"); }
            }

            if (IsStatic)
            {
                return(invokingMethod.Invoke(null, data));
            }
            else
            {
                IEnumerable <object> targets = InvocationTargetFactory.FindTargets(invokingMethod.DeclaringType, MonoTarget);
                return(InvocationTargetFactory.InvokeOnTargets(invokingMethod, targets, data));
            }
        }