Skip to content

Instantly share code, notes, and snippets.

@StacyGay
Created April 11, 2021 20:30
Show Gist options
  • Save StacyGay/7bc52b7a8b5e47b31ed620292af751ed to your computer and use it in GitHub Desktop.
Save StacyGay/7bc52b7a8b5e47b31ed620292af751ed to your computer and use it in GitHub Desktop.
Unity DI VNext Startup
public class Startup
{
// This method gets called by a runtime. Use this method to add services to the container
public IServiceProvider ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddTransient<ITransientService, TransientService>();
services.AddScoped<IScopedService, ScopedService>();
services.AddSingleton<ISingletonService, SingletonService>();
}
// Configure is called after ConfigureServices is called.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
// Configure the HTTP request pipeline.
app.UseStaticFiles();
// Add MVC to the request pipeline.
app.UseMvc();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment