예제 #1
0
        public void ShouldPreserveException()
        {
            var    cmd = MethodCommandFactory.Create(Cmd);
            Action act = () => cmd.Execute(new SimpleCommandContext(new ParsedCommand("cmd", Enumerable.Empty <ParsedParameter>())));

            act.ShouldThrowExactly <ApplicationException>().And.Message.Should().Be("test");
        }
예제 #2
0
        private static IEnumerable <ICommand> FindMethodCommandsOnInstanceInternal(object inst)
        {
            Type type = inst.GetType();

            return(from method in type.GetMethods().Where(m => !m.IsStatic)
                   let attr = method.GetCustomAttribute <CommandAttribute>()
                              where attr != null
                              select MethodCommandFactory.Create(method, inst));
        }
예제 #3
0
        private static IEnumerable <ICommand> FindStaticMethodCommandsInternal(Type type)
        {
            foreach (MethodInfo method in type.GetMethods(
                         BindingFlags.NonPublic |
                         BindingFlags.Public |
                         BindingFlags.Static).Where(m => (m.IsStatic)))
            {
                var attr = method.GetCustomAttribute <CommandAttribute>();
                if (attr == null)
                {
                    continue;
                }

                yield return(MethodCommandFactory.Create(method));
            }
        }
예제 #4
0
 public ICommand AddCommand(Action action)
 {
     return(AddCommand(MethodCommandFactory.Create(action.Method, action.Target)));
 }
예제 #5
0
 public ICommand AddCommand <T1, T2, T3>(Action <T1, T2, T3> action)
 {
     return(AddCommand(MethodCommandFactory.Create(action.Method, action.Target)));
 }