public static IApplicationBuilder UseMultitenancy <TTenant>(this IApplicationBuilder app, Action <MultitenancyMiddlewareOptionsBuilder <TTenant> > configure) where TTenant : class { var builder = new MultitenancyMiddlewareOptionsBuilder <TTenant>(app); configure(builder); return(app); }
public static MultitenancyMiddlewareOptionsBuilder <TTenant> UsePerTenantHostingEnvironment <TTenant>( this MultitenancyMiddlewareOptionsBuilder <TTenant> builder, Action <PerTenantHostingEnvironmentMiddlewareOptionsBuilder <TTenant> > configure) where TTenant : class { var optionsBuilder = new PerTenantHostingEnvironmentMiddlewareOptionsBuilder <TTenant>(builder); configure(optionsBuilder); return(builder); }
public static IAppBuilder UseMultitenancy <TTenant>(this IAppBuilder app, IServiceProvider services, Action <MultitenancyMiddlewareOptionsBuilder <TTenant> > configure) where TTenant : class { app.UseRequestScopeContext(); // Always required in middleware pipeline, so that AppBuilderAdaptor service can establish current owin context. var adaptor = new AppBuilderAdaptor(app, services); var builder = new MultitenancyMiddlewareOptionsBuilder <TTenant>(adaptor); configure(builder); return(app); }
public UseModulesOptionsBuilder(MultitenancyMiddlewareOptionsBuilder <TTenant> parent) { _parent = parent; }
public static UseModulesOptionsBuilder <TTenant> UseModules <TTenant>(this MultitenancyMiddlewareOptionsBuilder <TTenant> builder) where TTenant : class { return(new UseModulesOptionsBuilder <TTenant>(builder)); }
public static MultitenancyMiddlewareOptionsBuilder <TTenant> UsePerTenantMiddlewarePipeline <TTenant>(this MultitenancyMiddlewareOptionsBuilder <TTenant> builder, IAppBuilder rootAppBuilder, IServiceProvider appServices = null) where TTenant : class { var httpContextProvider = builder.ApplicationBuilder.ApplicationServices.GetRequiredService <IHttpContextProvider>(); var options = new TenantPipelineMiddlewareOptions() { IsTerminal = false, RootApp = rootAppBuilder, ApplicationServices = appServices, HttpContextProvider = httpContextProvider }; builder.ApplicationBuilder.UseMiddleware <TenantPipelineMiddleware <TTenant> >(options); return(builder); }
public static MultitenancyMiddlewareOptionsBuilder <TTenant> UsePerTenantContainers <TTenant>(this MultitenancyMiddlewareOptionsBuilder <TTenant> builder) where TTenant : class { builder.ApplicationBuilder.UseMiddleware <TenantContainerMiddleware <TTenant> >(builder.ApplicationBuilder); return(builder); }
public static MultitenancyMiddlewareOptionsBuilder <TTenant> UsePerTenantMiddlewarePipeline <TTenant>(this MultitenancyMiddlewareOptionsBuilder <TTenant> builder, IApplicationBuilder rootAppBuilder) where TTenant : class { var options = new TenantPipelineMiddlewareOptions() { IsTerminal = false, RootApp = rootAppBuilder }; builder.ApplicationBuilder.UseMiddleware <TenantPipelineMiddleware <TTenant> >(options); return(builder); }
public static MultitenancyMiddlewareOptionsBuilder <TTenant> UseTenantContainers <TTenant>(this MultitenancyMiddlewareOptionsBuilder <TTenant> builder) where TTenant : class { var options = new TenantContainerMiddlewareOptions() { DisposeAtEndOfRequest = true, HttpContextProvider = builder.ApplicationBuilder.ApplicationServices.GetRequiredService <IHttpContextProvider>() }; builder.ApplicationBuilder.UseMiddleware <TenantContainerMiddleware <TTenant> >(options); return(builder); }
public static MultitenancyMiddlewareOptionsBuilder <TTenant> UseRequestContextItem <TTenant, TItem>(this MultitenancyMiddlewareOptionsBuilder <TTenant> builder, Func <TItem> factory, bool disposeOfAtEndOfRequest, Action <TItem> onInstanceCreated = null) where TItem : IDisposable { var httpContextProvider = builder.ApplicationBuilder.ApplicationServices.GetRequiredService <IHttpContextProvider>(); var options = new SetRequestContextItemMiddlewareOptions <TItem>() { HttpContextProvider = httpContextProvider, Factory = factory, DisposeAtEndOfRequest = disposeOfAtEndOfRequest, OnInstanceCreated = onInstanceCreated }; builder.ApplicationBuilder.UseMiddleware <SetRequestContextItemMiddleware <TItem> >(options); return(builder); }
public static MultitenancyMiddlewareOptionsBuilder <TTenant> UseRequestServices <TTenant>(this MultitenancyMiddlewareOptionsBuilder <TTenant> builder, Func <IServiceScope> factory) where TTenant : class { UseRequestContextItem <TTenant, IServiceScope>(builder, factory, true, (scope) => { // Set the request scoped IServiceProvider as the current .RequestServices for the environment. // In ASP.NET Core this is HttpContext.RequestServices, in OWIN, we store it in an Items dictionary. var swapper = builder.ApplicationBuilder.ApplicationServices.GetRequiredService <RequestServicesSwapper <TTenant> >(); swapper.SwapRequestServices(scope.ServiceProvider); }); return(builder); }
public PerTenantHostingEnvironmentMiddlewareOptionsBuilder(MultitenancyMiddlewareOptionsBuilder <TTenant> builder) { _builder = builder; }