/* * 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 System.Globalization; using SafeExamBrowser.Contracts.Core.OperationModel; using SafeExamBrowser.Contracts.Core.OperationModel.Events; using SafeExamBrowser.Contracts.I18n; using SafeExamBrowser.Contracts.Logging; namespace SafeExamBrowser.Core.Operations { /// /// An operation to handle the initialization of an module with text data from the default directory. /// public class I18nOperation : IOperation { private ILogger logger; private IText text; private ITextResource textResource; public event ActionRequiredEventHandler ActionRequired { add { } remove { } } public event StatusChangedEventHandler StatusChanged { add { } remove { } } public I18nOperation(ILogger logger, IText text, ITextResource textResource) { this.logger = logger; this.text = text; this.textResource = textResource; } public OperationResult Perform() { logger.Info($"Loading default text data (the currently active culture is '{CultureInfo.CurrentCulture.Name}')..."); text.Initialize(textResource); return OperationResult.Success; } public OperationResult Repeat() { throw new InvalidOperationException($"The '{nameof(I18nOperation)}' is not meant to be repeated!"); } public void Revert() { // Nothing to do here... } } }