public static IAppBuilder UseRequestServices(this IAppBuilder builder, IHttpContextProvider httpContextProvider, Func <IServiceScope> factory)
 {
     UseRequestContextItem <IServiceScope>(builder, httpContextProvider, factory, true, (item) => {
         httpContextProvider.GetCurrent().SetRequestServices(item.ServiceProvider);
     });
     return(builder);
 }
Ejemplo n.º 2
0
        public IFileProvider GetActiveFileProvider()
        {
            var currentContext = _contextprovider.GetCurrent();

            if (currentContext == null)
            {
                return(null);
            }
            var cabinet      = GetCabinet(currentContext).Result;
            var fileProvider = cabinet?.FileProvider;

            return(fileProvider);
        }
        public void SwapRequestServices(IServiceProvider serviceProvider)
        {
            // var perRequestContainer = await _requestContainerAccessor.TenantRequestContainer.Value;
            var context = _httpContextProvider.GetCurrent();

            var old = context.GetRequestServices();

            context.SetRequestServices(serviceProvider);

            _onDispose = () =>
            {
                context.SetRequestServices(old);
            };
        }
        public async Task Restart()
        {
            var identifier = await _tenantDistinguisherAccessor.TenantDistinguisher.Value;

            if (identifier == null)
            {
                // current tenant cannot be identified.
                return;
            }

            var disposable = await _tenantResolver.RemoveTenantShell(identifier);

            _httpContextProvider.GetCurrent().SetItem(Guid.NewGuid().ToString(), disposable, true);
        }