Exemple #1
0
        private static ICommandHandler CreateCommandHandlers()
        {
            Action <IEnumerable <FileCabinetRecord> > printer;

            printer = DefaultRecordPrint;
            var recordPrinter = new DefaultRecordPrinter();
            var createHandler = new CreateCommandHandler(Program.fileCabinetService);
            var editHandler   = new EditCommandHandler(Program.fileCabinetService);
            var exitHandler   = new ExitCommandHandler(stopProgram);
            var exportHandler = new ExportCommandHandler(Program.fileCabinetService);
            var findHandler   = new FindCommandHandler(
                Program.fileCabinetService, printer);
            var helpHandler   = new HelpCommandHandler();
            var importHandler = new ImportCommandHandler(Program.fileCabinetService);
            var listHandler   = new ListCommandHandler(
                Program.fileCabinetService, printer);
            var purgeHandler   = new PurgeCommandHandler(Program.fileCabinetService);
            var removeHandler  = new RemoveCommandHandler(Program.fileCabinetService);
            var statHandler    = new StatCommandHandler(Program.fileCabinetService);
            var defaultHandler = new DefaultHandler();

            createHandler.SetNext(editHandler);
            editHandler.SetNext(exitHandler);
            exitHandler.SetNext(exportHandler);
            exportHandler.SetNext(findHandler);
            findHandler.SetNext(helpHandler);
            helpHandler.SetNext(importHandler);
            importHandler.SetNext(listHandler);
            listHandler.SetNext(purgeHandler);
            purgeHandler.SetNext(removeHandler);
            removeHandler.SetNext(statHandler);
            statHandler.SetNext(defaultHandler);
            return(createHandler);
        }
Exemple #2
0
        private static ICommandHandler CreateCommandHandlers()
        {
            var recordPrinter = new DefaultRecordPrinter();
            var createHandler = new CreateCommandHandler(fileCabinetService);
            var selectHandler = new SelectCommandHandler(fileCabinetService);
            var statHandler   = new StatCommandHandler(fileCabinetService);
            var exportHandler = new ExportCommandHandler(fileCabinetService);
            var importHandler = new ImportCommandHandler(fileCabinetService);
            var insertHandler = new InsertCommandHandler(fileCabinetService);
            var deleteHandler = new DeleteCommandHandler(fileCabinetService);
            var updateHandler = new UpdateCommandHandler(fileCabinetService);
            var purgeHandler  = new PurgeCommandHandler(fileCabinetService);
            var helpHandler   = new HelpCommandHandler();
            var exitHandler   = new ExitCommandHandler(ChangeState);

            createHandler.SetNext(insertHandler)
            .SetNext(selectHandler)
            .SetNext(deleteHandler)
            .SetNext(updateHandler)
            .SetNext(statHandler)
            .SetNext(exportHandler)
            .SetNext(importHandler)
            .SetNext(purgeHandler)
            .SetNext(helpHandler)
            .SetNext(exitHandler);

            return(createHandler);
        }
Exemple #3
0
        private static ICommandHandler CreateCommandHandlers()
        {
            IRecordPrinter recordPrinter = new DefaultRecordPrinter();

            var create = new CreateCommandHandler(fileCabinetService);
            var exit   = new ExitCommandHandler(Exit);
            var stat   = new StatCommanHandler(fileCabinetService);
            var help   = new PrintHelpCommandHandler();
            var edit   = new EditCommandHandler(fileCabinetService);
            var find   = new FindCommandHandler(fileCabinetService, DefaultRecordPrint);
            var export = new ExportCommandHandler(fileCabinetService);
            var import = new ImportCommandHandler(fileCabinetService);
            var remove = new RemoveCommandHandler(fileCabinetService);
            var purge  = new PurgeCommandHandler(fileCabinetService);

            create.SetNext(exit).SetNext(stat).SetNext(edit).SetNext(find).SetNext(export).SetNext(import).SetNext(remove).SetNext(purge).SetNext(help);

            return(create);
        }