예제 #1
0
 protected void InvokeSuccessor(string[] args, IDivLogger divLogger)
 {
     if(Successor != null)
     {
         Successor.HandleRequest(args, divLogger);
     }
 }
        public void HandleRequest(string[] args, IDivLogger divLogger)
        {
            _logger = divLogger;

            try
            {
                //Chain of responsibility pattern
                RemoveHandler removeHandler = new RemoveHandler(new GeneralFileRemover());
                CopyHandler copyHandler = new CopyHandler();
                HelpHandler helpHandler = new HelpHandler();

                removeHandler.Successor = copyHandler;
                copyHandler.Successor = helpHandler;

                removeHandler.HandleRequest(args, _logger);

            }
            catch (CommandLineEntryException exception)
            {
                _logger.Log(exception.Message, LogSeverity.High);
                _logger.Log(CommandLineUsage.Usage, LogSeverity.Low);

            }
            catch (Exception exception)
            {
                _logger.Log(exception.Message, LogSeverity.Highest);
            }
        }
예제 #3
0
        public void HandleRequest(string[] args, IDivLogger logger)
        {
            _logger = logger;

            if (IsRemoveByExtensions(args))
            {
                RemoveByExtensions(GetRootDirectory(args, 2), FromOneArgumentToTokens(args, 3));
            }
            else if (IsRemoveByFileNames(args))
            {
                RemoveByFileNames(GetRootDirectory(args, 2), FromOneArgumentToTokens(args, 3));
            }
            else if (IsRemoveByFolderName(args))
            {
                RemoveByFolderName(GetRootDirectory(args, 2), FromOneArgumentToTokens(args, 3));
            }
            else if(IsRemoveByRegularExpression(args))
            {
                RemoveByRegularExpression(GetRootDirectory(args, 2), GetArgument(args, 3));
            }
            else
            {
                InvokeSuccessor(args, logger);
            }
        }
예제 #4
0
        public void HandleRequest(string[] args, IDivLogger logger)
        {
            _logger = logger;

            if(IsCopy(args))
            {
                _logger.Log("Not yet implemented better luck next time", LogSeverity.Medium);
            }
            else
            {
                InvokeSuccessor(args, logger);
            }
        }
        public void Handle(string[] args, IDivLogger divLogger)
        {
            _logger = divLogger;

            try
            {
                PrepareHandler(args);
                _handler.Invoke();
            }
            catch (Exception exception)
            {
                _logger.Log(exception.Message, LogSeverity.Highest);
            }
        }
예제 #6
0
 public void HandleRequest(string[] args, IDivLogger logger)
 {
     _logger = logger;
     _logger.Log(CommandLineUsage.Usage, LogSeverity.Lowest);
 }