Beispiel #1
0
    /// <summary>
    /// Makes this Builder an InformationCommand-Builder.
    /// </summary>
    /// <returns><see cref="InformationCommandBuilder"/>.</returns>
    public InformationCommandBuilder InInformationMode()
    {
        var command = new InformationCommand();

        Command = command;
        return(new InformationCommandBuilder(ref command));
    }
Beispiel #2
0
 /// <summary>
 /// コンストラクタ
 /// </summary>
 public MainWindowViewModel()
 {
     ConfirmationCommand.Subscribe(ConfirmationMethod).AddTo(Disposable);
     InformationCommand.Subscribe(_ => ShowInformationDialog("メッセージ", "タイトル", MessageBoxImage.Error)).AddTo(Disposable);
     OpenFileCommand.Subscribe(OpenFileMethod).AddTo(Disposable);
     SaveFileCommand.Subscribe(SaveFileMethod).AddTo(Disposable);
     ClosedCommand.Subscribe(Close).AddTo(Disposable);
 }
Beispiel #3
0
        private static async Task Run(CommandProcessor commandProcessor)
        {
            var informationCommand = new InformationCommand();
            await commandProcessor.SendAsync(informationCommand);

            var fetchDataFromUrlCommand = new FetchDataFromUrlCommand(informationCommand.Url);
            await commandProcessor.SendAsync(fetchDataFromUrlCommand);

            var parseDataFromHtmlCommand = new ParseDataFromHtmlCommand(fetchDataFromUrlCommand.Html);
            await commandProcessor.SendAsync(parseDataFromHtmlCommand);

            var bestMatchCarParkCommand = new BestMatchCarParkCommand(parseDataFromHtmlCommand.CarParks);
            await commandProcessor.SendAsync(bestMatchCarParkCommand);

            var carParkToOutputCommand = new CarParkToOutputCommand(bestMatchCarParkCommand.BestMatch);
            await commandProcessor.SendAsync(carParkToOutputCommand);

            Console.WriteLine(carParkToOutputCommand.Output);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="InformationCommandBuilder"/> class.
 /// </summary>
 /// <param name="command">The command.</param>
 internal InformationCommandBuilder(ref InformationCommand command)
 {
     this.command = command;
 }
Beispiel #5
0
        private static void ArgsToCommandList(string[] args)
        {
            for (int i = 0; i < args.Length; i++)
            {
                int      next = i + 1;
                ICommand option;
                switch (args[i].Replace("-", "").Substring(0, 1))
                {
                case "v":
                    option = new VersionCommand();
                    if (_options.ContainsKey("v") == false)
                    {
                        _options.Add("v", option);
                    }
                    break;

                case "i":
                    option = new InformationCommand();
                    if (_options.ContainsKey("i") == false)
                    {
                        _options.Add("i", option);
                    }
                    break;

                case "?":
                    option = new InformationCommand();
                    if (_options.ContainsKey("i") == false)
                    {
                        _options.Add("i", option);
                    }
                    break;

                case "h":
                    if (args[i] == "--help")
                    {
                        option = new InformationCommand();
                        if (_options.ContainsKey("i") == false)
                        {
                            _options.Add("i", option);
                        }
                    }
                    else if (args[i] == "-hostname" || args[i].Split('=')[0] == "--host")
                    {
                        OrchestratorConfig.HostName = args[next];
                    }
                    break;

                case "H":
                    OrchestratorConfig.HostName = args[next];
                    break;

                case "f":
                    break;

                case "U":
                    OrchestratorConfig.UserId = args[next];
                    break;

                case "W":
                    OrchestratorConfig.Password = args[next];
                    break;

                case "T":
                    OrchestratorConfig.TenantName = args[next];
                    break;

                case "C":
                    OrchestratorConfig.Commands = args[next].Split(',').ToList <string>();
                    option = new OrchestratorCommand();
                    if (_options.ContainsKey("c") == false)
                    {
                        _options.Add("c", option);
                    }
                    break;

                default:
                    break;
                }
            }

            if (CommandManager._options.Count == 0 ||
                CommandManager._options.ContainsKey("i"))
            {
                CommandManager._options = new Dictionary <string, ICommand>()
                {
                    { "i", new InformationCommand() }
                }
            }
            ;

            else if (CommandManager._options.ContainsKey("v"))
            {
                CommandManager._options = new Dictionary <string, ICommand>()
                {
                    { "v", new VersionCommand() }
                }
            }
            ;
        }

        #endregion
    }