public void Options_Populate_Root_Resolve_Nested_Using_TenantContainerAdaptor() { ServiceCollection services = new ServiceCollection(); services.AddOptions(); services.AddLogging(); services.Configure <MyOptions>((a) => { a.Prop = true; }); ServiceProvider serviceProvider = services.BuildServiceProvider(); StructureMap.Container container = new StructureMap.Container(); Dotnettency.Container.StructureMap.ContainerExtensions.Populate(container, services); // container.Populate(services); ITenantContainerAdaptor sp = container.GetInstance <ITenantContainerAdaptor>(); ITenantContainerAdaptor childSp = sp.CreateChildContainer("Child"); var nestedSp = childSp.CreateChildContainer("Nested"); IOptions <MyOptions> options = nestedSp.GetRequiredService <IOptions <MyOptions> >(); Assert.True(options.Value?.Prop); }
public Task <ITenantContainerAdaptor> BuildAsync(TTenant tenant) { var tenantContainer = _parentContainer.CreateChildContainer(); tenantContainer.Configure(config => { _configureTenant(tenant, config); }); return(Task.FromResult(tenantContainer)); }