/// <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);
            }
        }
Пример #2
0
        /// <exception cref="T:System.Exception">Condition.</exception>
        public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result)
        {
            try
            {
                PreAction?.Invoke();

                base.TryInvokeMember(binder, args, out result);

                PostAction?.Invoke();

                return(true);
            }
            catch (Exception e)
            {
                ResponseOnFailure?.Invoke(e);
                throw;
            }
        }
Пример #3
0
 public override void Apply()
 {
     ps.SetValue(sender, value_new);
     PostAction?.Invoke();
 }
Пример #4
0
 public void RunAction()
 {
     PreAction?.Invoke(this, new MessageEventArgs("Pre - RunAction"));
     //Action();
     PostAction?.Invoke(this, new MessageEventArgs("Post - RunAction"));
 }