improve installationmanager

This commit is contained in:
Shaun Walker
2019-09-20 08:50:55 -04:00
parent 83a212e7e3
commit c3ff9ff12b
7 changed files with 52 additions and 42 deletions

View File

@ -147,12 +147,12 @@ namespace Oqtane.Server
// register singleton scoped core services
services.AddSingleton<IConfigurationRoot>(Configuration);
services.AddSingleton<IInstallation, Installation>();
services.AddSingleton<IInstallationManager, InstallationManager>();
// install any modules or themes
ServiceProvider sp = services.BuildServiceProvider();
var Installation = sp.GetRequiredService<IInstallation>();
Installation.Install("Modules,Themes");
var InstallationManager = sp.GetRequiredService<IInstallationManager>();
InstallationManager.InstallPackages("Modules,Themes");
// register transient scoped core services
services.AddTransient<IModuleDefinitionRepository, ModuleDefinitionRepository>();
@ -329,6 +329,31 @@ namespace Oqtane.Server
// register custom claims principal factory for role claims
services.AddTransient<IUserClaimsPrincipalFactory<IdentityUser>, ClaimsPrincipalFactory<IdentityUser>>();
services.AddSingleton<IInstallationManager, InstallationManager>();
// install any modules or themes
ServiceProvider sp = services.BuildServiceProvider();
var InstallationManager = sp.GetRequiredService<IInstallationManager>();
InstallationManager.InstallPackages("Modules,Themes");
// register transient scoped core services
services.AddTransient<IModuleDefinitionRepository, ModuleDefinitionRepository>();
services.AddTransient<IThemeRepository, ThemeRepository>();
services.AddTransient<IUserPermissions, UserPermissions>();
services.AddTransient<ITenantResolver, TenantResolver>();
services.AddTransient<IAliasRepository, AliasRepository>();
services.AddTransient<ITenantRepository, TenantRepository>();
services.AddTransient<ISiteRepository, SiteRepository>();
services.AddTransient<IPageRepository, PageRepository>();
services.AddTransient<IModuleRepository, ModuleRepository>();
services.AddTransient<IPageModuleRepository, PageModuleRepository>();
services.AddTransient<IUserRepository, UserRepository>();
services.AddTransient<IProfileRepository, ProfileRepository>();
services.AddTransient<IRoleRepository, RoleRepository>();
services.AddTransient<IUserRoleRepository, UserRoleRepository>();
services.AddTransient<IPermissionRepository, PermissionRepository>();
services.AddTransient<ISettingRepository, SettingRepository>();
// get list of loaded assemblies
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
string path = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
@ -361,26 +386,6 @@ namespace Oqtane.Server
}
services.AddMvc().AddModuleAssemblies(moduleassemblies).AddNewtonsoftJson();
// register singleton scoped core services
services.AddSingleton<IConfigurationRoot>(Configuration);
// register transient scoped core services
services.AddTransient<IModuleDefinitionRepository, ModuleDefinitionRepository>();
services.AddTransient<IThemeRepository, ThemeRepository>();
services.AddTransient<IUserPermissions, UserPermissions>();
services.AddTransient<ITenantResolver, TenantResolver>();
services.AddTransient<IAliasRepository, AliasRepository>();
services.AddTransient<ITenantRepository, TenantRepository>();
services.AddTransient<ISiteRepository, SiteRepository>();
services.AddTransient<IPageRepository, PageRepository>();
services.AddTransient<IModuleRepository, ModuleRepository>();
services.AddTransient<IPageModuleRepository, PageModuleRepository>();
services.AddTransient<IUserRepository, UserRepository>();
services.AddTransient<IRoleRepository, RoleRepository>();
services.AddTransient<IUserRoleRepository, UserRoleRepository>();
services.AddTransient<IPermissionRepository, PermissionRepository>();
services.AddTransient<ISettingRepository, SettingRepository>();
// dynamically register module services, contexts, and repository classes
assemblies = AppDomain.CurrentDomain.GetAssemblies()