public static PersistenceSpecification <T> CheckComponentList <T, TListElement>(this PersistenceSpecification <T> spec,
                                                                                        Expression <Func <T, IEnumerable <TListElement> > > expression,
                                                                                        IEnumerable <TListElement> propertyValue,
                                                                                        IEqualityComparer elementComparer,
                                                                                        Action <T, IEnumerable <TListElement> > listSetter)
        {
            Accessor property = ReflectionHelper.GetAccessor(expression);

            var list = new List <T, TListElement>(property, propertyValue);

            list.ValueSetter = (target, propertyInfo, value) => listSetter(target, value);

            return(spec.RegisterCheckedProperty(list, elementComparer));
        }
 public static PersistenceSpecification <T> CheckReference <T, TReference>(this PersistenceSpecification <T> spec,
                                                                           Expression <Func <TReference> > expression)
 {
     return(spec.CheckReference(expression, (IEqualityComparer)null));
 }
        /// <summary>
        /// Checks a list of components for validity.
        /// </summary>
        /// <typeparam name="T">Entity type</typeparam>
        /// <typeparam name="TListElement">Type of list element</typeparam>
        /// <param name="spec">Persistence specification</param>
        /// <param name="expression">Property</param>
        /// <param name="propertyValue">Value to save</param>
        /// <param name="elementComparer">Equality comparer</param>
        public static PersistenceSpecification <T> CheckComponentList <T, TListElement>(this PersistenceSpecification <T> spec,
                                                                                        Expression <Func <T, object> > expression,
                                                                                        IEnumerable <TListElement> propertyValue,
                                                                                        IEqualityComparer elementComparer)
        {
            Accessor property = ReflectionHelper.GetAccessor(expression);

            return(spec.RegisterCheckedProperty(new List <T, TListElement>(property, propertyValue), elementComparer));
        }
 public static PersistenceSpecification <T> CheckComponentList <T, TListElement>(this PersistenceSpecification <T> spec,
                                                                                 Expression <Func <T, IEnumerable <TListElement> > > expression,
                                                                                 IEnumerable <TListElement> propertyValue,
                                                                                 Action <T, IEnumerable <TListElement> > listSetter)
 {
     return(spec.CheckComponentList(expression, propertyValue, null, listSetter));
 }
 public static PersistenceSpecification <T> CheckProperty <T, TProperty>(this PersistenceSpecification <T> spec,
                                                                         Expression <Func <TProperty> > expression)
 {
     return(spec.CheckProperty(expression, (IEqualityComparer)null));
 }
 public static PersistenceSpecification <T> CheckBag <T, TListElement>(this PersistenceSpecification <T> spec,
                                                                       Expression <Func <T, IEnumerable <TListElement> > > expression,
                                                                       IEnumerable <TListElement> propertyValue)
 {
     return(spec.CheckBag(expression, propertyValue, (IEqualityComparer)null));
 }
        public static PersistenceSpecification <T> CheckInverseList <T, TListElement>(this PersistenceSpecification <T> spec,
                                                                                      Expression <Func <T, IEnumerable <TListElement> > > expression,
                                                                                      IEnumerable <TListElement> propertyValue,
                                                                                      IEqualityComparer elementComparer,
                                                                                      Action <T, TListElement> listItemSetter)
        {
            Accessor property = ReflectionHelper.GetAccessor(expression);

            var list = new ReferenceList <T, TListElement>(property, propertyValue);

            list.ValueSetter = (target, propertyInfo, value) =>
            {
                foreach (var item in value)
                {
                    listItemSetter(target, item);
                }
            };

            return(spec.RegisterCheckedPropertyWithoutTransactionalSave(list, elementComparer));
        }
        public static PersistenceSpecification <T> CheckInverseList <T, TListElement>(this PersistenceSpecification <T> spec,
                                                                                      Expression <Func <T, IEnumerable <TListElement> > > expression,
                                                                                      IEnumerable <TListElement> propertyValue,
                                                                                      params Func <TListElement, object>[] propertiesToCompare)
        {
            // Because of the params keyword, the compiler can select this overload
            // instead of the one above, even when no funcs are supplied in the method call.
            if (propertiesToCompare == null || propertiesToCompare.Length == 0)
            {
                return(spec.CheckList(expression, propertyValue, (IEqualityComparer)null));
            }

            return(spec.CheckInverseList(expression, propertyValue, new FuncEqualityComparer <TListElement>(propertiesToCompare)));
        }
        public static PersistenceSpecification <T> CheckInverseList <T, TListElement>(this PersistenceSpecification <T> spec,
                                                                                      Expression <Func <T, IEnumerable <TListElement> > > expression,
                                                                                      IEnumerable <TListElement> propertyValue,
                                                                                      IEqualityComparer elementComparer)
        {
            Accessor property = ReflectionHelper.GetAccessor(expression);

            return(spec.RegisterCheckedPropertyWithoutTransactionalSave(new ReferenceList <T, TListElement>(property, propertyValue), elementComparer));
        }