public ConsumerService() { try { var coreBuilder = new CoreBuilder(); coreBuilder.builder.RegisterModule <AutofacModules>(); coreBuilder.UserRedis(ConfigurationManager.ConnectionStrings["RedisConnectionString"].ConnectionString); coreBuilder.OnStarting(builder => { builder.RegisterType <MemoryEventBusService>().As <IMemoryEventBusService>().InstancePerMatchingLifetimeScope(); builder.RegisterType <DistributedEventBusService>().As <IDistributedEventBusService>().InstancePerMatchingLifetimeScope(); }); //拆分DLL后需要注册,需要注入的DLL Assembly[] asm = Utils.GetAllAssembly("MutualClass.*.dll").ToArray(); coreBuilder.Build(asm); CoreBuilderWork.LifetimeScope.Resolve <IDistributedEventBusService>(); //var _MutualClassRewardQueueService = CoreBuilderWork.LifetimeScope.Resolve<MutualClassRewardQueueService>(); //_MutualClassRewardQueueService.imq_onReceive_test(); } catch (Exception ex) { _Logger.Error("Autofac注册异常", ex); } InitializeComponent(); }
void Application_Start(object sender, EventArgs e) { log4net.Config.XmlConfigurator.ConfigureAndWatch(new System.IO.FileInfo(AppDomain.CurrentDomain.BaseDirectory + "log4net.config")); // 在应用程序启动时运行的代码 AreaRegistration.RegisterAllAreas(); GlobalConfiguration.Configure(WebApiConfig.Register); RouteConfig.RegisterRoutes(RouteTable.Routes); var coreBuilder = new CoreBuilder(); coreBuilder.UserRedis(ConfigurationManager.ConnectionStrings["RedisConnectionString"].ConnectionString); coreBuilder.Build(); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RouteConfig.RegisterRoutes(RouteTable.Routes); log4net.Config.XmlConfigurator.ConfigureAndWatch(new System.IO.FileInfo(AppDomain.CurrentDomain.BaseDirectory + "log4net.config")); var coreBuilder = new CoreBuilder(); coreBuilder.builder.RegisterModule <FileSystemModule>(); coreBuilder.builder.RegisterModule <AutofacModules>(); coreBuilder.UserRedis(ConfigurationManager.ConnectionStrings["RedisConnectionString"].ConnectionString); coreBuilder.Build(); }