/// <summary> /// Each option found will be executed. Before execution the validation will be called /// and if it reports true (validation ok) the option's execute operation will be done. /// </summary> /// <param name="args"></param> public void ExecuteOperation(string[] args = null) { if (HaveArgumentsBeenParsed == false) { Parse(args); } // Do we show the altnerate (user title?) if ((HasShowTitleAndDescriptionsOnNoAction) && (HasOperationActionToDo == false)) { TitleAction?.Invoke(this); DescriptionActionBefore?.Invoke(this); DescriptionAction?.Invoke(this); DescriptionActionAfter?.Invoke(this); } if (HasOperationActionToDo) { PreAction?.Invoke(this); Options.Where(opt => opt.ArgumentMatched) .ToList() .ForEach(option => { if ((option?.Validation?.Invoke(this) ?? true) && (option?.ValidationExtra?.Invoke(this, option) ?? true)) { option?.Operation?.Invoke(this); } }); PostAction?.Invoke(this); } }
public MenuItem(string name, string desc, MenuAction action = null, DescriptionAction descAct = null) { Name = name; Action = action; Description = desc; DescAction = descAct; Items = new List <MenuItem>(); }