Esempio n. 1
0
        /// <summary>
        /// Execute a task if the predicate returns true.
        /// </summary>
        /// <param name="host">The host that will be used to execute the method.</param>
        /// <param name="method">The method to execute if the predicate returns true.</param>
        /// <returns>A task that represents the asynchronous operation.</returns>
        public static async Task <IHost> Else(this ElseExecuteHost host, Func <IHost, Task <IHost> > method)
        {
            if (!host.CanElseExecute)
            {
                return(host.Unwrap());
            }

            return(await method(host));
        }
Esempio n. 2
0
        /// <summary>
        /// Execute a task if the predicate returns true.
        /// </summary>
        /// <param name="host">The host that will be used to execute the method.</param>
        /// <param name="method">The method to execute if the predicate returns true.</param>
        /// <returns>The host.</returns>
        public static IHost Else(this ElseExecuteHost host, Func <IHost, IHost> method)
        {
            if (!host.CanElseExecute)
            {
                return(host.Unwrap());
            }

            return(method(host));
        }