aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Data/Localization.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/WixToolset.Data/Localization.cs')
-rw-r--r--src/WixToolset.Data/Localization.cs42
1 files changed, 14 insertions, 28 deletions
diff --git a/src/WixToolset.Data/Localization.cs b/src/WixToolset.Data/Localization.cs
index 658ce14a..a5e2ba14 100644
--- a/src/WixToolset.Data/Localization.cs
+++ b/src/WixToolset.Data/Localization.cs
@@ -3,17 +3,10 @@
3namespace WixToolset.Data 3namespace WixToolset.Data
4{ 4{
5 using System; 5 using System;
6 using System.Collections;
7 using System.Collections.Generic; 6 using System.Collections.Generic;
8 using System.Diagnostics; 7 using System.Diagnostics;
9 using System.Diagnostics.CodeAnalysis;
10 using System.Globalization; 8 using System.Globalization;
11 using System.IO;
12 using System.Linq;
13 using System.Reflection;
14 using System.Xml; 9 using System.Xml;
15 using System.Xml.Linq;
16 using System.Xml.Schema;
17 using WixToolset.Data.Msi; 10 using WixToolset.Data.Msi;
18 using WixToolset.Data.Rows; 11 using WixToolset.Data.Rows;
19 12
@@ -24,17 +17,17 @@ namespace WixToolset.Data
24 { 17 {
25 private static string XmlElementName = "localization"; 18 private static string XmlElementName = "localization";
26 19
27 private Dictionary<string, WixVariableRow> variables = new Dictionary<string, WixVariableRow>(); 20 private Dictionary<string, BindVariable> variables = new Dictionary<string, BindVariable>();
28 private Dictionary<string, LocalizedControl> localizedControls = new Dictionary<string, LocalizedControl>(); 21 private Dictionary<string, LocalizedControl> localizedControls = new Dictionary<string, LocalizedControl>();
29 22
30 /// <summary> 23 /// <summary>
31 /// Instantiates a new localization object. 24 /// Instantiates a new localization object.
32 /// </summary> 25 /// </summary>
33 public Localization(int codepage, string culture, IDictionary<string, WixVariableRow> variables, IDictionary<string, LocalizedControl> localizedControls) 26 public Localization(int codepage, string culture, IDictionary<string, BindVariable> variables, IDictionary<string, LocalizedControl> localizedControls)
34 { 27 {
35 this.Codepage = codepage; 28 this.Codepage = codepage;
36 this.Culture = String.IsNullOrEmpty(culture) ? String.Empty : culture.ToLowerInvariant(); 29 this.Culture = String.IsNullOrEmpty(culture) ? String.Empty : culture.ToLowerInvariant();
37 this.variables = new Dictionary<string, WixVariableRow>(variables); 30 this.variables = new Dictionary<string, BindVariable>(variables);
38 this.localizedControls = new Dictionary<string, LocalizedControl>(localizedControls); 31 this.localizedControls = new Dictionary<string, LocalizedControl>(localizedControls);
39 } 32 }
40 33
@@ -54,19 +47,13 @@ namespace WixToolset.Data
54 /// Gets the variables. 47 /// Gets the variables.
55 /// </summary> 48 /// </summary>
56 /// <value>The variables.</value> 49 /// <value>The variables.</value>
57 public ICollection<WixVariableRow> Variables 50 public ICollection<BindVariable> Variables => this.variables.Values;
58 {
59 get { return this.variables.Values; }
60 }
61 51
62 /// <summary> 52 /// <summary>
63 /// Gets the localized controls. 53 /// Gets the localized controls.
64 /// </summary> 54 /// </summary>
65 /// <value>The localized controls.</value> 55 /// <value>The localized controls.</value>
66 public ICollection<KeyValuePair<string, LocalizedControl>> LocalizedControls 56 public ICollection<KeyValuePair<string, LocalizedControl>> LocalizedControls => this.localizedControls;
67 {
68 get { return this.localizedControls; }
69 }
70 57
71 /// <summary> 58 /// <summary>
72 /// Merge the information from another localization object into this one. 59 /// Merge the information from another localization object into this one.
@@ -74,10 +61,9 @@ namespace WixToolset.Data
74 /// <param name="localization">The localization object to be merged into this one.</param> 61 /// <param name="localization">The localization object to be merged into this one.</param>
75 public void Merge(Localization localization) 62 public void Merge(Localization localization)
76 { 63 {
77 foreach (WixVariableRow wixVariableRow in localization.Variables) 64 foreach (BindVariable wixVariableRow in localization.Variables)
78 { 65 {
79 WixVariableRow existingWixVariableRow; 66 if (!this.variables.TryGetValue(wixVariableRow.Id, out BindVariable existingWixVariableRow) || (existingWixVariableRow.Overridable && !wixVariableRow.Overridable))
80 if (!this.variables.TryGetValue(wixVariableRow.Id, out existingWixVariableRow) || (existingWixVariableRow.Overridable && !wixVariableRow.Overridable))
81 { 67 {
82 variables[wixVariableRow.Id] = wixVariableRow; 68 variables[wixVariableRow.Id] = wixVariableRow;
83 } 69 }
@@ -94,7 +80,7 @@ namespace WixToolset.Data
94 /// <param name="reader">XmlReader where the intermediate is persisted.</param> 80 /// <param name="reader">XmlReader where the intermediate is persisted.</param>
95 /// <param name="tableDefinitions">Collection containing TableDefinitions to use when loading the localization file.</param> 81 /// <param name="tableDefinitions">Collection containing TableDefinitions to use when loading the localization file.</param>
96 /// <returns>Returns the loaded localization.</returns> 82 /// <returns>Returns the loaded localization.</returns>
97 internal static Localization Read(XmlReader reader, TableDefinitionCollection tableDefinitions) 83 internal static Localization Read(XmlReader reader)
98 { 84 {
99 Debug.Assert("localization" == reader.LocalName); 85 Debug.Assert("localization" == reader.LocalName);
100 86
@@ -115,8 +101,7 @@ namespace WixToolset.Data
115 } 101 }
116 } 102 }
117 103
118 TableDefinition wixVariableTable = tableDefinitions["WixVariable"]; 104 Dictionary<string, BindVariable> variables = new Dictionary<string, BindVariable>();
119 Dictionary<string, WixVariableRow> variables = new Dictionary<string, WixVariableRow>();
120 Dictionary<string, LocalizedControl> localizedControls = new Dictionary<string, LocalizedControl>(); 105 Dictionary<string, LocalizedControl> localizedControls = new Dictionary<string, LocalizedControl>();
121 106
122 if (!empty) 107 if (!empty)
@@ -131,7 +116,7 @@ namespace WixToolset.Data
131 switch (reader.LocalName) 116 switch (reader.LocalName)
132 { 117 {
133 case "string": 118 case "string":
134 WixVariableRow row = Localization.ReadString(reader, wixVariableTable); 119 BindVariable row = Localization.ReadString(reader);
135 variables.Add(row.Id, row); 120 variables.Add(row.Id, row);
136 break; 121 break;
137 122
@@ -177,7 +162,7 @@ namespace WixToolset.Data
177 writer.WriteAttributeString("culture", this.Culture); 162 writer.WriteAttributeString("culture", this.Culture);
178 } 163 }
179 164
180 foreach (WixVariableRow wixVariableRow in this.variables.Values) 165 foreach (BindVariable wixVariableRow in this.variables.Values)
181 { 166 {
182 writer.WriteStartElement("string", Library.XmlNamespaceUri); 167 writer.WriteStartElement("string", Library.XmlNamespaceUri);
183 168
@@ -265,7 +250,7 @@ namespace WixToolset.Data
265 /// <param name="reader">XmlReader where the intermediate is persisted.</param> 250 /// <param name="reader">XmlReader where the intermediate is persisted.</param>
266 /// <param name="tableDefinitions">Collection containing TableDefinitions to use when loading the localization file.</param> 251 /// <param name="tableDefinitions">Collection containing TableDefinitions to use when loading the localization file.</param>
267 /// <returns>Returns the loaded localization.</returns> 252 /// <returns>Returns the loaded localization.</returns>
268 private static WixVariableRow ReadString(XmlReader reader, TableDefinition wixVariableTable) 253 private static BindVariable ReadString(XmlReader reader)
269 { 254 {
270 Debug.Assert("string" == reader.LocalName); 255 Debug.Assert("string" == reader.LocalName);
271 256
@@ -302,7 +287,8 @@ namespace WixToolset.Data
302 } 287 }
303 } 288 }
304 289
305 WixVariableRow wixVariableRow = new WixVariableRow(SourceLineNumber.CreateFromUri(reader.BaseURI), wixVariableTable); 290 BindVariable wixVariableRow = new BindVariable();
291 wixVariableRow.SourceLineNumbers = SourceLineNumber.CreateFromUri(reader.BaseURI);
306 wixVariableRow.Id = id; 292 wixVariableRow.Id = id;
307 wixVariableRow.Overridable = overridable; 293 wixVariableRow.Overridable = overridable;
308 wixVariableRow.Value = value; 294 wixVariableRow.Value = value;