private static void SetupPatterns(Revenj.Extensibility.Autofac.ContainerBuilder builder) { var serverModels = (from asm in Revenj.Utility.AssemblyScanner.GetAssemblies() let type = asm.GetType("SystemBoot.Configuration") where type != null && type.GetMethod("Initialize") != null select asm) .ToList(); builder.RegisterGeneratedFactory<Revenj.DomainPatterns.DomainModel.Factory>(); builder.RegisterType<Revenj.DomainPatterns.DomainModel>(); builder.Register(c => c.Resolve<Revenj.DomainPatterns.DomainModel.Factory>()(serverModels)).As<IDomainModel>().SingleInstance(); builder.RegisterType<DomainTypeResolver>().As<ITypeResolver>().SingleInstance(); builder.RegisterType<ServiceLocator>().As<IServiceLocator, IServiceProvider>().InstancePerLifetimeScope(); builder.RegisterGeneric(typeof(WeakCache<>)).As(typeof(WeakCache<>), typeof(IDataCache<>)).InstancePerLifetimeScope(); builder.RegisterType<DomainEventSource>().As<IDomainEventSource>().InstancePerLifetimeScope(); builder.RegisterType<DomainEventStore>().As<IDomainEventStore>().InstancePerLifetimeScope(); builder.RegisterType<GlobalEventStore>().SingleInstance(); builder.RegisterGeneric(typeof(SingleDomainEventSource<>)).As(typeof(IDomainEventSource<>)).InstancePerLifetimeScope(); builder.RegisterGeneric(typeof(RegisterChangeNotifications<>)).As(typeof(IObservable<>)).SingleInstance(); builder.RegisterType<DataContext>().As<IDataContext>().InstancePerLifetimeScope(); }
private static void SetupPostgres(Revenj.Extensibility.Autofac.ContainerBuilder builder) { var cs = ConfigurationManager.AppSettings["Revenj.ConnectionString"] ?? ConfigurationManager.AppSettings["ConnectionString"]; if (string.IsNullOrEmpty(cs)) throw new ConfigurationErrorsException(@"ConnectionString is missing from configuration. Add ConnectionString to <appSettings> Example: <add key=""ConnectionString"" value=""server=postgres.localhost;port=5432;database=MyDatabase;user=postgres;password=123456;encoding=unicode"" />"); builder.RegisterInstance(new Revenj.DatabasePersistence.Postgres.ConnectionInfo(cs)); builder.RegisterType<PostgresConnectionPool>().As<IConnectionPool>().SingleInstance(); builder.RegisterType<PostgresQueryManager>().As<IDatabaseQueryManager>().InstancePerLifetimeScope(); builder.RegisterType<PostgresDatabaseQuery>().As<IPostgresDatabaseQuery>(); builder.Register(c => c.Resolve<IDatabaseQueryManager>().CreateQuery()).As<IDatabaseQuery>().InstancePerLifetimeScope(); builder.RegisterType<PostgresDatabaseNotification>().As<IDataChangeNotification, IEagerNotification>().SingleInstance(); builder.RegisterType<PostgresObjectFactory>().As<IPostgresConverterRepository, IPostgresConverterFactory>().SingleInstance(); builder.RegisterType<Revenj.DatabasePersistence.Postgres.QueryGeneration.QueryExecutor>(); }
private static void SetupPostgres(Revenj.Extensibility.Autofac.ContainerBuilder builder, string cs) { builder.RegisterInstance(new Revenj.DatabasePersistence.Postgres.ConnectionInfo(cs)); builder.RegisterType<PostgresConnectionPool>().As<IConnectionPool>().SingleInstance(); builder.RegisterType<PostgresQueryManager>().As<IDatabaseQueryManager>().InstancePerLifetimeScope(); builder.RegisterType<PostgresDatabaseQuery>().As<IPostgresDatabaseQuery>(); builder.Register(c => c.Resolve<IDatabaseQueryManager>().CreateQuery()).As<IDatabaseQuery>().InstancePerLifetimeScope(); builder.RegisterType<PostgresDatabaseNotification>().As<IDataChangeNotification, IEagerNotification>().SingleInstance(); builder.RegisterType<PostgresObjectFactory>().As<IPostgresConverterRepository, IPostgresConverterFactory>().SingleInstance(); builder.RegisterType<Revenj.DatabasePersistence.Postgres.QueryGeneration.QueryExecutor>(); }
private static void SetupPatterns(Revenj.Extensibility.Autofac.ContainerBuilder builder) { var serverModels = (from key in ConfigurationManager.AppSettings.AllKeys where key.StartsWith("ServerAssembly", StringComparison.OrdinalIgnoreCase) select LoadAssembly(ConfigurationManager.AppSettings[key])) .ToList(); if (serverModels.Count == 0) { serverModels = (from asm in Revenj.Utility.AssemblyScanner.GetAssemblies() let type = asm.GetType("SystemBoot.Configuration") where type != null && type.GetMethod("Initialize") != null select asm) .ToList(); if (serverModels.Count == 0) throw new ConfigurationErrorsException(@"Server assemblies not found. When running in compiled mode, server assemblies must be deployed with other assemblies. Alternatively, explicitly specify sever assembly in the config file. Example: <add key=""ServerAssembly_Domain"" value=""AppDomainModel.dll"" />"); } builder.RegisterGeneratedFactory<Revenj.DomainPatterns.DomainModel.Factory>(); builder.RegisterType<Revenj.DomainPatterns.DomainModel>(); builder.Register(c => c.Resolve<Revenj.DomainPatterns.DomainModel.Factory>()(serverModels)).As<IDomainModel>().SingleInstance(); builder.RegisterType<DomainTypeResolver>().As<ITypeResolver>().SingleInstance(); builder.RegisterType<ServiceLocator>().As<IServiceLocator, IServiceProvider>().InstancePerLifetimeScope(); builder.RegisterGeneric(typeof(WeakCache<>)).As(typeof(WeakCache<>), typeof(IDataCache<>)).InstancePerLifetimeScope(); builder.RegisterType<DomainEventSource>().As<IDomainEventSource>().InstancePerLifetimeScope(); builder.RegisterType<DomainEventStore>().As<IDomainEventStore>().InstancePerLifetimeScope(); builder.RegisterType<GlobalEventStore>().SingleInstance(); builder.RegisterGeneric(typeof(SingleDomainEventSource<>)).As(typeof(IDomainEventSource<>)).InstancePerLifetimeScope(); builder.RegisterGeneric(typeof(RegisterChangeNotifications<>)).As(typeof(IObservable<>)).SingleInstance(); builder.RegisterType<DataContext>().As<IDataContext>().InstancePerLifetimeScope(); }