public override void establish_context()
            {
                property = ReflectionHelper.GetAccessor((Expression <Func <ListEntity, IEnumerable <string> > >)(x => x.GetterAndSetter));
                target   = new ListEntity();

                sut = new ReferenceBag <ListEntity, string>(property, new[] { "foo", "bar", "baz" });
            }
예제 #2
0
            public override void establish_context()
            {
                property = ReflectionHelper.GetAccessor((Expression<Func<ListEntity, IEnumerable<string>>>)(x => x.GetterAndSetter));
                target = new ListEntity();

                sut = new ReferenceBag<ListEntity, string>(property, new[] { "foo", "bar", "baz" });
            }
        public static PersistenceSpecification <T> CheckBag <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 ReferenceBag <T, TListElement>(property, propertyValue);

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

            return(spec.RegisterCheckedProperty(list, elementComparer));
        }
        public static PersistenceSpecification <T> CheckInverseBag <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.RegisterCheckedPropertyWithoutTransactionalSave(list, elementComparer));
        }