public IDependencyContainer BeginScope(Action <ContainerConfigurator> configuration = null) { var innerScope = new AutofacContainer(); innerScope.AutofacScope = AutofacScope.BeginLifetimeScope(builder => { new AutofacContainerBuilder(builder).Configure(configuration); innerScope.RegisterSelf(builder); }); return(innerScope); }
public IDependencyContainerV2 BeginScope(LifetimeScope scope, Action <ContainerConfigurator> configuration = null) { var innerScope = new AutofacContainer(); var autofacScope = scope.Equals(LifetimeScope.Local) ? new object() : scope; innerScope.AutofacScope = AutofacScope.BeginLifetimeScope(autofacScope, builder => { new AutofacContainerBuilder(builder).Configure(configuration); innerScope.RegisterSelf(builder); }); return(innerScope); }