public UsingEnvironmentName() { // Idiomatic Jasper way Settings.Configure(context => { if (context.HostingEnvironment.IsDevelopment()) { // If in development, I want to replace some kind // of problematic 3rd party service wrapper with // a nicely behaved stub Services.AddSingleton <IThirdPartyService, StubThirdPartyService>(); } }); // ASP.Net Core idiomatic way Hosting.ConfigureServices((context, services) => { if (context.HostingEnvironment.IsDevelopment()) { // If in development, I want to replace some kind // of problematic 3rd party service wrapper with // a nicely behaved stub services.AddSingleton <IThirdPartyService, StubThirdPartyService>(); } }); }
public BootstrappingApp() { Services.For <BootstrappingToken>().Use(new BootstrappingToken(Id)); Hosting.ConfigureAppConfiguration(c => { c.AddInMemoryCollection(new Dictionary <string, string> { { "foo", "bar" } }); c.AddInMemoryCollection(new Dictionary <string, string> { { "team", "chiefs" } }); }); Hosting.ConfigureServices(s => s.AddTransient <IService, ServiceFromJasperRegistryConfigure>()); Hosting.ConfigureServices((c, services) => { if (c.HostingEnvironment.EnvironmentName == "Green") { services.AddTransient <IService, GreenService>(); } }); Settings.Alter <BootstrappingSetting>((context, settings) => { settings.Environment = context.HostingEnvironment.EnvironmentName; settings.Team = context.Configuration["team"]; settings.City = context.Configuration["city"]; }); }
public UsingEnvironmentName() { // Idiomatic Jasper way Settings.Configure(context => { if (context.HostingEnvironment.IsDevelopment()) { Services.AddSingleton <IThirdPartyService, StubThirdPartyService>(); } }); // ASP.Net Core idiomatic way Hosting.ConfigureServices((context, services) => { if (context.HostingEnvironment.IsDevelopment()) { services.AddSingleton <IThirdPartyService, StubThirdPartyService>(); } }); }
public BootstrappingApp() { Services.For <BootstrappingToken>().Use(new BootstrappingToken(Id)); Configuration.AddInMemoryCollection(new Dictionary <string, string> { { "foo", "bar" } }); Hosting.ConfigureAppConfiguration(c => c.AddInMemoryCollection(new Dictionary <string, string> { { "team", "chiefs" } })); Hosting.ConfigureServices(s => s.AddTransient <IService, ServiceFromJasperRegistryConfigure>()); Hosting.ConfigureServices((c, services) => { if (c.HostingEnvironment.EnvironmentName == "Green") { services.AddTransient <IService, GreenService>(); } }); Hosting.Configure(app => { app.MapWhen( c => c.Request.Path.Value.Contains("host"), b => b.Run(c => c.Response.WriteAsync("from jasperregistry host"))); }); Settings.Alter <BootstrappingSetting>((context, settings) => { settings.Environment = context.HostingEnvironment.EnvironmentName; settings.Team = context.Configuration["team"]; settings.City = context.Configuration["city"]; }); }