/// <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); }
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()); }
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; }
/// <summary> /// 创建当前实体验证器实例 /// </summary> /// <returns>IEntityValidator</returns> public static IEntityValidator CreateValidator() { return(_factory?.Create()); }