diff options
author | Rob Mensching <rob@firegiant.com> | 2017-12-07 14:19:05 -0800 |
---|---|---|
committer | Rob Mensching <rob@firegiant.com> | 2017-12-07 14:19:05 -0800 |
commit | 49f1209035aac1fcfad5dbbe25f7b2306d3be86c (patch) | |
tree | 6ce5921493eb751b6d89c3faf0ebdf64110cbb65 /src/WixToolset.Core/ExtensibilityServices/WindowsInstallerBackendHelper.cs | |
parent | b1e662bd480241ea914f0f3d6bd174d9ffd03f5f (diff) | |
download | wix-49f1209035aac1fcfad5dbbe25f7b2306d3be86c.tar.gz wix-49f1209035aac1fcfad5dbbe25f7b2306d3be86c.tar.bz2 wix-49f1209035aac1fcfad5dbbe25f7b2306d3be86c.zip |
Support MSI backends creating custom tables and remove WixToolset.Data.WindowsInstaller
Diffstat (limited to 'src/WixToolset.Core/ExtensibilityServices/WindowsInstallerBackendHelper.cs')
-rw-r--r-- | src/WixToolset.Core/ExtensibilityServices/WindowsInstallerBackendHelper.cs | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/WixToolset.Core/ExtensibilityServices/WindowsInstallerBackendHelper.cs b/src/WixToolset.Core/ExtensibilityServices/WindowsInstallerBackendHelper.cs new file mode 100644 index 00000000..3b41fdf1 --- /dev/null +++ b/src/WixToolset.Core/ExtensibilityServices/WindowsInstallerBackendHelper.cs | |||
@@ -0,0 +1,53 @@ | |||
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.ExtensibilityServices | ||
4 | { | ||
5 | using System; | ||
6 | using System.Linq; | ||
7 | using WixToolset.Data; | ||
8 | using WixToolset.Data.WindowsInstaller; | ||
9 | using WixToolset.Extensibility.Services; | ||
10 | |||
11 | internal class WindowsInstallerBackendHelper : IWindowsInstallerBackendHelper | ||
12 | { | ||
13 | public WindowsInstallerBackendHelper(IServiceProvider serviceProvider) | ||
14 | { | ||
15 | this.ServiceProvider = serviceProvider; | ||
16 | } | ||
17 | |||
18 | private IServiceProvider ServiceProvider { get; } | ||
19 | |||
20 | public bool TryAddTupleToOutputMatchingTableDefinitions(IntermediateTuple tuple, Output output, TableDefinition[] tableDefinitions) | ||
21 | { | ||
22 | var tableDefinition = tableDefinitions.FirstOrDefault(t => t.Name == tuple.Definition.Name); | ||
23 | |||
24 | if (tableDefinition == null) | ||
25 | { | ||
26 | return false; | ||
27 | } | ||
28 | |||
29 | var table = output.EnsureTable(tableDefinition); | ||
30 | var row = table.CreateRow(tuple.SourceLineNumbers); | ||
31 | for (var i = 0; i < tuple.Fields.Length; ++i) | ||
32 | { | ||
33 | if (i < tableDefinition.Columns.Count) | ||
34 | { | ||
35 | var column = tableDefinition.Columns[i]; | ||
36 | |||
37 | switch (column.Type) | ||
38 | { | ||
39 | case ColumnType.Number: | ||
40 | row[i] = tuple.AsNumber(i); | ||
41 | break; | ||
42 | |||
43 | default: | ||
44 | row[i] = tuple.AsString(i); | ||
45 | break; | ||
46 | } | ||
47 | } | ||
48 | } | ||
49 | |||
50 | return true; | ||
51 | } | ||
52 | } | ||
53 | } | ||