コード例 #1
0
        public void ShouldCreateChildRepositoryFactory()
        {
            var factory = ReflectionExtensions.BuildParentRepositoryFunc <FakeChildEntity, FakeEntity>();

            factory.Should().NotBeNull();
            factory(Fake <FakeEntity>(), Fake <IStoreEntities>()).Should().BeAssignableTo <IRepository <FakeChildEntity, FakeEntity> >();
        }
コード例 #2
0
        public IRepository <TEntity, TParent> ForEntity <TEntity, TParent>(TParent parent, IDomainUnitOfWork uow) where TEntity : IChildEntity <TParent> where TParent : IEntity
        {
            var factory = Factories.GetOrAdd(typeof(TEntity), t => ReflectionExtensions.BuildParentRepositoryFunc <TEntity, TParent>()) as Func <TParent, IMetrics, IStoreEvents, IStoreSnapshots, IOobWriter, IEventFactory, IDomainUnitOfWork, IRepository <TEntity, TParent> >;

            if (factory == null)
            {
                throw new InvalidOperationException("unknown entity repository");
            }

            return(factory(parent, _metrics, _eventstore, _snapstore, _oobStore, _factory, uow));
        }
コード例 #3
0
        public IRepository <TEntity, TParent> ForEntity <TEntity, TParent>(TParent parent) where TEntity : IChildEntity <TParent> where TParent : IEntity
        {
            var factory = Factories.GetOrAdd(typeof(TEntity), t => ReflectionExtensions.BuildParentRepositoryFunc <TEntity, TParent>()) as Func <TParent, IStoreEntities, IRepository <TEntity, TParent> >;

            if (factory == null)
            {
                throw new InvalidOperationException("unknown entity repository");
            }

            return(factory(parent, _store));
        }