コード例 #1
0
        public static void ConfigureRepositories(this IAppHost appHost,
                                                 Assembly[] assembliesContainingDomainTypes)
        {
            var container = appHost.GetContainer();

            if (!container.Exists <IDependencyContainer>())
            {
                container.AddSingleton <IDependencyContainer>(new FunqDependencyContainer(container));
            }
            if (!container.Exists <IDomainFactory>())
            {
                container.AddSingleton <IDomainFactory>(c => DomainFactory.CreateRegistered(
                                                            c.Resolve <IDependencyContainer>(), assembliesContainingDomainTypes));
            }
            else
            {
                container.Resolve <IDomainFactory>()
                .RegisterDomainTypesFromAssemblies(assembliesContainingDomainTypes);
            }
            container.AddSingleton <IChangeEventMigrator>(c => new ChangeEventTypeMigrator());

            if (!container.Exists <IRepository>())
            {
                container.AddSingleton(GetRepository(appHost));
            }

            if (!container.Exists <IBlobository>())
            {
                container.AddSingleton(GetBlobository(appHost));
            }
        }
コード例 #2
0
        public static DomainFactory CreateRegistered(IDependencyContainer container,
                                                     params Assembly[] assembliesContainingFactories)
        {
            var domainFactory = new DomainFactory(container);

            domainFactory.RegisterDomainTypesFromAssemblies(assembliesContainingFactories);
            return(domainFactory);
        }