diff options
Diffstat (limited to 'src/WixToolset.Data/Intermediate.cs')
| -rw-r--r-- | src/WixToolset.Data/Intermediate.cs | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/src/WixToolset.Data/Intermediate.cs b/src/WixToolset.Data/Intermediate.cs index 7fc7d6c3..d1c38cf0 100644 --- a/src/WixToolset.Data/Intermediate.cs +++ b/src/WixToolset.Data/Intermediate.cs | |||
| @@ -29,9 +29,14 @@ namespace WixToolset.Data | |||
| 29 | this.Sections = new List<IntermediateSection>(); | 29 | this.Sections = new List<IntermediateSection>(); |
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | public Intermediate(string id, IEnumerable<IntermediateSection> sections, IDictionary<string, Localization> localizationsByCulture) | 32 | public Intermediate(string id, IEnumerable<IntermediateSection> sections, IDictionary<string, Localization> localizationsByCulture) : this(id, level: null, sections, localizationsByCulture) |
| 33 | { | ||
| 34 | } | ||
| 35 | |||
| 36 | public Intermediate(string id, string level, IEnumerable<IntermediateSection> sections, IDictionary<string, Localization> localizationsByCulture) | ||
| 33 | { | 37 | { |
| 34 | this.Id = id; | 38 | this.Id = id; |
| 39 | this.Level = level; | ||
| 35 | this.localizationsByCulture = (localizationsByCulture != null) ? new Dictionary<string, Localization>(localizationsByCulture, StringComparer.OrdinalIgnoreCase) : new Dictionary<string, Localization>(StringComparer.OrdinalIgnoreCase); | 40 | this.localizationsByCulture = (localizationsByCulture != null) ? new Dictionary<string, Localization>(localizationsByCulture, StringComparer.OrdinalIgnoreCase) : new Dictionary<string, Localization>(StringComparer.OrdinalIgnoreCase); |
| 36 | this.Sections = (sections != null) ? new List<IntermediateSection>(sections) : new List<IntermediateSection>(); | 41 | this.Sections = (sections != null) ? new List<IntermediateSection>(sections) : new List<IntermediateSection>(); |
| 37 | } | 42 | } |
| @@ -42,6 +47,11 @@ namespace WixToolset.Data | |||
| 42 | public string Id { get; } | 47 | public string Id { get; } |
| 43 | 48 | ||
| 44 | /// <summary> | 49 | /// <summary> |
| 50 | /// Get the id for the intermediate. | ||
| 51 | /// </summary> | ||
| 52 | public string Level { get; private set; } | ||
| 53 | |||
| 54 | /// <summary> | ||
| 45 | /// Get the localizations contained in this intermediate. | 55 | /// Get the localizations contained in this intermediate. |
| 46 | /// </summary> | 56 | /// </summary> |
| 47 | public IEnumerable<Localization> Localizations => this.localizationsByCulture.Values; | 57 | public IEnumerable<Localization> Localizations => this.localizationsByCulture.Values; |
| @@ -182,6 +192,25 @@ namespace WixToolset.Data | |||
| 182 | } | 192 | } |
| 183 | 193 | ||
| 184 | /// <summary> | 194 | /// <summary> |
| 195 | /// Updates the intermediate level to the specified level. | ||
| 196 | /// </summary> | ||
| 197 | /// <param name="level">Intermediate level.</param> | ||
| 198 | public void UpdateLevel(string level) | ||
| 199 | { | ||
| 200 | this.Level = String.IsNullOrEmpty(this.Level) ? level : String.Concat(this.Level, ";", level); | ||
| 201 | } | ||
| 202 | |||
| 203 | /// <summary> | ||
| 204 | /// Returns whether a specifed intermediate level has been set for this intermediate. | ||
| 205 | /// </summary> | ||
| 206 | /// <param name="level">Intermediate level.</param> | ||
| 207 | /// <returns>True if the specifed intermediate level has been set for this intermediate.</returns> | ||
| 208 | public bool HasLevel(string level) | ||
| 209 | { | ||
| 210 | return this.Level?.Contains(level) == true; | ||
| 211 | } | ||
| 212 | |||
| 213 | /// <summary> | ||
| 185 | /// Saves an intermediate to a path on disk. | 214 | /// Saves an intermediate to a path on disk. |
| 186 | /// </summary> | 215 | /// </summary> |
| 187 | /// <param name="path">Path to save intermediate file to disk.</param> | 216 | /// <param name="path">Path to save intermediate file to disk.</param> |
| @@ -277,6 +306,7 @@ namespace WixToolset.Data | |||
| 277 | private static Intermediate FinalizeLoad(JsonObject json, Uri baseUri, ITupleDefinitionCreator creator) | 306 | private static Intermediate FinalizeLoad(JsonObject json, Uri baseUri, ITupleDefinitionCreator creator) |
| 278 | { | 307 | { |
| 279 | var id = json.GetValueOrDefault<string>("id"); | 308 | var id = json.GetValueOrDefault<string>("id"); |
| 309 | var level = json.GetValueOrDefault<string>("level"); | ||
| 280 | 310 | ||
| 281 | var sections = new List<IntermediateSection>(); | 311 | var sections = new List<IntermediateSection>(); |
| 282 | 312 | ||
| @@ -296,7 +326,7 @@ namespace WixToolset.Data | |||
| 296 | localizations.Add(localization.Culture, localization); | 326 | localizations.Add(localization.Culture, localization); |
| 297 | } | 327 | } |
| 298 | 328 | ||
| 299 | return new Intermediate(id, sections, localizations); | 329 | return new Intermediate(id, level, sections, localizations); |
| 300 | } | 330 | } |
| 301 | 331 | ||
| 302 | private void SaveEmbedFiles(WixOutput wixout) | 332 | private void SaveEmbedFiles(WixOutput wixout) |
| @@ -351,6 +381,7 @@ namespace WixToolset.Data | |||
| 351 | var jsonObject = new JsonObject | 381 | var jsonObject = new JsonObject |
| 352 | { | 382 | { |
| 353 | { "id", this.Id }, | 383 | { "id", this.Id }, |
| 384 | { "level", this.Level }, | ||
| 354 | { "version", Intermediate.CurrentVersion.ToString() } | 385 | { "version", Intermediate.CurrentVersion.ToString() } |
| 355 | }; | 386 | }; |
| 356 | 387 | ||
