diff options
| author | Rob Mensching <rob@firegiant.com> | 2020-06-23 16:45:26 -0700 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2020-06-23 16:52:05 -0700 |
| commit | 0185c2ea6e638dc7e1c5224739717ba2152bb510 (patch) | |
| tree | 4b5241794849f4b07b9d2eb73a2a761a230a1242 /src/WixToolset.Core.WindowsInstaller/ExtensibilityServices/WindowsInstallerBackendHelper.cs | |
| parent | 51441387b09aa6b8c00fbc0d8841118b7fee63d6 (diff) | |
| download | wix-0185c2ea6e638dc7e1c5224739717ba2152bb510.tar.gz wix-0185c2ea6e638dc7e1c5224739717ba2152bb510.tar.bz2 wix-0185c2ea6e638dc7e1c5224739717ba2152bb510.zip | |
Move Windows Installer specific backend services to WindowsInstaller
Diffstat (limited to 'src/WixToolset.Core.WindowsInstaller/ExtensibilityServices/WindowsInstallerBackendHelper.cs')
| -rw-r--r-- | src/WixToolset.Core.WindowsInstaller/ExtensibilityServices/WindowsInstallerBackendHelper.cs | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/WixToolset.Core.WindowsInstaller/ExtensibilityServices/WindowsInstallerBackendHelper.cs b/src/WixToolset.Core.WindowsInstaller/ExtensibilityServices/WindowsInstallerBackendHelper.cs new file mode 100644 index 00000000..a1df335c --- /dev/null +++ b/src/WixToolset.Core.WindowsInstaller/ExtensibilityServices/WindowsInstallerBackendHelper.cs | |||
| @@ -0,0 +1,61 @@ | |||
| 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.ExtensibilityServices | ||
| 4 | { | ||
| 5 | using System.Linq; | ||
| 6 | using WixToolset.Data; | ||
| 7 | using WixToolset.Data.WindowsInstaller; | ||
| 8 | using WixToolset.Extensibility.Services; | ||
| 9 | |||
| 10 | internal class WindowsInstallerBackendHelper : IWindowsInstallerBackendHelper | ||
| 11 | { | ||
| 12 | public Row CreateRow(IntermediateSection section, IntermediateTuple tuple, WindowsInstallerData output, TableDefinition tableDefinition) | ||
| 13 | { | ||
| 14 | var table = output.EnsureTable(tableDefinition); | ||
| 15 | |||
| 16 | var row = table.CreateRow(tuple.SourceLineNumbers); | ||
| 17 | row.SectionId = section.Id; | ||
| 18 | |||
| 19 | return row; | ||
| 20 | } | ||
| 21 | |||
| 22 | public bool TryAddTupleToOutputMatchingTableDefinitions(IntermediateSection section, IntermediateTuple tuple, WindowsInstallerData output, TableDefinitionCollection tableDefinitions) | ||
| 23 | { | ||
| 24 | var tableDefinition = tableDefinitions.FirstOrDefault(t => t.TupleDefinition?.Name == tuple.Definition.Name); | ||
| 25 | if (tableDefinition == null) | ||
| 26 | { | ||
| 27 | return false; | ||
| 28 | } | ||
| 29 | |||
| 30 | var row = this.CreateRow(section, tuple, output, tableDefinition); | ||
| 31 | var rowOffset = 0; | ||
| 32 | |||
| 33 | if (tableDefinition.TupleIdIsPrimaryKey) | ||
| 34 | { | ||
| 35 | row[0] = tuple.Id.Id; | ||
| 36 | rowOffset = 1; | ||
| 37 | } | ||
| 38 | |||
| 39 | for (var i = 0; i < tuple.Fields.Length; ++i) | ||
| 40 | { | ||
| 41 | if (i < tableDefinition.Columns.Length) | ||
| 42 | { | ||
| 43 | var column = tableDefinition.Columns[i + rowOffset]; | ||
| 44 | |||
| 45 | switch (column.Type) | ||
| 46 | { | ||
| 47 | case ColumnType.Number: | ||
| 48 | row[i + rowOffset] = column.Nullable ? tuple.AsNullableNumber(i) : tuple.AsNumber(i); | ||
| 49 | break; | ||
| 50 | |||
| 51 | default: | ||
| 52 | row[i + rowOffset] = tuple.AsString(i); | ||
| 53 | break; | ||
| 54 | } | ||
| 55 | } | ||
| 56 | } | ||
| 57 | |||
| 58 | return true; | ||
| 59 | } | ||
| 60 | } | ||
| 61 | } | ||
