public IServiceScope CreateScope() { var httpContext = _httpContextAccessor.HttpContext; string tenant = null; if (httpContext != null) { tenant = _tenantResolver.ResolveTenant(httpContext); } var scopedConatiner = _tenantContainerProvider.GetTenantContainer(tenant).OpenScope(Reuse.WebRequestScopeName); return(scopedConatiner.Resolve <IServiceScope>()); }
public IEnumerable <TenantTestModel> GetServicesForTenantsFromContainers() { for (int i = 1; i <= 3; i++) { string tenant = $"t{i}"; using (_tenantProvider.BeginScope(tenant)) { // working but ugly (I don't want to flood the services code with the "tenant-related services / code") var tenantContainer = _tenantContainerProvider.GetTenantContainer(tenant); var tenantService = tenantContainer.Resolve <ITenantService>(); yield return(new TenantTestModel(tenant, tenantService.DescribeServices())); } } }