static Route GetRoute(IEnumerable <Route> routes, CommandDef command) { var route = routes.FirstOrDefault(r => r.Name == command.Name); if (route == null) { throw new RouteNotFoundException(command.Name, command.Arguments); } return(route); }
WorkCreator(Route route, CommandDef commandDef) { if (!typeof(T).IsAssignableFrom(route.Type)) { throw new ArgumentException(string.Format("Cannot assign {0} to {1}.", route.Type, typeof(T))); } ctor = route.Type.GetConstructor(new [] { typeof(string) }) ?? route.Type.GetConstructor(Type.EmptyTypes); arguments = ctor.GetParameters().Length == 0 ? new object[0] : new object[] { commandDef.Arguments }; }
public CommandRouteInterpretter(CommandDef command) { if (command == null) { throw new ArgumentNullException("command"); } if (command.Arguments == null) { throw new ArgumentNullException("command.Arguments"); } this.command = command; }
public void TestInitialize() { Parser = new CommandParser(Command); CommandDef = Parser.Parse(); }
public static T Create(Route route, CommandDef commandDef) { return(new WorkCreator <T>(route, commandDef).Create()); }
protected void TestInitialize(CommandDef commandDef) { Interpretter = new CommandRouteInterpretter(commandDef); Route = Interpretter.GetRoute(); }