コード例 #1
0
        public ValidationResult Validate(ICommandWithValidation model)
        {
            var type             = model.GetType();
            var genericClass     = typeof(CommandValidator <>);
            var constructedClass = genericClass.MakeGenericType(type);
            var validator        = _serviceProvider.GetService(constructedClass);

            if (validator == null)
            {
                return(new ValidationResult());
            }

            var x = ((IValidator)validator).Validate(model);

            return(x);
        }
コード例 #2
0
 public CommandValidationException(ICommandWithValidation command, IEnumerable <ValidationFailure> messages)
 {
     _erros   = messages.Select(r => r.ErrorMessage).ToList();
     _command = command;
 }