seb-win-refactoring/SafeExamBrowser.Core/Operations/I18nOperation.cs

50 lines
1.5 KiB
C#

/*
* Copyright (c) 2019 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.Globalization;
using SafeExamBrowser.Contracts.Core.OperationModel;
using SafeExamBrowser.Contracts.Core.OperationModel.Events;
using SafeExamBrowser.Contracts.I18n;
using SafeExamBrowser.Contracts.Logging;
namespace SafeExamBrowser.Core.Operations
{
/// <summary>
/// An operation to handle the initialization of an <see cref="IText"/> module with text data from the default directory.
/// </summary>
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 Revert()
{
return OperationResult.Success;
}
}
}