protected virtual async Task ValidateAsync(T command)
        {
            IValidationResult result = null;

            if (validationHandler != null)
            {
                result = await validationHandler.HandleAsync(command);
            }
            else if (validationDispatcher != null)
            {
                result = await validationDispatcher.ValidateAsync(command);
            }

            if (result != null)
            {
                result.ThrowIfNotValid();
            }
        }
Example #2
0
        /// <summary>
        /// A method responsible for validating commands.
        /// </summary>
        /// <typeparam name="TCommand">A type of the command.</typeparam>
        /// <param name="command">An instance of command to validate.</param>
        /// <returns>A continuation task.</returns>
        protected virtual async Task ValidateAsync <TCommand>(TCommand command)
        {
            IValidationResult result = await validationDispatcher.ValidateAsync(command);

            result.ThrowIfNotValid();
        }