Skip to content

Instantly share code, notes, and snippets.

@justinyoo
Created April 1, 2018 14:38
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 justinyoo/1b6dc3f68ff6fda34ac73a9a878416d6 to your computer and use it in GitHub Desktop.
Save justinyoo/1b6dc3f68ff6fda34ac73a9a878416d6 to your computer and use it in GitHub Desktop.
Dependency Injections on Azure Functions V2
public class ContainerBuilder : IContainerBuilder
{
private readonly IServiceCollection _services;
public ContainerBuilder()
{
this._services = new ServiceCollection();
}
public IContainerBuilder RegisterModule(IModule module = null)
{
if (module == null)
{
module = new Module();
}
module.Load(this._services);
return this;
}
public IServiceProvider Build()
{
var provider = this._services.BuildServiceProvider();
return provider;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment