Beispiel #1
0
 public void ToAction(CommandActionEventHandler action)
 {
     foreach (var name in names)
     {
         actionList[name] = action;
     }
 }
Beispiel #2
0
        public async Task ParseAsync(params string[] args)
        {
            var argList = new List <string>(args);

            CommandActionEventHandler action = null;

            if (argList.Count > 0 && ActionList.TryGetValue(argList[0], out action))
            {
                argList.RemoveAt(0);
            }

            for (var i = argList.Count - 1; i >= 0; i--)
            {
                var arg = argList[i];

                string value = null;
                var    x     = arg.IndexOf('=');

                if (x >= 0)
                {
                    value = arg.Substring(x + 1).Trim('\"');
                    arg   = arg.Substring(0, x);
                }

                if (!PropertyList.TryGetValue(arg, out var propertyAction))
                {
                    continue;
                }
                await propertyAction(value);

                argList.RemoveAt(i);
            }

            if (action != null)
            {
                await action(argList.ToArray());
            }
            else if (ActionRequired)
            {
                throw new ApplicationException("No action specified!");
            }
        }
Beispiel #3
0
 //public Command(Name name, string text, string image, string tooltip, CommandActionBase action)
 //    : this(name, text, image, tooltip, (action != null) ? new CommandActionEventHandler(action.Execute) : null ) { }
 public Command(Name name, string text, string image, string tooltip, CommandActionEventHandler action)
 {
     InnerName = name;
     InnerText = text;
     InnerImage = (image ?? DefaultImage);
     InnerToolTip = (tooltip ?? text);
     InnerAction = action;
     InnerEnabled = true;
 }
Beispiel #4
0
 public Command(Name name, string text, string image, CommandActionEventHandler action)
     : this(name, text, image, null, action)
 {
 }
Beispiel #5
0
 //..................................................................
 public Command(Name name, CommandActionEventHandler action)
     : this(name, null, null, null, action)
 {
 }