Skip to content

Instantly share code, notes, and snippets.

@NikitaChizhov
Created February 11, 2020 20:04
Show Gist options
  • Save NikitaChizhov/073eec647a8782e206e5939f813635c0 to your computer and use it in GitHub Desktop.
Save NikitaChizhov/073eec647a8782e206e5939f813635c0 to your computer and use it in GitHub Desktop.
void ConfigureServices(IServiceCollection services)
{
services
.AddLogging(configure =>
{
configure.AddConsole();
configure.SetMinimumLevel(LogLevel.Information);
})
.AddSingleton<IImportantDataProvider, ImportantDataProvider>()
.AddSingleton<IExampleService>(sp =>
{
var service = new ExampleService(sp.GetRequiredService<IImportantDataProvider>());
var decorated = new ExampleServiceClassicDecorator(service,
sp.GetRequiredService<ILogger<ExampleServiceClassicDecorator>>());
return decorated;
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment