示例#1
0
 /// <summary>
 /// Createt a new <paramref name="Microsoft.Samples.NLayerApp.Infrastructure.Crosscutting.Logging.ILog"/>
 /// </summary>
 /// <returns>Created ILog</returns>
 public static IEntityValidator CreateValidator()
 {
     if (_factory == null)
     {
         EntityValidatorFactory.SetCurrent(new DataAnnotationsEntityValidatorFactory());
     }
     return((_factory != null) ? _factory.Create() : null);
 }
示例#2
0
        public static IEntityValidator Create()
        {
            if (currentEntityValidatorFactory == null)
            {
                throw new NullReferenceException("Uma instância de IEntityValidatorFactory deve ser fornecida através do método SetCurrent(IEntityValidatorFactory entityValidatorFactory).");
            }

            return(currentEntityValidatorFactory.Create());
        }
示例#3
0
        public static void ValidateEntity <TEntity>(this IEntityValidatorFactory entityValidatorFactory, TEntity entity)
            where TEntity : class
        {
            var entityValidator = entityValidatorFactory.Create();
            var isValid         = entityValidator.IsValid(entity);

            if (!isValid)
            {
                var errors = entityValidator.GetInvalidMessages(entity).ToList();

                throw new ValidationErrorsException(errors);
            }
        }
 /// <summary>
 /// Createt a new 
 /// </summary>
 /// <returns>Created ILog</returns>
 public static IEntityValidator CreateValidator()
 {
     return (_factory != null) ? _factory.Create() : null;
 }
示例#5
0
 /// <summary>
 /// 创建当前实体验证器实例
 /// </summary>
 /// <returns>IEntityValidator</returns>
 public static IEntityValidator CreateValidator()
 {
     return(_factory?.Create());
 }