Beispiel #1
0
        public IEnumerable <TenantTestModel> GetServicesForTenants()
        {
            for (int i = 1; i <= 3; i++)
            {
                string tenant = $"t{i}";

                using (_tenantProvider.BeginScope(tenant))
                {
                    // Here I want to get the service for specific tenant
                    var tenantService = _tenantServiceResolver();
                    yield return(new TenantTestModel(tenant, tenantService.DescribeServices()));
                }
            }
        }
#pragma warning disable UseAsyncSuffix // Use Async suffix
        public async Task Invoke(HttpContext httpContext, ITenantResolver tenantResolver, ITenantProvider tenantProvider)
#pragma warning restore UseAsyncSuffix // Use Async suffix
        {
            var tenant = tenantResolver.ResolveTenant(httpContext);

            if (string.IsNullOrEmpty(tenant))
            {
                // Call the next middleware delegate in the pipeline
                await _next.Invoke(httpContext);
            }
            else
            {
                using (tenantProvider.BeginScope(tenant))
                {
                    await _next.Invoke(httpContext);
                }
            }
        }