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"); }
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)); }
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)); } }
public ICommand AddCommand(Action action) { return(AddCommand(MethodCommandFactory.Create(action.Method, action.Target))); }
public ICommand AddCommand <T1, T2, T3>(Action <T1, T2, T3> action) { return(AddCommand(MethodCommandFactory.Create(action.Method, action.Target))); }