public static PersistenceSpecification <T> CheckProperty <T>(this PersistenceSpecification <T> spec,
                                                                     Expression <Func <T, object> > expression, object propertyValue,
                                                                     IEqualityComparer propertyComparer)
        {
            Accessor property = ReflectionHelper.GetAccessor(expression);

            return(spec.RegisterCheckedProperty(new Property <T, object>(property, propertyValue), propertyComparer));
        }
        public static PersistenceSpecification <T> CheckProperty <T, TListElement>(this PersistenceSpecification <T> spec,
                                                                                   Expression <Func <T, Array> > 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> CheckProperty <T, TProperty>(this PersistenceSpecification <T> spec,
                                                                                Expression <Func <T, TProperty> > expression,
                                                                                TProperty propertyValue,
                                                                                IEqualityComparer propertyComparer,
                                                                                Action <T, TProperty> propertySetter)
        {
            Accessor propertyInfoFromExpression = ReflectionHelper.GetAccessor(expression);

            var property = new Property <T, TProperty>(propertyInfoFromExpression, propertyValue);

            property.ValueSetter = (target, propertyInfo, value) => propertySetter(target, value);

            return(spec.RegisterCheckedProperty(property, propertyComparer));
        }
        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> CheckBag <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 ReferenceBag <T, TListElement>(property, propertyValue);

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

            return(spec.RegisterCheckedProperty(list, elementComparer));
        }