Exemplo n.º 1
0
        public FunctionCommand(MethodInfo command, object obj = null, int?requiredParameters = null)
        {
            internCommand    = command;
            CommandParameter = command.GetParameters().Select(p => p.ParameterType).ToArray();
            CommandReturn    = command.ReturnType;

            callee = obj;
            // Require all parameters by default
            NormalParameters   = CommandParameter.Count(p => !SpecialTypes.Contains(p));
            RequiredParameters = requiredParameters ?? NormalParameters;
        }
Exemplo n.º 2
0
        public FunctionCommand(MethodInfo command, object obj = null, int?requiredParameters = null)
        {
            internCommand    = command;
            CommandParameter = command.GetParameters().Select(p => new ParamInfo(p, ParamKind.Unknown, p.IsOptional || p.GetCustomAttribute <ParamArrayAttribute>() != null)).ToArray();
            PrecomputeTypes();
            CommandReturn = command.ReturnType;

            callee = obj;

            NormalParameters   = CommandParameter.Count(p => p.kind.IsNormal());
            RequiredParameters = requiredParameters ?? CommandParameter.Count(p => !p.optional && p.kind.IsNormal());
        }
Exemplo n.º 3
0
        public FunctionCommand(MethodInfo command, object?obj = null, int?requiredParameters = null)
        {
            internCommand    = command;
            CommandParameter = PrecomputeTypes(command.GetParameters());
            CommandReturn    = command.ReturnType;
            if (CommandReturn.IsConstructedGenericType && CommandReturn.GetGenericTypeDefinition() == typeof(Task <>))
            {
                taskValueProp = CommandReturn.GetProperty(nameof(Task <object> .Result));
            }
            isPlainTask = CommandReturn == typeof(Task);

            callee = obj;

            NormalParameters   = CommandParameter.Count(p => p.Kind.IsNormal());
            RequiredParameters = requiredParameters ?? CommandParameter.Count(p => !p.Optional && p.Kind.IsNormal());
        }