public static IServiceCollection AddAutofac(this IServiceCollection services, Action <AutofacOptions> setupAction = null) { var options = new AutofacOptions(); if (setupAction != null) { setupAction(options); } return(services.AddSingleton <IServiceProviderFactory <ContainerBuilder> >(new AutofacServiceProviderFactory(options))); }
/// <summary> /// Uses the autofac container. /// </summary> public static IHostBuilder UseAutofac(this IHostBuilder builder, Action <HostBuilderContext, AutofacOptions> configure) { return(builder.UseServiceProviderFactory(context => { var options = new AutofacOptions(); if (configure != null) { configure(context, options); } return new AutofacServiceProviderFactory(options) ; })); }
public AutofacServiceProviderFactory(AutofacOptions options) { _options = options; }