Skip to content

Instantly share code, notes, and snippets.

@justinyoo
Last active September 5, 2017 13:08
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/f36bed04c7203e2aacd6c4f15a5048c1 to your computer and use it in GitHub Desktop.
Save justinyoo/f36bed04c7203e2aacd6c4f15a5048c1 to your computer and use it in GitHub Desktop.
Make Your Azure WebJobs Testable Again
public class AutofacJobHostBuilder : JobHostBuilder
{
public AutofacJobHostBuilder(IModule module)
: this(GetJobHostConfigurationBuilder(module))
{
}
public AutofacJobHostBuilder(IJobHostConfigurationBuilder config)
: base(config)
{
}
private static JobHostConfigurationBuilder GetJobHostConfigurationBuilder(IModule module)
{
var handler = new AutofacRegistrationHandler() { RegisterModule = p => p.RegisterModule(module) };
var activator = new AutofacJobActivator().RegisterDependencies(handler);
var builder = new JobHostConfigurationBuilder(activator);
return builder;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment