Exemple #1
0
    private static object?[]? PrepareArguments(
        IDictionary <string, object?> parameters,
        ObjectMethodExecutor objectMethodExecutor)
    {
        var declaredParameterInfos = objectMethodExecutor.MethodParameters;
        var count = declaredParameterInfos.Length;

        if (count == 0)
        {
            return(null);
        }

        var arguments = new object?[count];

        for (var index = 0; index < count; index++)
        {
            var parameterInfo = declaredParameterInfos[index];

            if (!parameters.TryGetValue(parameterInfo.Name !, out var value))
            {
                value = objectMethodExecutor.GetDefaultValueForParameter(index);
            }

            arguments[index] = value;
        }

        return(arguments);
    }
        public static object[] PrepareArguments(
            IDictionary<string, object> actionParameters,
            ObjectMethodExecutor actionMethodExecutor)
        {
            var declaredParameterInfos = actionMethodExecutor.ActionParameters;
            var count = declaredParameterInfos.Length;
            if (count == 0)
            {
                return null;
            }

            var arguments = new object[count];
            for (var index = 0; index < count; index++)
            {
                var parameterInfo = declaredParameterInfos[index];
                object value;

                if (!actionParameters.TryGetValue(parameterInfo.Name, out value))
                {
                    value = actionMethodExecutor.GetDefaultValueForParameter(index);
                }

                arguments[index] = value;
            }

            return arguments;
        }