예제 #1
0
        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);
        }
예제 #2
0
 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 };
 }
예제 #3
0
 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();
 }
예제 #5
0
 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();
 }
 public void TestInitialize()
 {
    Parser = new CommandParser(Command);
    CommandDef = Parser.Parse();
 }