seb-win-refactoring/SafeExamBrowser/CompositionRoot.cs

105 lines
5.1 KiB
C#
Raw Normal View History

2017-07-05 11:41:19 +02:00
/*
* Copyright (c) 2018 ETH Zürich, Educational Development and Technology (LET)
2017-07-28 14:52:15 +02:00
*
2017-07-05 11:41:19 +02:00
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
using System.Collections.Generic;
using SafeExamBrowser.Browser;
using SafeExamBrowser.Configuration;
using SafeExamBrowser.Contracts.Behaviour;
using SafeExamBrowser.Contracts.Configuration;
2017-07-28 14:52:15 +02:00
using SafeExamBrowser.Contracts.Configuration.Settings;
using SafeExamBrowser.Contracts.I18n;
using SafeExamBrowser.Contracts.Logging;
using SafeExamBrowser.Contracts.Monitoring;
using SafeExamBrowser.Contracts.SystemComponents;
using SafeExamBrowser.Contracts.UserInterface;
using SafeExamBrowser.Contracts.UserInterface.Taskbar;
using SafeExamBrowser.Contracts.WindowsApi;
using SafeExamBrowser.Core.Behaviour;
using SafeExamBrowser.Core.Behaviour.Operations;
using SafeExamBrowser.Core.I18n;
using SafeExamBrowser.Core.Logging;
using SafeExamBrowser.Monitoring.Display;
2017-08-04 12:19:56 +02:00
using SafeExamBrowser.Monitoring.Keyboard;
2017-08-04 15:20:33 +02:00
using SafeExamBrowser.Monitoring.Mouse;
using SafeExamBrowser.Monitoring.Processes;
2017-07-24 08:56:39 +02:00
using SafeExamBrowser.Monitoring.Windows;
using SafeExamBrowser.SystemComponents;
using SafeExamBrowser.UserInterface.Classic;
using SafeExamBrowser.WindowsApi;
namespace SafeExamBrowser
2017-07-05 11:41:19 +02:00
{
internal class CompositionRoot
2017-07-05 11:41:19 +02:00
{
private IApplicationController browserController;
private IApplicationInfo browserInfo;
private IDisplayMonitor displayMonitor;
2017-08-04 12:19:56 +02:00
private IKeyboardInterceptor keyboardInterceptor;
private ILogger logger;
2017-08-07 12:23:56 +02:00
private ILogContentFormatter logFormatter;
2017-08-04 15:20:33 +02:00
private IMouseInterceptor mouseInterceptor;
private INativeMethods nativeMethods;
private IProcessMonitor processMonitor;
2017-08-04 12:19:56 +02:00
private IRuntimeController runtimeController;
private ISettings settings;
private ISystemComponent<ISystemKeyboardLayoutControl> keyboardLayout;
private ISystemComponent<ISystemPowerSupplyControl> powerSupply;
private ISystemComponent<ISystemWirelessNetworkControl> wirelessNetwork;
private ISystemInfo systemInfo;
private IText text;
private IUserInterfaceFactory uiFactory;
2017-07-24 08:56:39 +02:00
private IWindowMonitor windowMonitor;
public IShutdownController ShutdownController { get; private set; }
public IStartupController StartupController { get; private set; }
public Queue<IOperation> StartupOperations { get; private set; }
public Taskbar Taskbar { get; private set; }
public void BuildObjectGraph()
{
browserInfo = new BrowserApplicationInfo();
logger = new Logger();
2017-08-07 12:23:56 +02:00
logFormatter = new DefaultLogFormatter();
nativeMethods = new NativeMethods();
settings = new Settings();
systemInfo = new SystemInfo();
uiFactory = new UserInterfaceFactory();
2017-08-07 12:23:56 +02:00
logger.Subscribe(new LogFileWriter(logFormatter, settings));
text = new Text(logger);
Taskbar = new Taskbar(new ModuleLogger(logger, typeof(Taskbar)));
browserController = new BrowserApplicationController(settings, text, uiFactory);
displayMonitor = new DisplayMonitor(new ModuleLogger(logger, typeof(DisplayMonitor)), nativeMethods);
2017-08-04 12:19:56 +02:00
keyboardInterceptor = new KeyboardInterceptor(settings.Keyboard, new ModuleLogger(logger, typeof(KeyboardInterceptor)));
keyboardLayout = new KeyboardLayout(new ModuleLogger(logger, typeof(KeyboardLayout)), text);
2017-08-04 15:20:33 +02:00
mouseInterceptor = new MouseInterceptor(new ModuleLogger(logger, typeof(MouseInterceptor)), settings.Mouse);
powerSupply = new PowerSupply(new ModuleLogger(logger, typeof(PowerSupply)), text);
processMonitor = new ProcessMonitor(new ModuleLogger(logger, typeof(ProcessMonitor)), nativeMethods);
windowMonitor = new WindowMonitor(new ModuleLogger(logger, typeof(WindowMonitor)), nativeMethods);
wirelessNetwork = new WirelessNetwork(new ModuleLogger(logger, typeof(WirelessNetwork)), text);
runtimeController = new RuntimeController(displayMonitor, new ModuleLogger(logger, typeof(RuntimeController)), processMonitor, Taskbar, windowMonitor);
2017-07-24 15:29:17 +02:00
ShutdownController = new ShutdownController(logger, settings, text, uiFactory);
StartupController = new StartupController(logger, settings, systemInfo, text, uiFactory);
StartupOperations = new Queue<IOperation>();
StartupOperations.Enqueue(new I18nOperation(logger, text));
StartupOperations.Enqueue(new KeyboardInterceptorOperation(keyboardInterceptor, logger, nativeMethods));
StartupOperations.Enqueue(new WindowMonitorOperation(logger, windowMonitor));
StartupOperations.Enqueue(new ProcessMonitorOperation(logger, processMonitor));
StartupOperations.Enqueue(new DisplayMonitorOperation(displayMonitor, logger, Taskbar));
StartupOperations.Enqueue(new TaskbarOperation(logger, settings.Taskbar, keyboardLayout, powerSupply, wirelessNetwork, systemInfo, Taskbar, text, uiFactory));
StartupOperations.Enqueue(new BrowserOperation(browserController, browserInfo, logger, Taskbar, uiFactory));
StartupOperations.Enqueue(new RuntimeControllerOperation(runtimeController, logger));
StartupOperations.Enqueue(new ClipboardOperation(logger, nativeMethods));
StartupOperations.Enqueue(new MouseInterceptorOperation(logger, mouseInterceptor, nativeMethods));
}
2017-07-05 11:41:19 +02:00
}
}