/// <summary>Creates the command handler.</summary>
        /// <returns>CommandHandler that refers to all the commands via chain of responsibility.</returns>
        private static CommandHandlerBase CreateCommandHandler()
        {
            var createHandler = new CreateCommandHandler(fileCabinetService);
            var purgeHandler  = new PurgeCommandHandler(fileCabinetService);
            var statHandler   = new StatCommandHandler(fileCabinetService);
            var exportHandler = new ExportCommandHandler(fileCabinetService);
            var importHandler = new ImportCommandHandler(fileCabinetService);
            var exitHandler   = new ExitCommandHandler(b => isRunning = b);
            var missedHandler = new MissedCommandHandler();
            var insertHandler = new InsertCommandHandler(fileCabinetService);
            var deleteHandler = new DeleteCommandHandler(fileCabinetService);
            var updateHandler = new UpdateCommandHandler(fileCabinetService);
            var selectHandler = new SelectCommandHandler(fileCabinetService);

            exitHandler.SetNext(missedHandler);
            importHandler.SetNext(exitHandler);
            exportHandler.SetNext(importHandler);
            statHandler.SetNext(exportHandler);
            purgeHandler.SetNext(statHandler);
            createHandler.SetNext(purgeHandler);
            updateHandler.SetNext(createHandler);
            deleteHandler.SetNext(updateHandler);
            selectHandler.SetNext(deleteHandler);
            insertHandler.SetNext(selectHandler);
            return(insertHandler);
        }
Ejemplo n.º 2
0
        private static ICommandHandler CreateCommandHandler()
        {
            var createHandler = new CreateComanndHandler(Program.fileCabinetService, inputValidator);
            var exitHandler   = new ExitComanndHandler(x => isRunning = x);
            var exportHandler = new ExportComanndHandler(Program.fileCabinetService);
            var helpHandler   = new HelpComanndHandler();
            var importHandler = new ImportComanndHandler(Program.fileCabinetService);
            var missedHandler = new MissedComanndHandler();
            var purgeHandler  = new PurgeComanndHandler(Program.fileCabinetService);
            var statHandler   = new StatComanndHandler(Program.fileCabinetService);
            var selectHandler = new SelectComanndHandler(Program.fileCabinetService, new CustomRecordPrinter());
            var insertHandler = new InserCommandHandler(Program.fileCabinetService);
            var deleteHandler = new DeleteCommandHandler(Program.fileCabinetService);
            var updateHandler = new UpdateCommandHandler(Program.fileCabinetService);

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

            return(helpHandler);
        }
Ejemplo n.º 3
0
        private static ICommandHandler CreateCommandHandlers(IFileCabinetService fileCabinetService)
        {
            ICommandHandler createCommandHandler = new CreateCommandHandler(fileCabinetService);
            ICommandHandler updateCommandHandler = new UpdateCommandHandler(fileCabinetService);
            ICommandHandler deleteCommandHandler = new DeleteCommandHandler(fileCabinetService);
            ICommandHandler selectCommand        = new SelectCommandHandler(fileCabinetService, Program.PrinterByFilter);
            ICommandHandler statCommandHandler   = new StatCommandHandler(fileCabinetService);
            ICommandHandler exportCommandHandler = new ExportCommandHandler(fileCabinetService);
            ICommandHandler importCommandHandler = new ImportCommandHandler(fileCabinetService);
            ICommandHandler purgeCommandHandler  = new PurgeCommandHandler(fileCabinetService);
            ICommandHandler helpCommandHandler   = new HelpCommandHandler();
            ICommandHandler exitCommandHandler   = new ExitCommandHandler(Existing);
            ICommandHandler insertCommandHandler = new InsertCommandHandler(fileCabinetService);

            createCommandHandler.SetNext(updateCommandHandler);
            updateCommandHandler.SetNext(deleteCommandHandler);
            deleteCommandHandler.SetNext(selectCommand);
            selectCommand.SetNext(statCommandHandler);
            statCommandHandler.SetNext(exportCommandHandler);
            exportCommandHandler.SetNext(importCommandHandler);
            importCommandHandler.SetNext(purgeCommandHandler);
            purgeCommandHandler.SetNext(helpCommandHandler);
            helpCommandHandler.SetNext(exitCommandHandler);
            exitCommandHandler.SetNext(insertCommandHandler);

            return(createCommandHandler);
        }
Ejemplo n.º 4
0
        private static CommandHandlerBase CreateCommandHandlers(IFileCabinetService service)
        {
            var helpCommandHandler        = new HelpCommandHandler();
            var createCommandHandler      = new CreateCommandHandler(service);
            var exitCommandHandler        = new ExitCommandHandler(ChangeRunning, fileStream);
            var exportCommandHandler      = new ExportCommandHandler(service);
            var importCommandHandler      = new ImportCommandHandler(service);
            var purgeCommandHandler       = new PurgeCommandHandler(service);
            var statCommandHandler        = new StatCommandHandler(service);
            var insertCommandHandler      = new InsertCommandHandler(service);
            var deleteCommandHandler      = new DeleteCommandHandler(service);
            var selectCommandHandler      = new SelectCommandHandler(service);
            var updateCommandHandler      = new UpdateCommandHandler(service);
            var printMissedCommandHandler = new PrintMissedCommandHandler();

            helpCommandHandler.SetNext(createCommandHandler);
            createCommandHandler.SetNext(exitCommandHandler);
            exitCommandHandler.SetNext(exportCommandHandler);
            exportCommandHandler.SetNext(importCommandHandler);
            importCommandHandler.SetNext(purgeCommandHandler);
            purgeCommandHandler.SetNext(statCommandHandler);
            statCommandHandler.SetNext(insertCommandHandler);
            insertCommandHandler.SetNext(deleteCommandHandler);
            deleteCommandHandler.SetNext(updateCommandHandler);
            updateCommandHandler.SetNext(selectCommandHandler);
            selectCommandHandler.SetNext(printMissedCommandHandler);
            return(helpCommandHandler);
        }
Ejemplo n.º 5
0
        private static ICommandHandler CreateCommandHandlers()
        {
            var recordPrinte  = new DefaultRecordPrinter();
            var helpHandler   = new HelpCommandHandler();
            var createHandler = new CreateCommandHandler(fileCabinetService);
            var purgeHandler  = new PurgeCommandHandler(fileCabinetService);
            var exitHandler   = new ExitCommandHandler(ChangeStatus);
            var exportHandler = new ExportCommandHandler(fileCabinetService);
            var statHandler   = new StatCommandHandler(fileCabinetService);
            var insertHandler = new InsertCommandHandler(fileCabinetService);
            var deleteHandler = new DeleteCommandHandler(fileCabinetService);
            var updateHandler = new UpdateCommandHandler(fileCabinetService);
            var selectHandler = new SelectCommandHandler(fileCabinetService, Console.WriteLine);

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

            return(helpHandler);
        }