示例#1
0
        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>();
        }
示例#2
0
        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);
        }
示例#3
0
 private IReadOnlyList <ICafModuleDescriptor> LoadModules(IServiceCollection services, IConfiguration configuration, CafApplicationCreationOptions options)
 {
     return(services
            .GetSingletonInstance <IModuleLoader>()
            .LoadModules(
                services,
                configuration,
                StartupModuleType
                ));
 }