/// <summary>
        /// Callback method that is called when the result of a validation rule has changed.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ProcessValidationResult(RuleBinding <TResult> ruleBinding, TResult validationResult)
        {
            var rule = ruleBinding.ValidationRule;

            var bindingGroups = from depBinding in ruleBinding.DependencyBindings
                                where
                                depBinding.ValidationRuleDependency.InputOnly == false &&
                                depBinding.TargetOwnerObject is TEntity
                                group depBinding by depBinding.TargetOwnerObject as TEntity;

            TResult oldValidationResult = null;

            if (ValidationResults.ContainsKey(ruleBinding))
            {
                oldValidationResult = ValidationResults[ruleBinding];
            }
            foreach (var bindingGroup in bindingGroups)
            {
                var entity         = bindingGroup.Key;
                var membersInError = bindingGroup.Select(binding => binding.ValidationRuleDependency.TargetProperty.Name).Distinct().ToArray();
                if (HasValidationResult(entity, membersInError, oldValidationResult))
                {
                    ClearValidationResult(entity, membersInError, oldValidationResult);
                }
                if (HasValidationResult(entity, membersInError, validationResult) == false)
                {
                    SetValidationResult(entity, membersInError, validationResult);
                }
            }
            if (IsValidationSuccess(validationResult) && oldValidationResult != null)
            {
                ValidationResults.Remove(ruleBinding);
                if (EntitiesInErrorChanged != null)
                {
                    EntitiesInErrorChanged(EntitiesInError, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
                }
            }
            else
            {
                ValidationResults[ruleBinding] = validationResult;
                if (EntitiesInErrorChanged != null)
                {
                    EntitiesInErrorChanged(EntitiesInError, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
                }
            }
            if (ValidationResultChanged != null)
            {
                ValidationResultChanged(this, new ValidationResultChangedEventArgs <TEntity, TResult>(validationResult, bindingGroups.Select(g => g.Key)));
            }
        }