Last active
April 30, 2021 11:07
-
-
Save manoj-choudhari-git/449ea9998569d3e1a60d5a0657ee6dd4 to your computer and use it in GitHub Desktop.
C# Console application starting the host for dependency injection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
CreateHostBuilder(args).Build().Run(); | |
} | |
static IHostBuilder CreateHostBuilder(string[] args) => | |
Host.CreateDefaultBuilder(args) | |
.ConfigureServices((_, services) => | |
services.AddTransient<ITransientGetCreatedTime, GetCreatedTimeImplementation>() | |
.AddScoped<IScopedGetCreatedTime, GetCreatedTimeImplementation>() | |
.AddSingleton<ISingletonGetCreatedTime, GetCreatedTimeImplementation>() | |
.AddTransient<GetCreatedTimeInvoker>()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment