Skip to content

Instantly share code, notes, and snippets.

@manoj-choudhari-git
Last active April 30, 2021 11:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save manoj-choudhari-git/449ea9998569d3e1a60d5a0657ee6dd4 to your computer and use it in GitHub Desktop.
Save manoj-choudhari-git/449ea9998569d3e1a60d5a0657ee6dd4 to your computer and use it in GitHub Desktop.
C# Console application starting the host for dependency injection
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