System.Func.Invoke(ZeroCommandContext)

Here are the examples of the csharp api System.Func.Invoke(ZeroCommandContext) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

2 Examples 7

19 Source : ZeroCommand.cs
with MIT License
from nightlybuilds-net

private async Task<bool> EvaluateBeforeRun()
        {
            var beforeRun = true;
            if (this._beforeExecuteAsync != null)
                beforeRun = await this._beforeExecuteAsync.Invoke(this._context);

            if (this._beforeExecute != null)
                beforeRun = this._beforeExecute.Invoke(this._context);

            if (this._validate != null)
                beforeRun = this._validate.Invoke(this._context);

            if (this._validateAsync != null)
                beforeRun = await this._validateAsync.Invoke(this._context);

            return beforeRun;
        }

19 Source : ZeroCommand.cs
with MIT License
from nightlybuilds-net

public async void Execute(object parameter)
        {
            this.IsExecuting = true;
            if (this._autoCanExecute) this.RaiseEvaluateCanExecute();

            await this._concurrentSemapreplaced.WaitAsync();

            var beforeRunEvaluation = true;
            try
            {
                beforeRunEvaluation = await this.EvaluateBeforeRun();
                if (!beforeRunEvaluation)
                    return;

                if (this._asyncAction != null)
                    await this._asyncAction.Invoke((T)parameter, this._context);

                this._action?.Invoke((T)parameter, this._context);
            }
            catch (Exception e)
            {
                if (this._onErrorAsync != null)
                    await this._onErrorAsync?.Invoke(e);

                this._onError?.Invoke(e);

                if (this._onErrorAsync == null && this._onError == null && !this._swallowException)
                    throw;
            }
            finally
            {
                if (beforeRunEvaluation)
                {
                    if (this._afterExecuteAsync != null)
                        await this._afterExecuteAsync?.Invoke(this._context);

                    this._afterExecute?.Invoke(this._context);
                }

                this._concurrentSemapreplaced.Release();
                this.IsExecuting = false;
                if (this._autoCanExecute) this.RaiseEvaluateCanExecute();
            }
        }