diff options
| author | Rob Mensching <rob@firegiant.com> | 2021-04-02 14:41:49 -0700 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2021-04-02 14:58:00 -0700 |
| commit | 4449fcc5b8d104817c67135229682c66c3d892ca (patch) | |
| tree | 327f617de2e296ddb4e62c50bf07ec8b5dcf0a3e /src/WixToolset.Core.WindowsInstaller/Bind/ProcessPropertiesCommand.cs | |
| parent | 9cca339473d77c7036035f949239f5231c325968 (diff) | |
| download | wix-4449fcc5b8d104817c67135229682c66c3d892ca.tar.gz wix-4449fcc5b8d104817c67135229682c66c3d892ca.tar.bz2 wix-4449fcc5b8d104817c67135229682c66c3d892ca.zip | |
Enable codepages and languages to be set via .wxl files
Fixes wixtoolset/issues#5801
Diffstat (limited to 'src/WixToolset.Core.WindowsInstaller/Bind/ProcessPropertiesCommand.cs')
| -rw-r--r-- | src/WixToolset.Core.WindowsInstaller/Bind/ProcessPropertiesCommand.cs | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/ProcessPropertiesCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/ProcessPropertiesCommand.cs new file mode 100644 index 00000000..217609be --- /dev/null +++ b/src/WixToolset.Core.WindowsInstaller/Bind/ProcessPropertiesCommand.cs | |||
| @@ -0,0 +1,101 @@ | |||
| 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | ||
| 2 | |||
| 3 | namespace WixToolset.Core.WindowsInstaller.Bind | ||
| 4 | { | ||
| 5 | using System; | ||
| 6 | using System.Collections.Generic; | ||
| 7 | using System.Linq; | ||
| 8 | using WixToolset.Data; | ||
| 9 | using WixToolset.Data.Symbols; | ||
| 10 | using WixToolset.Extensibility.Services; | ||
| 11 | |||
| 12 | internal class ProcessPropertiesCommand | ||
| 13 | { | ||
| 14 | public ProcessPropertiesCommand(IntermediateSection section, WixPackageSymbol packageSymbol, int fallbackLcid, bool populateDelayedVariables, IBackendHelper backendHelper) | ||
| 15 | { | ||
| 16 | this.Section = section; | ||
| 17 | this.PackageSymbol = packageSymbol; | ||
| 18 | this.FallbackLcid = fallbackLcid; | ||
| 19 | this.PopulateDelayedVariables = populateDelayedVariables; | ||
| 20 | this.BackendHelper = backendHelper; | ||
| 21 | } | ||
| 22 | |||
| 23 | private IntermediateSection Section { get; } | ||
| 24 | |||
| 25 | private WixPackageSymbol PackageSymbol { get; } | ||
| 26 | |||
| 27 | private int FallbackLcid { get; } | ||
| 28 | |||
| 29 | private bool PopulateDelayedVariables { get; } | ||
| 30 | |||
| 31 | private IBackendHelper BackendHelper { get; } | ||
| 32 | |||
| 33 | public Dictionary<string, string> DelayedVariablesCache { get; private set; } | ||
| 34 | |||
| 35 | public string ProductLanguage { get; private set; } | ||
| 36 | |||
| 37 | public void Execute() | ||
| 38 | { | ||
| 39 | PropertySymbol languageSymbol = null; | ||
| 40 | var variableCache = this.PopulateDelayedVariables ? new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase) : null; | ||
| 41 | |||
| 42 | if (SectionType.Product == this.Section.Type || variableCache != null) | ||
| 43 | { | ||
| 44 | foreach (var propertySymbol in this.Section.Symbols.OfType<PropertySymbol>()) | ||
| 45 | { | ||
| 46 | // Set the ProductCode if it is to be generated. | ||
| 47 | if ("ProductCode" == propertySymbol.Id.Id && "*".Equals(propertySymbol.Value, StringComparison.Ordinal)) | ||
| 48 | { | ||
| 49 | propertySymbol.Value = this.BackendHelper.CreateGuid(); | ||
| 50 | |||
| 51 | #if TODO_PATCHING // Is this still necessary? | ||
| 52 | // Update the target ProductCode in any instance transforms. | ||
| 53 | foreach (SubStorage subStorage in this.Output.SubStorages) | ||
| 54 | { | ||
| 55 | Output subStorageOutput = subStorage.Data; | ||
| 56 | if (OutputType.Transform != subStorageOutput.Type) | ||
| 57 | { | ||
| 58 | continue; | ||
| 59 | } | ||
| 60 | |||
| 61 | Table instanceSummaryInformationTable = subStorageOutput.Tables["_SummaryInformation"]; | ||
| 62 | foreach (Row row in instanceSummaryInformationTable.Rows) | ||
| 63 | { | ||
| 64 | if ((int)SummaryInformation.Transform.ProductCodes == row.FieldAsInteger(0)) | ||
| 65 | { | ||
| 66 | row[1] = row.FieldAsString(1).Replace("*", propertyRow.Value); | ||
| 67 | break; | ||
| 68 | } | ||
| 69 | } | ||
| 70 | } | ||
| 71 | #endif | ||
| 72 | } | ||
| 73 | else if ("ProductLanguage" == propertySymbol.Id.Id) | ||
| 74 | { | ||
| 75 | languageSymbol = propertySymbol; | ||
| 76 | } | ||
| 77 | |||
| 78 | // Add the property name and value to the variableCache. | ||
| 79 | if (variableCache != null) | ||
| 80 | { | ||
| 81 | variableCache[$"property.{propertySymbol.Id.Id}"] = propertySymbol.Value; | ||
| 82 | } | ||
| 83 | } | ||
| 84 | |||
| 85 | if (this.Section.Type == SectionType.Product && String.IsNullOrEmpty(languageSymbol?.Value)) | ||
| 86 | { | ||
| 87 | if (languageSymbol == null) | ||
| 88 | { | ||
| 89 | languageSymbol = this.Section.AddSymbol(new PropertySymbol(this.PackageSymbol.SourceLineNumbers, new Identifier(AccessModifier.Section, "ProductLanguage"))); | ||
| 90 | } | ||
| 91 | |||
| 92 | this.PackageSymbol.Language = this.FallbackLcid.ToString(); | ||
| 93 | languageSymbol.Value = this.FallbackLcid.ToString(); | ||
| 94 | } | ||
| 95 | } | ||
| 96 | |||
| 97 | this.DelayedVariablesCache = variableCache; | ||
| 98 | this.ProductLanguage = languageSymbol?.Value; | ||
| 99 | } | ||
| 100 | } | ||
| 101 | } | ||
