Esempio n. 1
0
        /// <inheritdoc />
        public void RegisterTypes(IContainerProvider container)
        {
            container.RegisterFactory <ILogger>(_ => LogManager.GetCurrentClassLogger());

            container.RegisterInstance <IDbContextFactory>(new DbContextFactory(() => new EngineDbContext(container.GetDbContextOptions <EngineDbContext>())));

            container.RegisterType <IModuleService, ModuleService>();
            container.RegisterType <IModuleConnectionService, ModuleConnectionService>();

            container.RegisterSingleton <ISettingsRegistry, SettingsRegistry>();
            container.RegisterSingleton <ISettingsService, SettingsService>();
            container.RegisterInstance <ISettingHandlerFactory>(new SettingHandlerFactory(t => (ISettingHandler)container.Resolve(t)));

            container.RegisterSingleton <IApiServer, ApiServer>();
            container.RegisterInstance <IApiServerConfiguration>(new ApiConfiguration {
                PipeName = Globals.EnginePipeName
            });
            container.RegisterSingleton <IApiClient, ApiClient>();
            container.RegisterInstance <IApiClientConfiguration>(new ApiConfiguration {
                PipeName = Globals.AppPipeName
            });
            container.RegisterSingleton <IRequestProcessorFactory, RequestProcessorFactory>();
            container.RegisterSingleton <IMessageSerializer, MessagePackMessageSerializer>();

            container.RegisterSingleton <IUpdateService, HttpUpdateService>();
        }
Esempio n. 2
0
        public void RegisterTypes(IContainerProvider container)
        {
            var configurationBuilder = new ConfigurationBuilder();

            configurationBuilder.AddJsonFile("appsettings.json", false);
            var configuration = configurationBuilder.Build();

            container.RegisterInstance <IConfiguration>(configuration);

            container.RegisterFactory <ILogger>(c => LogManager.GetCurrentClassLogger());

            container.RegisterInstance <IDbContextFactory>(new DbContextFactory(() => new AppDbContext(container.GetDbContextOptions <AppDbContext>())));

            container.RegisterSingleton <INavigationManager, NavigationManager>();

            container.RegisterSingleton <IApplicationStateService, ApplicationStateService>();

            container.RegisterSingleton <IResourceRegistry, ResourceRegistry>();
            container.RegisterSingleton <IMenuItemRegistry, MenuItemRegistry>();
            container.RegisterSingleton <IToolBarRegistry, ToolBarRegistry>();
            container.RegisterSingleton <IWidgetRegistry, WidgetRegistry>();
            container.RegisterSingleton <IWidgetFactory, WidgetFactory>();

            container.RegisterSingleton <IRequestProcessorFactory, RequestProcessorFactory>();
            container.RegisterType <IRequestProcessor, ApiEventRequestProcessor>();
            container.RegisterSingleton <IApiServer, ApiServer>();
            container.RegisterInstance <IApiServerConfiguration>(new ApiConfiguration {
                PipeName = Globals.AppPipeName
            });
            container.RegisterSingleton <IApiClient, ApiClient>();
            container.RegisterInstance <IApiClientConfiguration>(new ApiConfiguration {
                PipeName = Globals.EnginePipeName
            });
            container.RegisterSingleton <IMessageSerializer, MessagePackMessageSerializer>();

            container.RegisterSingleton <ISettingsRegistry, SettingsRegistry>();
            container.RegisterSingleton <ISettingsService, SettingsService>();
            container.RegisterInstance <ISettingHandlerFactory>(new SettingHandlerFactory(t => (ISettingHandler)container.Resolve(t)));

            container.RegisterDialog <MessageBoxView, MessageBoxViewModel>();

            container.RegisterView <MainMenuView, MainMenuViewModel>();
            container.RegisterView <MainStatusBarView, MainStatusBarViewModel>();
            container.RegisterView <ToolBarView, ToolBarViewModel>();

            container.RegisterView <StartupView, StartupViewModel>();
            container.RegisterView <StatusView, StatusViewModel>();
            container.RegisterView <MainView, MainViewModel>();
            container.RegisterView <SettingsView, SettingsViewModel>();
            container.RegisterView <AboutView, AboutViewModel>();

            container.RegisterRequestProcessor <UpdatesRequestProcessor>();
            container.RegisterSingleton <IUpdateService, HttpUpdateService>();
            container.RegisterSingleton <UpdateHandler>();
        }