From dbde9e7104b907bbbaea17e21247d8cafc8b3a4c Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Sat, 14 Oct 2017 16:12:07 -0700 Subject: Massive refactoring to introduce the concept of IBackend --- src/WixToolset.Core/Localizer.cs | 51 ++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 26 deletions(-) (limited to 'src/WixToolset.Core/Localizer.cs') diff --git a/src/WixToolset.Core/Localizer.cs b/src/WixToolset.Core/Localizer.cs index 63ead24a..72d0955b 100644 --- a/src/WixToolset.Core/Localizer.cs +++ b/src/WixToolset.Core/Localizer.cs @@ -8,11 +8,12 @@ namespace WixToolset using WixToolset.Data; using WixToolset.Data.Rows; using WixToolset.Core.Native; + using WixToolset.Extensibility; /// /// Parses localization files and localizes database values. /// - public sealed class Localizer + public sealed class Localizer : ILocalizer { public static readonly XNamespace WxlNamespace = "http://wixtoolset.org/schemas/v4/wxl"; private static string XmlElementName = "WixLocalization"; @@ -55,7 +56,28 @@ namespace WixToolset /// Gets the codepage. /// /// The codepage. - public int Codepage { get; private set; } + public int Codepage { get; } + + /// + /// Get a localized data value. + /// + /// The name of the localization variable. + /// The localized data value or null if it wasn't found. + public string GetLocalizedValue(string id) + { + return this.variables.TryGetValue(id, out var wixVariableRow) ? wixVariableRow.Value : null; + } + + /// + /// Get a localized control. + /// + /// The optional id of the control's dialog. + /// The id of the control. + /// The localized control or null if it wasn't found. + public LocalizedControl GetLocalizedControl(string dialog, string control) + { + return this.localizedControls.TryGetValue(LocalizedControl.GetKey(dialog, control), out var localizedControl) ? localizedControl : null; + } /// /// Loads a localization file from a path on disk. @@ -96,28 +118,6 @@ namespace WixToolset return localization; } - /// - /// Get a localized data value. - /// - /// The name of the localization variable. - /// The localized data value or null if it wasn't found. - public string GetLocalizedValue(string id) - { - return this.variables.TryGetValue(id, out var wixVariableRow) ? wixVariableRow.Value : null; - } - - /// - /// Get a localized control. - /// - /// The optional id of the control's dialog. - /// The id of the control. - /// The localized control or null if it wasn't found. - public LocalizedControl GetLocalizedControl(string dialog, string control) - { - LocalizedControl localizedControl; - return this.localizedControls.TryGetValue(LocalizedControl.GetKey(dialog, control), out localizedControl) ? localizedControl : null; - } - /// /// Adds a WixVariableRow to a dictionary while performing the expected override checks. /// @@ -125,8 +125,7 @@ namespace WixToolset /// Row to add to the variables dictionary. private static void AddWixVariable(IDictionary variables, WixVariableRow wixVariableRow) { - WixVariableRow existingWixVariableRow; - if (!variables.TryGetValue(wixVariableRow.Id, out existingWixVariableRow) || (existingWixVariableRow.Overridable && !wixVariableRow.Overridable)) + if (!variables.TryGetValue(wixVariableRow.Id, out var existingWixVariableRow) || (existingWixVariableRow.Overridable && !wixVariableRow.Overridable)) { variables[wixVariableRow.Id] = wixVariableRow; } -- cgit v1.2.3-55-g6feb