public void Options_are_not_built_for_infrastructure_types_exposed_by_method_parameters(Type type)
        {
            var targetType = typeof(ClassWithMethodHavingParameter <>).MakeGenericType(type);

            var target = Activator.CreateInstance(targetType);

            var binder = new MethodBinder(
                targetType.GetMethod(nameof(ClassWithMethodHavingParameter <int> .Handle)),
                () => target);

            var options = binder.BuildOptions();

            options.Should()
            .NotContain(o => o.Argument.ArgumentType == type);
        }
Exemplo n.º 2
0
        public static void ConfigureFromMethod(
            this Command command,
            MethodInfo method,
            Func <object> target)
        {
            if (command == null)
            {
                throw new ArgumentNullException(nameof(command));
            }

            if (method == null)
            {
                throw new ArgumentNullException(nameof(method));
            }

            var handler = new MethodBinder(method, target);

            foreach (var option in handler.BuildOptions())
            {
                command.AddOption(option);
            }

            command.Handler = handler;
        }