コード例 #1
0
        void ExecuteCommandType(Type cmdT, string[] args)
        {
            ICLICommand o = (ICLICommand)Activator.CreateInstance(cmdT);

            o.OnQuit += (object sender, EventArgs e) => QuitCommand();
            o.Execute(args);
        }
コード例 #2
0
ファイル: CLICommands.cs プロジェクト: ignatandrei/WebAPI2CLI
        /// <summary>
        /// Adds the command to the list of the commands
        /// </summary>
        /// <param name="cmd">The command.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentException">unsupported type {cmd?.GetType()}</exception>
        public CLI_Commands AddCommand(ICLICommand cmd)
        {
            if (cmd is CLICommand_v1 v)
            {
                Commands_v1.Add(v);
                return(this);
            }

            throw new ArgumentException($"unsupported type {cmd?.GetType()}");
        }
コード例 #3
0
        internal IUIOption FindOption(ICLICommand command)
        {
            if (OptionCollection == null)
            {
                throw new InvalidOperationException($"{nameof(OptionCollection)} cannot be null while processing options.");
            }

            //tolist prevents potential errors from editing the list
            foreach (var option in OptionCollection.ActiveOptions.ToList())
            {
                if (option.IsMatch(command))
                {
                    return(option);
                }
            }
            return(null);
        }
コード例 #4
0
 public void Select(ICLICommand command) => SelectFunc?.Invoke(command);
コード例 #5
0
 public abstract bool IsMatch(ICLICommand command);
コード例 #6
0
ファイル: ReturnValue.cs プロジェクト: ignatandrei/WebAPI2CLI
 internal ReturnValue_v1 FromCommand(ICLICommand cmd)
 {
     this.Command = cmd;
     return(this);
 }
コード例 #7
0
 internal CommandEvent(ICLICommand command, IUIOption opt)
 {
     Command = command;
     Option  = opt;
 }
コード例 #8
0
ファイル: CommandSet.cs プロジェクト: mstickland/MX-Util
 public bool IsMatch(ICLICommand command)
 {
     return(MatchFunc(command));
 }
コード例 #9
0
ファイル: CommandSet.cs プロジェクト: mstickland/MX-Util
 public bool IsMatch(ICLICommand command)
 {
     return(TriggerCommands.Any(c => String.Equals(c, command.Command, StringComparison.OrdinalIgnoreCase)));
 }
コード例 #10
0
ファイル: AutoOption.cs プロジェクト: mstickland/MX-Util
 public override bool IsMatch(ICLICommand command)
 {
     return((UseShortcutCharacter && StrCompare(command.Command, CleanTitle[ShortcutCharacterIndex].ToString())) ||
            (UsePrefixNumber && StrCompare(command.Command, PrefixNumber.ToString())));
 }