private void Execute(CommandMap <Command> map, params string[] prms) { if (prms.Length == 0) { return; } var cmd = map[prms[0]]; if (cmd == null) { return; } cmd(prms.Skip(1).ToArray()); }
public ConsoleCommander( ScheduleService service, Func <string, string> requestInput, Action <string> writeln) { mainCommandsMap = new CommandMap <MainCommand> { [CREATE] = Create, [GET] = Get, [DELETE] = Delete }; createCommandsMap = new CommandMap <Command> { [DEMO] = CreateDemo(service, requestInput, writeln), [STUDENT] = CreateStudent(service, requestInput), [CLASS] = CreateClass(service, requestInput), [LESSON] = CreateLesson(service, requestInput), [TEACHER] = CreateTeacher(service, requestInput), [TEACHER_LESSON] = CreateTeacherLesson(service, requestInput), [EXERCISE] = CreateExercise(service, requestInput) }; getCommandsMap = new CommandMap <Command> { [STUDENTS] = GetStudents(service, writeln), [CLASSES] = GetClasses(service, writeln), [LESSONS] = GetLessons(service, writeln), [TEACHERS] = GetTeachers(service, writeln), [TEACHER_SCHEDULE] = GetTeacherSchedule(service, requestInput, writeln), [CLASS_SCHEDULE] = GetClassSchedule(service, requestInput, writeln), [FULL_SCHEDULE] = GetFullSchedule(service, writeln), }; deleteCommandsMap = new CommandMap <Command> { [STUDENT] = DeleteStudent(service, requestInput), [CLASS] = DeleteClass(service, requestInput), [LESSON] = DeleteLesson(service, requestInput), [TEACHER] = DeleteTeacher(service, requestInput), [TEACHER_LESSON] = DeleteTeacherLesson(service, requestInput), [EXERCISE] = DeleteExercise(service, requestInput), [ALL] = DeleteAll(service, requestInput) }; }