protected virtual void PerformCollectionValidation <TItemVM>( Action <TItemVM, string, object> addValidationErrorAction, ValidatorType type, IViewModel owner, IVMCollectionBase <TItemVM> targetCollection, object validatorKey, IVMPropertyDescriptor targetProperty = null ) where TItemVM : IViewModel { foreach (TItemVM item in targetCollection) { var invocation = new ValidatorInvocation(type, owner, item, null, targetProperty, validatorKey); var errors = ValidatorSetups .Where(x => x.Invocation.Equals(invocation)) .SelectMany(x => x.Result.Errors); errors.ForEach(x => addValidationErrorAction(item, x.Message, x.Details)); } ActualInvocations.Add( new ValidatorInvocation(type, owner, null, targetCollection, targetProperty, validatorKey) ); }
protected override void PerformCollectionValidation <TItemVM>(Action <TItemVM, string, object> addValidationErrorAction, ValidatorType type, IViewModel owner, IVMCollectionBase <TItemVM> targetCollection, object validatorKey, IVMPropertyDescriptor targetProperty = null) { bool validate = false; switch (type) { case ValidatorType.CollectionProperty: if ((EnabledValidators & ValidatorTypes.Property) == ValidatorTypes.Property) { validate = true; } break; case ValidatorType.CollectionViewModel: if ((EnabledValidators & ValidatorTypes.ViewModel) == ValidatorTypes.ViewModel) { validate = true; } break; } if (validate) { base.PerformCollectionValidation <TItemVM>(addValidationErrorAction, type, owner, targetCollection, validatorKey, targetProperty); } }