/// <summary>
        /// Given a validation rule and a collection of tuples of parameter to object bindings (represented as list),
        /// create corresponding RuleBindings.
        /// We create a separate rule binding for each parameter to object binding tuple.
        /// </summary>
        /// <param name="rule"></param>
        /// <param name="objectBindings"></param>
        /// <returns></returns>
        private static IEnumerable <RuleBinding <TResult> > GetRuleBindings(ValidationRule <TResult> rule, IEnumerable <IEnumerable <ParameterObjectBinding> > objectBindings)
        {
            var result = new List <RuleBinding <TResult> >();

            foreach (var objectBinding in objectBindings)
            {
                var bindings = (from dependency in rule.Signature
                                select new ValidationRuleDependencyBinding
                {
                    ValidationRuleDependency = dependency,
                    ParameterObjectBinding = objectBinding.Single(b => b.ParameterName == dependency.ParameterExpression.Name)
                }).Distinct(new ValidationRuleDependencyBindingComparer());
                if (bindings.Count() != rule.Signature.Count())
                {
                    continue;
                }
                result.Add(new RuleBinding <TResult>
                {
                    DependencyBindings = bindings.ToArray(),
                    ValidationRule     = rule
                });
            }
            return(result);
        }
        /// <summary>
        /// Given a validation rule with dependency expressions and a collection of objects
        /// return a list of tuples (represented as lists) with all permutations of matching objects.
        /// </summary>
        /// <param name="rule"></param>
        /// <param name="objects"></param>
        /// <returns></returns>
        private static IEnumerable <IEnumerable <ParameterObjectBinding> > GetRuleArgumentObjectBindings(ValidationRule <TResult> rule, IEnumerable <TEntity> objects)
        {
            List <IEnumerable <ParameterObjectBinding> > bindings = new List <IEnumerable <ParameterObjectBinding> >();

            var dependencyParameters = rule.GetValidationRuleDependencyParameters();

            var parameterObjectBindings =
                (from obj in objects
                 from parameter in dependencyParameters
                 where parameter.ParameterObjectType.IsAssignableFrom(obj.GetType())
                 select new ParameterObjectBinding {
                ParameterName = parameter.ParameterName, ParameterObjectType = parameter.ParameterObjectType, ParameterObject = obj
            })
                .GroupBy(x => x.ParameterName);

            foreach (var group in parameterObjectBindings.ToList())
            {
                bindings.Add(group.ToList());
            }

            return(GetPermutations(bindings));
        }