Skip to content

Instantly share code, notes, and snippets.

@manoj-choudhari-git
Last active April 26, 2021 21:27
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/3be8cfe271282ead9771ad226d8b1aca to your computer and use it in GitHub Desktop.
Save manoj-choudhari-git/3be8cfe271282ead9771ad226d8b1aca to your computer and use it in GitHub Desktop.
AutofacRootModule for using Autofac in .NET core web applications
public class AutofacRootModule : Module
{
protected override void Load(ContainerBuilder builder)
{
builder.RegisterType<CreatedOnDateTimeService>().As<ISingletonService>().SingleInstance();
builder.RegisterType<CreatedOnDateTimeService>().As<IScopedService>().InstancePerLifetimeScope();
builder.RegisterType<CreatedOnDateTimeService>().As<ITransientService>().InstancePerDependency();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment