/// <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 string Run(string request) { Console.WriteLine($"Running {Name} started..."); string request1 = PreAction?.Invoke(request); string request2 = NextMiddleWare?.Run(request1); string request3 = PostAction?.Invoke(request2); Console.WriteLine($"Running {Name} finished..."); return(request3); }
public void RunAction() { PreAction?.Invoke(this, new MessageEventArgs("Pre - RunAction")); //Action(); PostAction?.Invoke(this, new MessageEventArgs("Post - RunAction")); }