protected override void RegisterBuilder(ContainerBuilderWrapper builder) { var configAssembliesStr = CPlatformAppConfig.GetSection("Automapper:Assemblies").Get <string>(); if (!string.IsNullOrEmpty(configAssembliesStr)) { AppConfig.AssembliesStrings = configAssembliesStr.Split(";"); } builder.RegisterType <AutoMapperBootstrap>().As <IAutoMapperBootstrap>(); }
static void Main(string[] args) { // Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); var host = new ServiceHostBuilder() .RegisterServices(builder => { builder.AddMicroService(option => { option.AddServiceRuntime() .AddRelateService() .AddConfigurationWatch() //option.UseZooKeeperManager(new ConfigInfo("127.0.0.1:2181")); .AddServiceEngine(typeof(SurgingServiceEngine)) .AddClientIntercepted(typeof(CacheProviderInterceptor)); builder.Register(p => new CPlatformContainer(ServiceLocator.Current)); }); }) .ConfigureLogging(logger => { logger.AddConfiguration( AppConfig.GetSection("Logging")); }) .UseServer(options => { }) .UseConsoleLifetime() .Configure(build => { #if DEBUG build.AddCacheFile("${cachePath}|/app/configs/cacheSettings.json", optional: false, reloadOnChange: true); build.AddCPlatformFile("${surgingPath}|/app/configs/surgingSettings.json", optional: false, reloadOnChange: true); build.AddEventBusFile("${eventBusPath}|/app/configs/eventBusSettings.json", optional: false, reloadOnChange: true); build.AddConsulFile("${consulPath}|/app/configs/consul.json", optional: false, reloadOnChange: true); build.AddZookeeperFile("${zookeeperPath}|/app/configs/zookeeper.json", optional: false, reloadOnChange: true); #else build.AddCacheFile("${cachePath}|configs/cacheSettings.json", optional: false, reloadOnChange: true); build.AddCPlatformFile("${surgingPath}|configs/surgingSettings.json", optional: false, reloadOnChange: true); build.AddEventBusFile("${eventBusPath}|configs/eventBusSettings.json", optional: false); build.AddConsulFile("${consulPath}|configs/consul.json", optional: false, reloadOnChange: true); build.AddZookeeperFile("${zookeeperPath}|configs/zookeeper.json", optional: false, reloadOnChange: true); #endif }) .UseStartup <Startup>() .Build(); using (host.Run()) { Console.WriteLine($"服务端启动成功,{DateTime.Now}。"); } }