diff options
Diffstat (limited to 'src/WixToolset.Core.WindowsInstaller/Bind/BindSummaryInfoCommand.cs')
-rw-r--r-- | src/WixToolset.Core.WindowsInstaller/Bind/BindSummaryInfoCommand.cs | 178 |
1 files changed, 92 insertions, 86 deletions
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/BindSummaryInfoCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/BindSummaryInfoCommand.cs index 5471792d..c9286a38 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/BindSummaryInfoCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/BindSummaryInfoCommand.cs | |||
@@ -1,20 +1,24 @@ | |||
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. | 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 | 2 | ||
3 | namespace WixToolset.Core.WindowsInstaller.Databases | 3 | namespace WixToolset.Core.WindowsInstaller.Bind |
4 | { | 4 | { |
5 | using System; | 5 | using System; |
6 | using System.Globalization; | 6 | using System.Globalization; |
7 | using System.Linq; | ||
7 | using WixToolset.Data; | 8 | using WixToolset.Data; |
9 | using WixToolset.Data.Tuples; | ||
8 | 10 | ||
9 | /// <summary> | 11 | /// <summary> |
10 | /// Binds the summary information table of a database. | 12 | /// Binds the summary information table of a database. |
11 | /// </summary> | 13 | /// </summary> |
12 | internal class BindSummaryInfoCommand | 14 | internal class BindSummaryInfoCommand |
13 | { | 15 | { |
14 | /// <summary> | 16 | public BindSummaryInfoCommand(IntermediateSection section) |
15 | /// The output to bind. | 17 | { |
16 | /// </summary> | 18 | this.Section = section; |
17 | public Output Output { private get; set; } | 19 | } |
20 | |||
21 | private IntermediateSection Section { get; } | ||
18 | 22 | ||
19 | /// <summary> | 23 | /// <summary> |
20 | /// Returns a flag indicating if files are compressed by default. | 24 | /// Returns a flag indicating if files are compressed by default. |
@@ -40,95 +44,97 @@ namespace WixToolset.Core.WindowsInstaller.Databases | |||
40 | this.InstallerVersion = 0; | 44 | this.InstallerVersion = 0; |
41 | this.ModularizationGuid = null; | 45 | this.ModularizationGuid = null; |
42 | 46 | ||
43 | Table summaryInformationTable = this.Output.Tables["_SummaryInformation"]; | 47 | bool foundCreateDataTime = false; |
48 | bool foundLastSaveDataTime = false; | ||
49 | bool foundCreatingApplication = false; | ||
50 | string now = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss", CultureInfo.InvariantCulture); | ||
44 | 51 | ||
45 | if (null != summaryInformationTable) | 52 | foreach (var summaryInformationRow in this.Section.Tuples.OfType<_SummaryInformationTuple>()) |
46 | { | 53 | { |
47 | bool foundCreateDataTime = false; | 54 | switch (summaryInformationRow.PropertyId) |
48 | bool foundLastSaveDataTime = false; | ||
49 | bool foundCreatingApplication = false; | ||
50 | string now = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss", CultureInfo.InvariantCulture); | ||
51 | |||
52 | foreach (Row summaryInformationRow in summaryInformationTable.Rows) | ||
53 | { | 55 | { |
54 | switch (summaryInformationRow.FieldAsInteger(0)) | 56 | case 1: // PID_CODEPAGE |
55 | { | ||
56 | case 1: // PID_CODEPAGE | ||
57 | // make sure the code page is an int and not a web name or null | 57 | // make sure the code page is an int and not a web name or null |
58 | string codepage = summaryInformationRow.FieldAsString(1); | 58 | var codepage = summaryInformationRow.Value; |
59 | |||
60 | if (null == codepage) | ||
61 | { | ||
62 | codepage = "0"; | ||
63 | } | ||
64 | else | ||
65 | { | ||
66 | summaryInformationRow[1] = Common.GetValidCodePage(codepage, false, false, summaryInformationRow.SourceLineNumbers).ToString(CultureInfo.InvariantCulture); | ||
67 | } | ||
68 | break; | ||
69 | case 9: // PID_REVNUMBER | ||
70 | string packageCode = (string)summaryInformationRow[1]; | ||
71 | |||
72 | if (OutputType.Module == this.Output.Type) | ||
73 | { | ||
74 | this.ModularizationGuid = packageCode.Substring(1, 36).Replace('-', '_'); | ||
75 | } | ||
76 | else if ("*" == packageCode) | ||
77 | { | ||
78 | // set the revision number (package/patch code) if it should be automatically generated | ||
79 | summaryInformationRow[1] = Common.GenerateGuid(); | ||
80 | } | ||
81 | break; | ||
82 | case 12: // PID_CREATE_DTM | ||
83 | foundCreateDataTime = true; | ||
84 | break; | ||
85 | case 13: // PID_LASTSAVE_DTM | ||
86 | foundLastSaveDataTime = true; | ||
87 | break; | ||
88 | case 14: | ||
89 | this.InstallerVersion = summaryInformationRow.FieldAsInteger(1); | ||
90 | break; | ||
91 | case 15: // PID_WORDCOUNT | ||
92 | if (OutputType.Patch == this.Output.Type) | ||
93 | { | ||
94 | this.LongNames = true; | ||
95 | this.Compressed = true; | ||
96 | } | ||
97 | else | ||
98 | { | ||
99 | this.LongNames = (0 == (summaryInformationRow.FieldAsInteger(1) & 1)); | ||
100 | this.Compressed = (2 == (summaryInformationRow.FieldAsInteger(1) & 2)); | ||
101 | } | ||
102 | break; | ||
103 | case 18: // PID_APPNAME | ||
104 | foundCreatingApplication = true; | ||
105 | break; | ||
106 | } | ||
107 | } | ||
108 | 59 | ||
109 | // add a summary information row for the create time/date property if its not already set | 60 | if (String.IsNullOrEmpty(codepage)) |
110 | if (!foundCreateDataTime) | 61 | { |
111 | { | 62 | codepage = "0"; |
112 | Row createTimeDateRow = summaryInformationTable.CreateRow(null); | 63 | } |
113 | createTimeDateRow[0] = 12; | 64 | else |
114 | createTimeDateRow[1] = now; | 65 | { |
115 | } | 66 | summaryInformationRow.Value = Common.GetValidCodePage(codepage, false, false, summaryInformationRow.SourceLineNumbers).ToString(CultureInfo.InvariantCulture); |
67 | } | ||
68 | break; | ||
69 | case 9: // PID_REVNUMBER | ||
70 | var packageCode = summaryInformationRow.Value; | ||
116 | 71 | ||
117 | // add a summary information row for the last save time/date property if its not already set | 72 | if (SectionType.Module == this.Section.Type) |
118 | if (!foundLastSaveDataTime) | 73 | { |
119 | { | 74 | this.ModularizationGuid = packageCode.Substring(1, 36).Replace('-', '_'); |
120 | Row lastSaveTimeDateRow = summaryInformationTable.CreateRow(null); | 75 | } |
121 | lastSaveTimeDateRow[0] = 13; | 76 | else if ("*" == packageCode) |
122 | lastSaveTimeDateRow[1] = now; | 77 | { |
78 | // set the revision number (package/patch code) if it should be automatically generated | ||
79 | summaryInformationRow.Value = Common.GenerateGuid(); | ||
80 | } | ||
81 | break; | ||
82 | case 12: // PID_CREATE_DTM | ||
83 | foundCreateDataTime = true; | ||
84 | break; | ||
85 | case 13: // PID_LASTSAVE_DTM | ||
86 | foundLastSaveDataTime = true; | ||
87 | break; | ||
88 | case 14: | ||
89 | this.InstallerVersion = summaryInformationRow[_SummaryInformationTupleFields.Value].AsNumber(); | ||
90 | break; | ||
91 | case 15: // PID_WORDCOUNT | ||
92 | if (SectionType.Patch == this.Section.Type) | ||
93 | { | ||
94 | this.LongNames = true; | ||
95 | this.Compressed = true; | ||
96 | } | ||
97 | else | ||
98 | { | ||
99 | var attributes = summaryInformationRow[_SummaryInformationTupleFields.Value].AsNumber(); | ||
100 | this.LongNames = (0 == (attributes & 1)); | ||
101 | this.Compressed = (2 == (attributes & 2)); | ||
102 | } | ||
103 | break; | ||
104 | case 18: // PID_APPNAME | ||
105 | foundCreatingApplication = true; | ||
106 | break; | ||
123 | } | 107 | } |
108 | } | ||
124 | 109 | ||
125 | // add a summary information row for the creating application property if its not already set | 110 | // add a summary information row for the create time/date property if its not already set |
126 | if (!foundCreatingApplication) | 111 | if (!foundCreateDataTime) |
127 | { | 112 | { |
128 | Row creatingApplicationRow = summaryInformationTable.CreateRow(null); | 113 | var createTimeDateRow = new _SummaryInformationTuple(null, new Identifier(12, AccessModifier.Private)); |
129 | creatingApplicationRow[0] = 18; | 114 | createTimeDateRow.PropertyId = 12; |
130 | creatingApplicationRow[1] = String.Format(CultureInfo.InvariantCulture, AppCommon.GetCreatingApplicationString()); | 115 | createTimeDateRow.Value = now; |
131 | } | 116 | |
117 | this.Section.Tuples.Add(createTimeDateRow); | ||
118 | } | ||
119 | |||
120 | // add a summary information row for the last save time/date property if its not already set | ||
121 | if (!foundLastSaveDataTime) | ||
122 | { | ||
123 | var lastSaveTimeDateRow = new _SummaryInformationTuple(null, new Identifier(13, AccessModifier.Private)); | ||
124 | lastSaveTimeDateRow.PropertyId = 13; | ||
125 | lastSaveTimeDateRow.Value = now; | ||
126 | |||
127 | this.Section.Tuples.Add(lastSaveTimeDateRow); | ||
128 | } | ||
129 | |||
130 | // add a summary information row for the creating application property if its not already set | ||
131 | if (!foundCreatingApplication) | ||
132 | { | ||
133 | var creatingApplicationRow = new _SummaryInformationTuple(null, new Identifier(18, AccessModifier.Private)); | ||
134 | creatingApplicationRow.PropertyId = 18; | ||
135 | creatingApplicationRow.Value = String.Format(CultureInfo.InvariantCulture, AppCommon.GetCreatingApplicationString()); | ||
136 | |||
137 | this.Section.Tuples.Add(creatingApplicationRow); | ||
132 | } | 138 | } |
133 | } | 139 | } |
134 | } | 140 | } |