protected ValidatableViewModel(IErrorsContainer <ValidationError> errorsContainer, ArrayFormat errorFormat = ArrayFormat.First) { ErrorsContainer = errorsContainer; ErrorsContainer.ErrorsChanged += OnErrorsChanged; dataErrorInfoProvider = new DataErrorInfoProvider(ErrorsContainer, errorFormat, ObjectErrorPropertyName); }
public DataErrorInfoProvider(IErrorsContainer <TError> errorsContainer, Func <IEnumerable <TError>, string> errorsFormatter, string objectPropertyName = "") { Contract.Requires <ArgumentNullException>(errorsContainer != null, "errorsContainer"); Contract.Requires <ArgumentNullException>(objectPropertyName != null, "objectPropertyName"); Contract.Requires <ArgumentNullException>(errorsFormatter != null, "errorsFormatter"); ObjectPropertyName = objectPropertyName; ErrorsContainer = errorsContainer; ErrorsFormatter = errorsFormatter; }
public static void ClearErrors <TError, TProperty>(this IErrorsContainer <TError> errorsContainer, Expression <Func <TProperty> > propertySelector) where TError : ValidationError { Ensure.NotNull(errorsContainer); Ensure.NotNull(propertySelector); string propertyName = ExpressionUtils.GetPropertyName(propertySelector); errorsContainer.ClearErrors(propertyName); }
public static IEnumerable <TError> GetErrors <TError, TProperty>(this IErrorsContainer <TError> errorsContainer, Expression <Func <TProperty> > propertySelector) where TError : ValidationError { Ensure.NotNull(errorsContainer); Ensure.NotNull(propertySelector); string propertyName = ExpressionUtils.GetPropertyName(propertySelector); return(errorsContainer.GetErrors(propertyName)); }
public static void ClearAndSetErrors <TError>(this IErrorsContainer <TError> errorsContainer, IEnumerable <TError> errors) where TError : ValidationError { Ensure.NotNull(errorsContainer); errorsContainer.ClearAllErrors();; if (!errors.IsNullOrEmpty()) { errorsContainer.SetErrors(errors); } ; }
public static void ClearErrors <TError, TEntity, TProperty>( this IErrorsContainer <TError> errorContainer, Expression <Func <TEntity, TProperty> > propertyExpression) where TError : ValidationError { if (propertyExpression == null) { throw new ArgumentNullException("propertyExpression"); } string propertyName = ExpressionUtils.GetPropertyName(propertyExpression); errorContainer.ClearErrors(propertyName); }
public DataErrorInfoProvider(IErrorsContainer <TError> errorsContainer, ArrayFormat arrayFormat = ArrayFormat.First, string objectPropertyName = "") : this(errorsContainer, ArrayFormatter.GetErrorFormatter(arrayFormat) as Func <IEnumerable <TError>, string>, objectPropertyName) { }