internal static void AddCoreCafServices(this IServiceCollection services, CafApplicationCreationOptions applicationCreationOptions) { var moduleLoader = new ModuleLoader(); if (!services.IsAdded <IConfiguration>()) { services.AddSingleton <IConfiguration>(ConfigurationHelper.BuildConfiguration( applicationCreationOptions.Configuration )); } services.TryAddSingleton <IModuleLoader>(moduleLoader); services.TryAddSingleton <IDefaultAutoRegistrar>(new DefaultAutoRegistrar()); services.AddAssemblyOf <ICafApplication>(); }
internal CafApplicationBase(Type startupModuleType, IServiceCollection services, IConfiguration configuration, Action <CafApplicationCreationOptions> optionsAction) { StartupModuleType = startupModuleType; Services = services; services.AddObjectWrapper <IServiceProvider>(); Configuration = configuration; var options = new CafApplicationCreationOptions(services); optionsAction?.Invoke(options); services.AddSingleton <ICafApplication>(this); services.AddSingleton <IModuleContainer>(this); services.AddCoreServices(); services.AddCoreCafServices(options); Modules = LoadModules(services, configuration, options); }
private IReadOnlyList <ICafModuleDescriptor> LoadModules(IServiceCollection services, IConfiguration configuration, CafApplicationCreationOptions options) { return(services .GetSingletonInstance <IModuleLoader>() .LoadModules( services, configuration, StartupModuleType )); }