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(); }
public void OnInvoke() { var coreBuilder = new CoreBuilder(); coreBuilder.OnStarting(builder => { builder.RegisterModule <GrpcModule>(); }); coreBuilder.Build(); }
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(); }
static void Main() { var coreBuilder = new CoreBuilder(); coreBuilder.OnStarting(builder => { builder.RegisterModule <GrpcModule>(); builder.RegisterModule <AutofacModule>(); }); coreBuilder.Build(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); }
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(); }