diff --git a/SafeExamBrowser.Browser/BrowserApplicationController.cs b/SafeExamBrowser.Browser/BrowserApplicationController.cs index 9ad7eed6..4eb83bab 100644 --- a/SafeExamBrowser.Browser/BrowserApplicationController.cs +++ b/SafeExamBrowser.Browser/BrowserApplicationController.cs @@ -24,11 +24,17 @@ namespace SafeExamBrowser.Browser private IApplicationButton button; private IList instances = new List(); private IBrowserSettings settings; + private IRuntimeInfo runtimeInfo; private IUserInterfaceFactory uiFactory; private IText text; - public BrowserApplicationController(IBrowserSettings settings, IText text, IUserInterfaceFactory uiFactory) + public BrowserApplicationController( + IBrowserSettings settings, + IRuntimeInfo runtimeInfo, + IText text, + IUserInterfaceFactory uiFactory) { + this.runtimeInfo = runtimeInfo; this.settings = settings; this.text = text; this.uiFactory = uiFactory; @@ -38,8 +44,8 @@ namespace SafeExamBrowser.Browser { var cefSettings = new CefSettings { - CachePath = settings.CachePath, - LogFile = settings.LogFile + CachePath = runtimeInfo.BrowserCachePath, + LogFile = runtimeInfo.BrowserLogFile }; var success = Cef.Initialize(cefSettings, true, null); diff --git a/SafeExamBrowser.Client/CompositionRoot.cs b/SafeExamBrowser.Client/CompositionRoot.cs index 5074b6d2..6ace1af4 100644 --- a/SafeExamBrowser.Client/CompositionRoot.cs +++ b/SafeExamBrowser.Client/CompositionRoot.cs @@ -21,16 +21,8 @@ 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; -using SafeExamBrowser.Monitoring.Keyboard; -using SafeExamBrowser.Monitoring.Mouse; -using SafeExamBrowser.Monitoring.Processes; -using SafeExamBrowser.Monitoring.Windows; -using SafeExamBrowser.SystemComponents; using SafeExamBrowser.UserInterface.Classic; using SafeExamBrowser.WindowsApi; @@ -64,46 +56,51 @@ namespace SafeExamBrowser.Client internal void BuildObjectGraph() { browserInfo = new BrowserApplicationInfo(); + logger = new Logger(); nativeMethods = new NativeMethods(); settings = new SettingsRepository().LoadDefaults(); systemInfo = new SystemInfo(); uiFactory = new UserInterfaceFactory(); - InitializeLogger(); + InitializeLogging(); text = new Text(logger); - Taskbar = new Taskbar(new ModuleLogger(logger, typeof(Taskbar))); - browserController = new BrowserApplicationController(settings.Browser, text, uiFactory); - displayMonitor = new DisplayMonitor(new ModuleLogger(logger, typeof(DisplayMonitor)), nativeMethods); - keyboardInterceptor = new KeyboardInterceptor(settings.Keyboard, new ModuleLogger(logger, typeof(KeyboardInterceptor))); - keyboardLayout = new KeyboardLayout(new ModuleLogger(logger, typeof(KeyboardLayout)), text); - 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); + // TODO + //Taskbar = new Taskbar(new ModuleLogger(logger, typeof(Taskbar))); + //browserController = new BrowserApplicationController(settings.Browser, text, uiFactory); + //displayMonitor = new DisplayMonitor(new ModuleLogger(logger, typeof(DisplayMonitor)), nativeMethods); + //keyboardInterceptor = new KeyboardInterceptor(settings.Keyboard, new ModuleLogger(logger, typeof(KeyboardInterceptor))); + //keyboardLayout = new KeyboardLayout(new ModuleLogger(logger, typeof(KeyboardLayout)), text); + //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); - clientController = new ClientController(displayMonitor, new ModuleLogger(logger, typeof(ClientController)), processMonitor, Taskbar, windowMonitor); - ShutdownController = new ShutdownController(logger, settings, text, uiFactory); - StartupController = new StartupController(logger, settings, systemInfo, text, uiFactory); + //clientController = new ClientController(displayMonitor, new ModuleLogger(logger, typeof(ClientController)), processMonitor, Taskbar, windowMonitor); + //ShutdownController = new ShutdownController(logger, settings, text, uiFactory); + //StartupController = new StartupController(logger, settings, systemInfo, text, uiFactory); - StartupOperations = new Queue(); - 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 ClientControllerOperation(clientController, logger)); - StartupOperations.Enqueue(new ClipboardOperation(logger, nativeMethods)); - StartupOperations.Enqueue(new MouseInterceptorOperation(logger, mouseInterceptor, nativeMethods)); + //StartupOperations = new Queue(); + //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 ClientControllerOperation(clientController, logger)); + //StartupOperations.Enqueue(new ClipboardOperation(logger, nativeMethods)); + //StartupOperations.Enqueue(new MouseInterceptorOperation(logger, mouseInterceptor, nativeMethods)); } - private void InitializeLogger() + private void InitializeLogging() { - logger = new Logger(); - logger.Subscribe(new LogFileWriter(new DefaultLogFormatter(), settings.Logging.ClientLogFile)); + // TODO + //var logFileWriter = new LogFileWriter(new DefaultLogFormatter(), settings.Logging.ClientLogFile); + + //logFileWriter.Initialize(); + //logger.Subscribe(logFileWriter); } } } diff --git a/SafeExamBrowser.Configuration/Settings/LoggingSettings.cs b/SafeExamBrowser.Configuration/RuntimeInfo.cs similarity index 59% rename from SafeExamBrowser.Configuration/Settings/LoggingSettings.cs rename to SafeExamBrowser.Configuration/RuntimeInfo.cs index 10b9330d..18bc24d2 100644 --- a/SafeExamBrowser.Configuration/Settings/LoggingSettings.cs +++ b/SafeExamBrowser.Configuration/RuntimeInfo.cs @@ -1,22 +1,27 @@ /* * Copyright (c) 2018 ETH Zürich, Educational Development and Technology (LET) - * + * * 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; -using SafeExamBrowser.Contracts.Configuration.Settings; +using SafeExamBrowser.Contracts.Configuration; -namespace SafeExamBrowser.Configuration.Settings +namespace SafeExamBrowser.Configuration { [Serializable] - internal class LoggingSettings : ILoggingSettings + public class RuntimeInfo : IRuntimeInfo { + public string AppDataFolder { get; set; } public DateTime ApplicationStartTime { get; set; } + public string BrowserCachePath { get; set; } public string BrowserLogFile { get; set; } public string ClientLogFile { get; set; } + public string ProgramCopyright { get; set; } + public string ProgramTitle { get; set; } + public string ProgramVersion { get; set; } public string RuntimeLogFile { get; set; } } } diff --git a/SafeExamBrowser.Configuration/SafeExamBrowser.Configuration.csproj b/SafeExamBrowser.Configuration/SafeExamBrowser.Configuration.csproj index a60b92cf..e17b4eb5 100644 --- a/SafeExamBrowser.Configuration/SafeExamBrowser.Configuration.csproj +++ b/SafeExamBrowser.Configuration/SafeExamBrowser.Configuration.csproj @@ -53,9 +53,9 @@ + - diff --git a/SafeExamBrowser.Configuration/Settings/Settings.cs b/SafeExamBrowser.Configuration/Settings/Settings.cs index dd869808..2e4b5685 100644 --- a/SafeExamBrowser.Configuration/Settings/Settings.cs +++ b/SafeExamBrowser.Configuration/Settings/Settings.cs @@ -14,22 +14,15 @@ namespace SafeExamBrowser.Configuration.Settings [Serializable] internal class Settings : ISettings { - public string AppDataFolder { get; set; } - public string ProgramCopyright { get; set; } - public string ProgramTitle { get; set; } - public string ProgramVersion { get; set; } - public IBrowserSettings Browser { get; private set; } public IKeyboardSettings Keyboard { get; private set; } - public ILoggingSettings Logging { get; private set; } public IMouseSettings Mouse { get; private set; } public ITaskbarSettings Taskbar { get; private set; } - public Settings(BrowserSettings browser, KeyboardSettings keyboard, LoggingSettings logging, MouseSettings mouse, TaskbarSettings taskbar) + public Settings(BrowserSettings browser, KeyboardSettings keyboard, MouseSettings mouse, TaskbarSettings taskbar) { Browser = browser; Keyboard = keyboard; - Logging = logging; Mouse = mouse; Taskbar = taskbar; } diff --git a/SafeExamBrowser.Configuration/Settings/SettingsRepository.cs b/SafeExamBrowser.Configuration/Settings/SettingsRepository.cs index 10fb7eba..701757ba 100644 --- a/SafeExamBrowser.Configuration/Settings/SettingsRepository.cs +++ b/SafeExamBrowser.Configuration/Settings/SettingsRepository.cs @@ -7,8 +7,6 @@ */ using System; -using System.IO; -using System.Reflection; using SafeExamBrowser.Contracts.Configuration.Settings; namespace SafeExamBrowser.Configuration.Settings @@ -25,26 +23,11 @@ namespace SafeExamBrowser.Configuration.Settings { var browser = new BrowserSettings(); var keyboard = new KeyboardSettings(); - var logging = new LoggingSettings(); var mouse = new MouseSettings(); var taskbar = new TaskbarSettings(); - var settings = new Settings(browser, keyboard, logging, mouse, taskbar); - var executable = Assembly.GetEntryAssembly(); - var startTime = DateTime.Now; - var logFolderName = "Logs"; - var logFilePrefix = startTime.ToString("yyyy-MM-dd\\_HH\\hmm\\mss\\s"); - - settings.AppDataFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), nameof(SafeExamBrowser)); - settings.ProgramCopyright = executable.GetCustomAttribute().Copyright; - settings.ProgramTitle = executable.GetCustomAttribute().Title; - settings.ProgramVersion = executable.GetCustomAttribute().InformationalVersion; - - browser.CachePath = Path.Combine(settings.AppDataFolder, "Cache"); - - logging.ApplicationStartTime = DateTime.Now; - logging.BrowserLogFile = Path.Combine(settings.AppDataFolder, logFolderName, $"{logFilePrefix}_Browser.txt"); - logging.ClientLogFile = Path.Combine(settings.AppDataFolder, logFolderName, $"{logFilePrefix}_Client.txt"); - logging.RuntimeLogFile = Path.Combine(settings.AppDataFolder, logFolderName, $"{logFilePrefix}_Runtime.txt"); + var settings = new Settings(browser, keyboard, mouse, taskbar); + + // TODO return settings; } diff --git a/SafeExamBrowser.Contracts/Configuration/Settings/ILoggingSettings.cs b/SafeExamBrowser.Contracts/Configuration/IRuntimeInfo.cs similarity index 54% rename from SafeExamBrowser.Contracts/Configuration/Settings/ILoggingSettings.cs rename to SafeExamBrowser.Contracts/Configuration/IRuntimeInfo.cs index 2832210f..989e0f3b 100644 --- a/SafeExamBrowser.Contracts/Configuration/Settings/ILoggingSettings.cs +++ b/SafeExamBrowser.Contracts/Configuration/IRuntimeInfo.cs @@ -8,15 +8,25 @@ using System; -namespace SafeExamBrowser.Contracts.Configuration.Settings +namespace SafeExamBrowser.Contracts.Configuration { - public interface ILoggingSettings + public interface IRuntimeInfo { + /// + /// The path of the application data folder. + /// + string AppDataFolder { get; } + /// /// The point in time when the application was started. /// DateTime ApplicationStartTime { get; } + /// + /// The path where the browser cache is to be stored. + /// + string BrowserCachePath { get; } + /// /// The file path under which the log of the browser component is to be stored. /// @@ -27,6 +37,21 @@ namespace SafeExamBrowser.Contracts.Configuration.Settings /// string ClientLogFile { get; } + /// + /// The copyright information for the application (i.e. the executing assembly). + /// + string ProgramCopyright { get; } + + /// + /// The program title of the application (i.e. the executing assembly). + /// + string ProgramTitle { get; } + + /// + /// The program version of the application (i.e. the executing assembly). + /// + string ProgramVersion { get; } + /// /// The file path under which the log of the runtime component is to be stored. /// diff --git a/SafeExamBrowser.Contracts/Configuration/Settings/IBrowserSettings.cs b/SafeExamBrowser.Contracts/Configuration/Settings/IBrowserSettings.cs index 01064b05..b19d2a30 100644 --- a/SafeExamBrowser.Contracts/Configuration/Settings/IBrowserSettings.cs +++ b/SafeExamBrowser.Contracts/Configuration/Settings/IBrowserSettings.cs @@ -35,16 +35,6 @@ namespace SafeExamBrowser.Contracts.Configuration.Settings /// bool AllowReloading { get; } - /// - /// The path where the browser cache is to be stored. - /// - string CachePath { get; } - - /// - /// The file path under which the browser log is to be stored. - /// - string LogFile { get; } - /// /// Determines whether the main browser window should be rendered in fullscreen mode, i.e. without window frame. /// diff --git a/SafeExamBrowser.Contracts/Configuration/Settings/ISettings.cs b/SafeExamBrowser.Contracts/Configuration/Settings/ISettings.cs index 350ecd3f..5b2015d9 100644 --- a/SafeExamBrowser.Contracts/Configuration/Settings/ISettings.cs +++ b/SafeExamBrowser.Contracts/Configuration/Settings/ISettings.cs @@ -10,11 +10,6 @@ namespace SafeExamBrowser.Contracts.Configuration.Settings { public interface ISettings { - /// - /// The path of the application data folder. - /// - string AppDataFolder { get; } - /// /// All browser-related settings. /// @@ -25,31 +20,11 @@ namespace SafeExamBrowser.Contracts.Configuration.Settings /// IKeyboardSettings Keyboard { get; } - /// - /// All logging-related settings. - /// - ILoggingSettings Logging { get; } - /// /// All mouse-related settings. /// IMouseSettings Mouse { get; } - /// - /// The copyright information for the application (i.e. the executing assembly). - /// - string ProgramCopyright { get; } - - /// - /// The program title of the application (i.e. the executing assembly). - /// - string ProgramTitle { get; } - - /// - /// The program version of the application (i.e. the executing assembly). - /// - string ProgramVersion { get; } - /// /// All taskbar-related settings. /// diff --git a/SafeExamBrowser.Contracts/SafeExamBrowser.Contracts.csproj b/SafeExamBrowser.Contracts/SafeExamBrowser.Contracts.csproj index b5d01816..2d630c3c 100644 --- a/SafeExamBrowser.Contracts/SafeExamBrowser.Contracts.csproj +++ b/SafeExamBrowser.Contracts/SafeExamBrowser.Contracts.csproj @@ -53,6 +53,7 @@ + @@ -65,7 +66,6 @@ - diff --git a/SafeExamBrowser.Contracts/UserInterface/IUserInterfaceFactory.cs b/SafeExamBrowser.Contracts/UserInterface/IUserInterfaceFactory.cs index ff489769..33ab4511 100644 --- a/SafeExamBrowser.Contracts/UserInterface/IUserInterfaceFactory.cs +++ b/SafeExamBrowser.Contracts/UserInterface/IUserInterfaceFactory.cs @@ -19,7 +19,7 @@ namespace SafeExamBrowser.Contracts.UserInterface /// /// Creates a new about window displaying information about the currently running application version. /// - IWindow CreateAboutWindow(ISettings settings, IText text); + IWindow CreateAboutWindow(IRuntimeInfo runtimeInfo, IText text); /// /// Creates a taskbar button, initialized with the given application information. @@ -54,7 +54,7 @@ namespace SafeExamBrowser.Contracts.UserInterface /// /// Creates a new splash screen which runs on its own thread. /// - ISplashScreen CreateSplashScreen(ISettings settings, IText text); + ISplashScreen CreateSplashScreen(IRuntimeInfo runtimeInfo, IText text); /// /// Creates a system control which allows to change the wireless network connection of the computer. diff --git a/SafeExamBrowser.Core.UnitTests/Behaviour/ShutdownControllerTests.cs b/SafeExamBrowser.Core.UnitTests/Behaviour/ShutdownControllerTests.cs index 9faeb7de..7466c072 100644 --- a/SafeExamBrowser.Core.UnitTests/Behaviour/ShutdownControllerTests.cs +++ b/SafeExamBrowser.Core.UnitTests/Behaviour/ShutdownControllerTests.cs @@ -11,7 +11,7 @@ using System.Collections.Generic; using Microsoft.VisualStudio.TestTools.UnitTesting; using Moq; using SafeExamBrowser.Contracts.Behaviour; -using SafeExamBrowser.Contracts.Configuration.Settings; +using SafeExamBrowser.Contracts.Configuration; using SafeExamBrowser.Contracts.I18n; using SafeExamBrowser.Contracts.Logging; using SafeExamBrowser.Contracts.UserInterface; @@ -23,7 +23,7 @@ namespace SafeExamBrowser.Core.UnitTests.Behaviour public class ShutdownControllerTests { private Mock loggerMock; - private Mock settingsMock; + private Mock runtimeInfoMock; private Mock textMock; private Mock uiFactoryMock; @@ -33,13 +33,13 @@ namespace SafeExamBrowser.Core.UnitTests.Behaviour public void Initialize() { loggerMock = new Mock(); - settingsMock = new Mock(); + runtimeInfoMock = new Mock(); textMock = new Mock(); uiFactoryMock = new Mock(); - uiFactoryMock.Setup(f => f.CreateSplashScreen(settingsMock.Object, textMock.Object)).Returns(new Mock().Object); + uiFactoryMock.Setup(f => f.CreateSplashScreen(runtimeInfoMock.Object, textMock.Object)).Returns(new Mock().Object); - sut = new ShutdownController(loggerMock.Object, settingsMock.Object, textMock.Object, uiFactoryMock.Object); + sut = new ShutdownController(loggerMock.Object, runtimeInfoMock.Object, textMock.Object, uiFactoryMock.Object); } [TestMethod] @@ -117,7 +117,7 @@ namespace SafeExamBrowser.Core.UnitTests.Behaviour [TestMethod] public void MustNotFailInCaseOfUnexpectedError() { - uiFactoryMock.Setup(l => l.CreateSplashScreen(It.IsAny(), It.IsAny())).Throws(new Exception()); + uiFactoryMock.Setup(l => l.CreateSplashScreen(It.IsAny(), It.IsAny())).Throws(new Exception()); sut.FinalizeApplication(new Queue()); } } diff --git a/SafeExamBrowser.Core.UnitTests/Behaviour/StartupControllerTests.cs b/SafeExamBrowser.Core.UnitTests/Behaviour/StartupControllerTests.cs index f323ee87..be07b786 100644 --- a/SafeExamBrowser.Core.UnitTests/Behaviour/StartupControllerTests.cs +++ b/SafeExamBrowser.Core.UnitTests/Behaviour/StartupControllerTests.cs @@ -24,7 +24,7 @@ namespace SafeExamBrowser.Core.UnitTests.Behaviour public class StartupControllerTests { private Mock loggerMock; - private Mock settingsMock; + private Mock runtimeInfoMock; private Mock systemInfoMock; private Mock textMock; private Mock uiFactoryMock; @@ -35,14 +35,14 @@ namespace SafeExamBrowser.Core.UnitTests.Behaviour public void Initialize() { loggerMock = new Mock(); - settingsMock = new Mock(); + runtimeInfoMock = new Mock(); systemInfoMock = new Mock(); textMock = new Mock(); uiFactoryMock = new Mock(); - uiFactoryMock.Setup(f => f.CreateSplashScreen(settingsMock.Object, textMock.Object)).Returns(new Mock().Object); + uiFactoryMock.Setup(f => f.CreateSplashScreen(runtimeInfoMock.Object, textMock.Object)).Returns(new Mock().Object); - sut = new StartupController(loggerMock.Object, settingsMock.Object, systemInfoMock.Object, textMock.Object, uiFactoryMock.Object); + sut = new StartupController(loggerMock.Object, runtimeInfoMock.Object, systemInfoMock.Object, textMock.Object, uiFactoryMock.Object); } [TestMethod] diff --git a/SafeExamBrowser.Core.UnitTests/Notifications/AboutNotificationControllerTests.cs b/SafeExamBrowser.Core.UnitTests/Notifications/AboutNotificationControllerTests.cs index 03748cf5..f8ff0e02 100644 --- a/SafeExamBrowser.Core.UnitTests/Notifications/AboutNotificationControllerTests.cs +++ b/SafeExamBrowser.Core.UnitTests/Notifications/AboutNotificationControllerTests.cs @@ -8,7 +8,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Moq; -using SafeExamBrowser.Contracts.Configuration.Settings; +using SafeExamBrowser.Contracts.Configuration; using SafeExamBrowser.Contracts.I18n; using SafeExamBrowser.Contracts.UserInterface; using SafeExamBrowser.Core.Notifications; @@ -18,14 +18,14 @@ namespace SafeExamBrowser.Core.UnitTests.Notifications [TestClass] public class AboutNotificationControllerTests { - private Mock settingsMock; + private Mock runtimeInfoMock; private Mock textMock; private Mock uiFactoryMock; [TestInitialize] public void Initialize() { - settingsMock = new Mock(); + runtimeInfoMock = new Mock(); textMock = new Mock(); uiFactoryMock = new Mock(); } @@ -35,9 +35,9 @@ namespace SafeExamBrowser.Core.UnitTests.Notifications { var button = new NotificationButtonMock(); var window = new Mock(); - var sut = new AboutNotificationController(settingsMock.Object, textMock.Object, uiFactoryMock.Object); + var sut = new AboutNotificationController(runtimeInfoMock.Object, textMock.Object, uiFactoryMock.Object); - uiFactoryMock.Setup(u => u.CreateAboutWindow(It.IsAny(), It.IsAny())).Returns(window.Object); + uiFactoryMock.Setup(u => u.CreateAboutWindow(It.IsAny(), It.IsAny())).Returns(window.Object); sut.RegisterNotification(button); button.Click(); sut.Terminate(); @@ -50,9 +50,9 @@ namespace SafeExamBrowser.Core.UnitTests.Notifications { var button = new NotificationButtonMock(); var window = new Mock(); - var sut = new AboutNotificationController(settingsMock.Object, textMock.Object, uiFactoryMock.Object); + var sut = new AboutNotificationController(runtimeInfoMock.Object, textMock.Object, uiFactoryMock.Object); - uiFactoryMock.Setup(u => u.CreateAboutWindow(It.IsAny(), It.IsAny())).Returns(window.Object); + uiFactoryMock.Setup(u => u.CreateAboutWindow(It.IsAny(), It.IsAny())).Returns(window.Object); sut.RegisterNotification(button); button.Click(); button.Click(); @@ -60,7 +60,7 @@ namespace SafeExamBrowser.Core.UnitTests.Notifications button.Click(); button.Click(); - uiFactoryMock.Verify(u => u.CreateAboutWindow(It.IsAny(), It.IsAny()), Times.Once); + uiFactoryMock.Verify(u => u.CreateAboutWindow(It.IsAny(), It.IsAny()), Times.Once); window.Verify(u => u.Show(), Times.Once); window.Verify(u => u.BringToForeground(), Times.Exactly(4)); } @@ -69,7 +69,7 @@ namespace SafeExamBrowser.Core.UnitTests.Notifications public void MustSubscribeToClickEvent() { var button = new NotificationButtonMock(); - var sut = new AboutNotificationController(settingsMock.Object, textMock.Object, uiFactoryMock.Object); + var sut = new AboutNotificationController(runtimeInfoMock.Object, textMock.Object, uiFactoryMock.Object); sut.RegisterNotification(button); diff --git a/SafeExamBrowser.Core/Behaviour/ShutdownController.cs b/SafeExamBrowser.Core/Behaviour/ShutdownController.cs index c000c926..2e660ef6 100644 --- a/SafeExamBrowser.Core/Behaviour/ShutdownController.cs +++ b/SafeExamBrowser.Core/Behaviour/ShutdownController.cs @@ -9,6 +9,7 @@ using System; using System.Collections.Generic; using SafeExamBrowser.Contracts.Behaviour; +using SafeExamBrowser.Contracts.Configuration; using SafeExamBrowser.Contracts.Configuration.Settings; using SafeExamBrowser.Contracts.I18n; using SafeExamBrowser.Contracts.Logging; @@ -19,15 +20,15 @@ namespace SafeExamBrowser.Core.Behaviour public class ShutdownController : IShutdownController { private ILogger logger; - private ISettings settings; + private IRuntimeInfo runtimeInfo; private ISplashScreen splashScreen; private IText text; private IUserInterfaceFactory uiFactory; - public ShutdownController(ILogger logger, ISettings settings, IText text, IUserInterfaceFactory uiFactory) + public ShutdownController(ILogger logger, IRuntimeInfo runtimeInfo, IText text, IUserInterfaceFactory uiFactory) { this.logger = logger; - this.settings = settings; + this.runtimeInfo = runtimeInfo; this.text = text; this.uiFactory = uiFactory; } @@ -69,7 +70,7 @@ namespace SafeExamBrowser.Core.Behaviour logger.Log(string.Empty); logger.Info("--- Initiating shutdown procedure ---"); - splashScreen = uiFactory.CreateSplashScreen(settings, text); + splashScreen = uiFactory.CreateSplashScreen(runtimeInfo, text); splashScreen.SetIndeterminate(); splashScreen.UpdateText(TextKey.SplashScreen_ShutdownProcedure); splashScreen.InvokeShow(); diff --git a/SafeExamBrowser.Core/Behaviour/StartupController.cs b/SafeExamBrowser.Core/Behaviour/StartupController.cs index 657d753b..c3aa04cd 100644 --- a/SafeExamBrowser.Core/Behaviour/StartupController.cs +++ b/SafeExamBrowser.Core/Behaviour/StartupController.cs @@ -21,7 +21,7 @@ namespace SafeExamBrowser.Core.Behaviour public class StartupController : IStartupController { private ILogger logger; - private ISettings settings; + private IRuntimeInfo runtimeInfo; private ISplashScreen splashScreen; private ISystemInfo systemInfo; private IText text; @@ -29,10 +29,10 @@ namespace SafeExamBrowser.Core.Behaviour private Stack stack = new Stack(); - public StartupController(ILogger logger, ISettings settings, ISystemInfo systemInfo, IText text, IUserInterfaceFactory uiFactory) + public StartupController(ILogger logger, IRuntimeInfo runtimeInfo, ISystemInfo systemInfo, IText text, IUserInterfaceFactory uiFactory) { this.logger = logger; - this.settings = settings; + this.runtimeInfo = runtimeInfo; this.systemInfo = systemInfo; this.text = text; this.uiFactory = uiFactory; @@ -92,8 +92,8 @@ namespace SafeExamBrowser.Core.Behaviour private void Initialize(int operationCount) { - var titleLine = $"/* {settings.ProgramTitle}, Version {settings.ProgramVersion}{Environment.NewLine}"; - var copyrightLine = $"/* {settings.ProgramCopyright}{Environment.NewLine}"; + var titleLine = $"/* {runtimeInfo.ProgramTitle}, Version {runtimeInfo.ProgramVersion}{Environment.NewLine}"; + var copyrightLine = $"/* {runtimeInfo.ProgramCopyright}{Environment.NewLine}"; var emptyLine = $"/* {Environment.NewLine}"; var githubLine = $"/* Please visit https://github.com/SafeExamBrowser for more information."; @@ -105,7 +105,7 @@ namespace SafeExamBrowser.Core.Behaviour logger.Info("--- Initiating startup procedure ---"); - splashScreen = uiFactory.CreateSplashScreen(settings, text); + splashScreen = uiFactory.CreateSplashScreen(runtimeInfo, text); splashScreen.SetMaxProgress(operationCount); splashScreen.UpdateText(TextKey.SplashScreen_StartupProcedure); splashScreen.InvokeShow(); diff --git a/SafeExamBrowser.Core/Logging/LogFileWriter.cs b/SafeExamBrowser.Core/Logging/LogFileWriter.cs index 2b42481e..fe72ba9b 100644 --- a/SafeExamBrowser.Core/Logging/LogFileWriter.cs +++ b/SafeExamBrowser.Core/Logging/LogFileWriter.cs @@ -24,6 +24,16 @@ namespace SafeExamBrowser.Core.Logging this.formatter = formatter; } + public void Initialize() + { + var logFolder = Path.GetDirectoryName(filePath); + + if (!Directory.Exists(logFolder)) + { + Directory.CreateDirectory(logFolder); + } + } + public void Notify(ILogContent content) { lock (@lock) diff --git a/SafeExamBrowser.Core/Notifications/AboutNotificationController.cs b/SafeExamBrowser.Core/Notifications/AboutNotificationController.cs index c18a61f8..c4be58ad 100644 --- a/SafeExamBrowser.Core/Notifications/AboutNotificationController.cs +++ b/SafeExamBrowser.Core/Notifications/AboutNotificationController.cs @@ -7,6 +7,7 @@ */ using SafeExamBrowser.Contracts.Behaviour; +using SafeExamBrowser.Contracts.Configuration; using SafeExamBrowser.Contracts.Configuration.Settings; using SafeExamBrowser.Contracts.I18n; using SafeExamBrowser.Contracts.UserInterface; @@ -17,14 +18,14 @@ namespace SafeExamBrowser.Core.Notifications public class AboutNotificationController : INotificationController { private INotificationButton notification; - private ISettings settings; + private IRuntimeInfo runtimeInfo; private IText text; private IUserInterfaceFactory uiFactory; private IWindow window; - public AboutNotificationController(ISettings settings, IText text, IUserInterfaceFactory uiFactory) + public AboutNotificationController(IRuntimeInfo runtimeInfo, IText text, IUserInterfaceFactory uiFactory) { - this.settings = settings; + this.runtimeInfo = runtimeInfo; this.text = text; this.uiFactory = uiFactory; } @@ -45,7 +46,7 @@ namespace SafeExamBrowser.Core.Notifications { if (window == null) { - window = uiFactory.CreateAboutWindow(settings, text); + window = uiFactory.CreateAboutWindow(runtimeInfo, text); window.Closing += () => window = null; window.Show(); diff --git a/SafeExamBrowser.UserInterface.Classic/AboutWindow.xaml.cs b/SafeExamBrowser.UserInterface.Classic/AboutWindow.xaml.cs index d51671c5..65d38c7b 100644 --- a/SafeExamBrowser.UserInterface.Classic/AboutWindow.xaml.cs +++ b/SafeExamBrowser.UserInterface.Classic/AboutWindow.xaml.cs @@ -8,7 +8,7 @@ using System.Windows; using System.Windows.Documents; -using SafeExamBrowser.Contracts.Configuration.Settings; +using SafeExamBrowser.Contracts.Configuration; using SafeExamBrowser.Contracts.I18n; using SafeExamBrowser.Contracts.UserInterface; @@ -16,7 +16,7 @@ namespace SafeExamBrowser.UserInterface.Classic { public partial class AboutWindow : Window, IWindow { - private ISettings settings; + private IRuntimeInfo runtimeInfo; private IText text; private WindowClosingEventHandler closing; @@ -26,9 +26,9 @@ namespace SafeExamBrowser.UserInterface.Classic remove { closing -= value; } } - public AboutWindow(ISettings settings, IText text) + public AboutWindow(IRuntimeInfo runtimeInfo, IText text) { - this.settings = settings; + this.runtimeInfo = runtimeInfo; this.text = text; InitializeComponent(); @@ -43,10 +43,10 @@ namespace SafeExamBrowser.UserInterface.Classic private void InitializeAboutWindow() { Closing += (o, args) => closing?.Invoke(); - VersionInfo.Inlines.Add(new Run($"{text.Get(TextKey.Version)} {settings.ProgramVersion}") { FontStyle = FontStyles.Italic }); + VersionInfo.Inlines.Add(new Run($"{text.Get(TextKey.Version)} {runtimeInfo.ProgramVersion}") { FontStyle = FontStyles.Italic }); VersionInfo.Inlines.Add(new LineBreak()); VersionInfo.Inlines.Add(new LineBreak()); - VersionInfo.Inlines.Add(new Run(settings.ProgramCopyright) { FontSize = 10 }); + VersionInfo.Inlines.Add(new Run(runtimeInfo.ProgramCopyright) { FontSize = 10 }); } } } diff --git a/SafeExamBrowser.UserInterface.Classic/SplashScreen.xaml.cs b/SafeExamBrowser.UserInterface.Classic/SplashScreen.xaml.cs index 1510b841..da9104a4 100644 --- a/SafeExamBrowser.UserInterface.Classic/SplashScreen.xaml.cs +++ b/SafeExamBrowser.UserInterface.Classic/SplashScreen.xaml.cs @@ -8,7 +8,7 @@ using System.Windows; using System.Windows.Documents; -using SafeExamBrowser.Contracts.Configuration.Settings; +using SafeExamBrowser.Contracts.Configuration; using SafeExamBrowser.Contracts.I18n; using SafeExamBrowser.Contracts.UserInterface; using SafeExamBrowser.UserInterface.Classic.ViewModels; @@ -18,12 +18,12 @@ namespace SafeExamBrowser.UserInterface.Classic public partial class SplashScreen : Window, ISplashScreen { private SplashScreenViewModel model = new SplashScreenViewModel(); - private ISettings settings; + private IRuntimeInfo runtimeInfo; private IText text; - public SplashScreen(ISettings settings, IText text) + public SplashScreen(IRuntimeInfo runtimeInfo, IText text) { - this.settings = settings; + this.runtimeInfo = runtimeInfo; this.text = text; InitializeComponent(); @@ -73,10 +73,10 @@ namespace SafeExamBrowser.UserInterface.Classic private void InitializeSplashScreen() { - InfoTextBlock.Inlines.Add(new Run($"Version {settings.ProgramVersion}") { FontStyle = FontStyles.Italic }); + InfoTextBlock.Inlines.Add(new Run($"Version {runtimeInfo.ProgramVersion}") { FontStyle = FontStyles.Italic }); InfoTextBlock.Inlines.Add(new LineBreak()); InfoTextBlock.Inlines.Add(new LineBreak()); - InfoTextBlock.Inlines.Add(new Run(settings.ProgramCopyright) { FontSize = 10 }); + InfoTextBlock.Inlines.Add(new Run(runtimeInfo.ProgramCopyright) { FontSize = 10 }); StatusTextBlock.DataContext = model; ProgressBar.DataContext = model; diff --git a/SafeExamBrowser.UserInterface.Classic/UserInterfaceFactory.cs b/SafeExamBrowser.UserInterface.Classic/UserInterfaceFactory.cs index 0483122d..3990895c 100644 --- a/SafeExamBrowser.UserInterface.Classic/UserInterfaceFactory.cs +++ b/SafeExamBrowser.UserInterface.Classic/UserInterfaceFactory.cs @@ -20,9 +20,9 @@ namespace SafeExamBrowser.UserInterface.Classic { public class UserInterfaceFactory : IUserInterfaceFactory { - public IWindow CreateAboutWindow(ISettings settings, IText text) + public IWindow CreateAboutWindow(IRuntimeInfo runtimeInfo, IText text) { - return new AboutWindow(settings, text); + return new AboutWindow(runtimeInfo, text); } public IApplicationButton CreateApplicationButton(IApplicationInfo info) @@ -75,13 +75,13 @@ namespace SafeExamBrowser.UserInterface.Classic return new PowerSupplyControl(); } - public ISplashScreen CreateSplashScreen(ISettings settings, IText text) + public ISplashScreen CreateSplashScreen(IRuntimeInfo runtimeInfo, IText text) { SplashScreen splashScreen = null; var splashReadyEvent = new AutoResetEvent(false); var splashScreenThread = new Thread(() => { - splashScreen = new SplashScreen(settings, text); + splashScreen = new SplashScreen(runtimeInfo, text); splashScreen.Closed += (o, args) => splashScreen.Dispatcher.InvokeShutdown(); splashScreen.Show(); diff --git a/SafeExamBrowser.UserInterface.Windows10/AboutWindow.xaml.cs b/SafeExamBrowser.UserInterface.Windows10/AboutWindow.xaml.cs index 76b2e6f0..d0d90ac1 100644 --- a/SafeExamBrowser.UserInterface.Windows10/AboutWindow.xaml.cs +++ b/SafeExamBrowser.UserInterface.Windows10/AboutWindow.xaml.cs @@ -8,7 +8,7 @@ using System.Windows; using System.Windows.Documents; -using SafeExamBrowser.Contracts.Configuration.Settings; +using SafeExamBrowser.Contracts.Configuration; using SafeExamBrowser.Contracts.I18n; using SafeExamBrowser.Contracts.UserInterface; @@ -16,7 +16,7 @@ namespace SafeExamBrowser.UserInterface.Windows10 { public partial class AboutWindow : Window, IWindow { - private ISettings settings; + private IRuntimeInfo runtimeInfo; private IText text; private WindowClosingEventHandler closing; @@ -26,9 +26,9 @@ namespace SafeExamBrowser.UserInterface.Windows10 remove { closing -= value; } } - public AboutWindow(ISettings settings, IText text) + public AboutWindow(IRuntimeInfo runtimeInfo, IText text) { - this.settings = settings; + this.runtimeInfo = runtimeInfo; this.text = text; InitializeComponent(); @@ -43,10 +43,10 @@ namespace SafeExamBrowser.UserInterface.Windows10 private void InitializeAboutWindow() { Closing += (o, args) => closing?.Invoke(); - VersionInfo.Inlines.Add(new Run($"{text.Get(TextKey.Version)} {settings.ProgramVersion}") { FontStyle = FontStyles.Italic }); + VersionInfo.Inlines.Add(new Run($"{text.Get(TextKey.Version)} {runtimeInfo.ProgramVersion}") { FontStyle = FontStyles.Italic }); VersionInfo.Inlines.Add(new LineBreak()); VersionInfo.Inlines.Add(new LineBreak()); - VersionInfo.Inlines.Add(new Run(settings.ProgramCopyright) { FontSize = 10 }); + VersionInfo.Inlines.Add(new Run(runtimeInfo.ProgramCopyright) { FontSize = 10 }); } } } diff --git a/SafeExamBrowser.UserInterface.Windows10/SplashScreen.xaml.cs b/SafeExamBrowser.UserInterface.Windows10/SplashScreen.xaml.cs index 1404015d..ff7b4e78 100644 --- a/SafeExamBrowser.UserInterface.Windows10/SplashScreen.xaml.cs +++ b/SafeExamBrowser.UserInterface.Windows10/SplashScreen.xaml.cs @@ -8,7 +8,7 @@ using System.Windows; using System.Windows.Documents; -using SafeExamBrowser.Contracts.Configuration.Settings; +using SafeExamBrowser.Contracts.Configuration; using SafeExamBrowser.Contracts.I18n; using SafeExamBrowser.Contracts.UserInterface; using SafeExamBrowser.UserInterface.Windows10.ViewModels; @@ -18,12 +18,12 @@ namespace SafeExamBrowser.UserInterface.Windows10 public partial class SplashScreen : Window, ISplashScreen { private SplashScreenViewModel model = new SplashScreenViewModel(); - private ISettings settings; + private IRuntimeInfo runtimeInfo; private IText text; - public SplashScreen(ISettings settings, IText text) + public SplashScreen(IRuntimeInfo runtimeInfo, IText text) { - this.settings = settings; + this.runtimeInfo = runtimeInfo; this.text = text; InitializeComponent(); @@ -73,10 +73,10 @@ namespace SafeExamBrowser.UserInterface.Windows10 private void InitializeSplashScreen() { - InfoTextBlock.Inlines.Add(new Run($"Version {settings.ProgramVersion}") { FontStyle = FontStyles.Italic }); + InfoTextBlock.Inlines.Add(new Run($"Version {runtimeInfo.ProgramVersion}") { FontStyle = FontStyles.Italic }); InfoTextBlock.Inlines.Add(new LineBreak()); InfoTextBlock.Inlines.Add(new LineBreak()); - InfoTextBlock.Inlines.Add(new Run(settings.ProgramCopyright) { FontSize = 10 }); + InfoTextBlock.Inlines.Add(new Run(runtimeInfo.ProgramCopyright) { FontSize = 10 }); StatusTextBlock.DataContext = model; ProgressBar.DataContext = model; diff --git a/SafeExamBrowser.UserInterface.Windows10/UserInterfaceFactory.cs b/SafeExamBrowser.UserInterface.Windows10/UserInterfaceFactory.cs index 7d870823..6545e3f9 100644 --- a/SafeExamBrowser.UserInterface.Windows10/UserInterfaceFactory.cs +++ b/SafeExamBrowser.UserInterface.Windows10/UserInterfaceFactory.cs @@ -20,9 +20,9 @@ namespace SafeExamBrowser.UserInterface.Windows10 { public class UserInterfaceFactory : IUserInterfaceFactory { - public IWindow CreateAboutWindow(ISettings settings, IText text) + public IWindow CreateAboutWindow(IRuntimeInfo runtimeInfo, IText text) { - return new AboutWindow(settings, text); + return new AboutWindow(runtimeInfo, text); } public IApplicationButton CreateApplicationButton(IApplicationInfo info) @@ -76,13 +76,13 @@ namespace SafeExamBrowser.UserInterface.Windows10 return new PowerSupplyControl(); } - public ISplashScreen CreateSplashScreen(ISettings settings, IText text) + public ISplashScreen CreateSplashScreen(IRuntimeInfo runtimeInfo, IText text) { SplashScreen splashScreen = null; var splashReadyEvent = new AutoResetEvent(false); var splashScreenThread = new Thread(() => { - splashScreen = new SplashScreen(settings, text); + splashScreen = new SplashScreen(runtimeInfo, text); splashScreen.Closed += (o, args) => splashScreen.Dispatcher.InvokeShutdown(); splashScreen.Show(); diff --git a/SafeExamBrowser/App.cs b/SafeExamBrowser/App.cs index 87495875..c6bf86f8 100644 --- a/SafeExamBrowser/App.cs +++ b/SafeExamBrowser/App.cs @@ -66,9 +66,9 @@ namespace SafeExamBrowser if (success) { // TODO: Probably needs new window to display status of running application... - MainWindow = instances.SplashScreen; - MainWindow.Closing += MainWindow_Closing; - MainWindow.Show(); + //MainWindow = instances.SplashScreen; + //MainWindow.Closing += MainWindow_Closing; + //MainWindow.Show(); } else { diff --git a/SafeExamBrowser/CompositionRoot.cs b/SafeExamBrowser/CompositionRoot.cs index 1a1cfabb..2c23f851 100644 --- a/SafeExamBrowser/CompositionRoot.cs +++ b/SafeExamBrowser/CompositionRoot.cs @@ -7,18 +7,14 @@ */ +using System; using System.Collections.Generic; using System.IO; +using System.Reflection; using SafeExamBrowser.Configuration; -using SafeExamBrowser.Configuration.Settings; using SafeExamBrowser.Contracts.Behaviour; using SafeExamBrowser.Contracts.Configuration; -using SafeExamBrowser.Contracts.Configuration.Settings; -using SafeExamBrowser.Contracts.I18n; using SafeExamBrowser.Contracts.Logging; -using SafeExamBrowser.Contracts.Runtime; -using SafeExamBrowser.Contracts.UserInterface; -using SafeExamBrowser.Contracts.WindowsApi; using SafeExamBrowser.Core.Behaviour; using SafeExamBrowser.Core.Behaviour.Operations; using SafeExamBrowser.Core.I18n; @@ -30,50 +26,60 @@ namespace SafeExamBrowser { internal class CompositionRoot { - private ILogger logger; - private INativeMethods nativeMethods; - private IRuntimeController runtimeController; - private ISettings settings; - private ISystemInfo systemInfo; - private IText text; - private IUserInterfaceFactory uiFactory; - internal IShutdownController ShutdownController { get; private set; } internal IStartupController StartupController { get; private set; } internal Queue StartupOperations { get; private set; } - internal SplashScreen SplashScreen { get; private set; } internal void BuildObjectGraph() { - nativeMethods = new NativeMethods(); - settings = new SettingsRepository().LoadDefaults(); - systemInfo = new SystemInfo(); - uiFactory = new UserInterfaceFactory(); + var logger = new Logger(); + var nativeMethods = new NativeMethods(); + var runtimeInfo = new RuntimeInfo(); + var systemInfo = new SystemInfo(); + var uiFactory = new UserInterfaceFactory(); - InitializeLogger(); + Initialize(runtimeInfo); + Initialize(logger, runtimeInfo); - text = new Text(logger); + var text = new Text(logger); + var runtimeController = new RuntimeController(new ModuleLogger(logger, typeof(RuntimeController))); - runtimeController = new RuntimeController(new ModuleLogger(logger, typeof(RuntimeController))); - ShutdownController = new ShutdownController(logger, settings, text, uiFactory); - StartupController = new StartupController(logger, settings, systemInfo, text, uiFactory); + ShutdownController = new ShutdownController(logger, runtimeInfo, text, uiFactory); + StartupController = new StartupController(logger, runtimeInfo, systemInfo, text, uiFactory); StartupOperations = new Queue(); StartupOperations.Enqueue(new I18nOperation(logger, text)); + // TODO + //StartupOperations.Enqueue(new ConfigurationOperation()); + //StartupOperations.Enqueue(new KioskModeOperation()); StartupOperations.Enqueue(new RuntimeControllerOperation(runtimeController, logger)); } - private void InitializeLogger() + private void Initialize(RuntimeInfo runtimeInfo) { - var logFolder = Path.GetDirectoryName(settings.Logging.RuntimeLogFile); + var appDataFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), nameof(SafeExamBrowser)); + var executable = Assembly.GetEntryAssembly(); + var startTime = DateTime.Now; + var logFolder = Path.Combine(appDataFolder, "Logs"); + var logFilePrefix = startTime.ToString("yyyy-MM-dd\\_HH\\hmm\\mss\\s"); - if (!Directory.Exists(logFolder)) - { - Directory.CreateDirectory(logFolder); - } + runtimeInfo.ApplicationStartTime = startTime; + runtimeInfo.AppDataFolder = appDataFolder; + runtimeInfo.BrowserCachePath = Path.Combine(appDataFolder, "Cache"); + runtimeInfo.BrowserLogFile = Path.Combine(logFolder, $"{logFilePrefix}_Browser.txt"); + runtimeInfo.ClientLogFile = Path.Combine(logFolder, $"{logFilePrefix}_Client.txt"); + runtimeInfo.ProgramCopyright = executable.GetCustomAttribute().Copyright; + runtimeInfo.ProgramTitle = executable.GetCustomAttribute().Title; + runtimeInfo.ProgramVersion = executable.GetCustomAttribute().InformationalVersion; + runtimeInfo.RuntimeLogFile = Path.Combine(logFolder, $"{logFilePrefix}_Runtime.txt"); + } - logger = new Logger(); - logger.Subscribe(new LogFileWriter(new DefaultLogFormatter(), settings.Logging.RuntimeLogFile)); + private void Initialize(ILogger logger, IRuntimeInfo runtimeInfo) + { + var logFileWriter = new LogFileWriter(new DefaultLogFormatter(), runtimeInfo.RuntimeLogFile); + + logFileWriter.Initialize(); + logger.Subscribe(logFileWriter); } } }