Did you know that you can inject any object in the Configure
method of your startup class? For example if you want to inject ICustomer
.
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
public void ConfigureServices(IServiceCollection services)
{
services.AddScoped<ICustomer,Customer>();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ICustomer customer)
{
// use customer here
}
}