diff options
| author | Rob Mensching <rob@firegiant.com> | 2017-10-14 16:12:07 -0700 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2017-10-14 16:12:07 -0700 |
| commit | dbde9e7104b907bbbaea17e21247d8cafc8b3a4c (patch) | |
| tree | 0f5fbbb6fe12c6b2e5e622a0e18ce4c5b4eb2b96 /src/WixToolset.Core.WindowsInstaller/Bind/BindSummaryInfoCommand.cs | |
| parent | fbf986eb97f68396797a89fc7d40dec07b775440 (diff) | |
| download | wix-dbde9e7104b907bbbaea17e21247d8cafc8b3a4c.tar.gz wix-dbde9e7104b907bbbaea17e21247d8cafc8b3a4c.tar.bz2 wix-dbde9e7104b907bbbaea17e21247d8cafc8b3a4c.zip | |
Massive refactoring to introduce the concept of IBackend
Diffstat (limited to 'src/WixToolset.Core.WindowsInstaller/Bind/BindSummaryInfoCommand.cs')
| -rw-r--r-- | src/WixToolset.Core.WindowsInstaller/Bind/BindSummaryInfoCommand.cs | 135 |
1 files changed, 135 insertions, 0 deletions
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/BindSummaryInfoCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/BindSummaryInfoCommand.cs new file mode 100644 index 00000000..5471792d --- /dev/null +++ b/src/WixToolset.Core.WindowsInstaller/Bind/BindSummaryInfoCommand.cs | |||
| @@ -0,0 +1,135 @@ | |||
| 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.Databases | ||
| 4 | { | ||
| 5 | using System; | ||
| 6 | using System.Globalization; | ||
| 7 | using WixToolset.Data; | ||
| 8 | |||
| 9 | /// <summary> | ||
| 10 | /// Binds the summary information table of a database. | ||
| 11 | /// </summary> | ||
| 12 | internal class BindSummaryInfoCommand | ||
| 13 | { | ||
| 14 | /// <summary> | ||
| 15 | /// The output to bind. | ||
| 16 | /// </summary> | ||
| 17 | public Output Output { private get; set; } | ||
| 18 | |||
| 19 | /// <summary> | ||
| 20 | /// Returns a flag indicating if files are compressed by default. | ||
| 21 | /// </summary> | ||
| 22 | public bool Compressed { get; private set; } | ||
| 23 | |||
| 24 | /// <summary> | ||
| 25 | /// Returns a flag indicating if uncompressed files use long filenames. | ||
| 26 | /// </summary> | ||
| 27 | public bool LongNames { get; private set; } | ||
| 28 | |||
| 29 | public int InstallerVersion { get; private set; } | ||
| 30 | |||
| 31 | /// <summary> | ||
| 32 | /// Modularization guid, or null if the output is not a module. | ||
| 33 | /// </summary> | ||
| 34 | public string ModularizationGuid { get; private set; } | ||
| 35 | |||
| 36 | public void Execute() | ||
| 37 | { | ||
| 38 | this.Compressed = false; | ||
| 39 | this.LongNames = false; | ||
| 40 | this.InstallerVersion = 0; | ||
| 41 | this.ModularizationGuid = null; | ||
| 42 | |||
| 43 | Table summaryInformationTable = this.Output.Tables["_SummaryInformation"]; | ||
| 44 | |||
| 45 | if (null != summaryInformationTable) | ||
| 46 | { | ||
| 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); | ||
| 51 | |||
| 52 | foreach (Row summaryInformationRow in summaryInformationTable.Rows) | ||
| 53 | { | ||
| 54 | switch (summaryInformationRow.FieldAsInteger(0)) | ||
| 55 | { | ||
| 56 | case 1: // PID_CODEPAGE | ||
| 57 | // make sure the code page is an int and not a web name or null | ||
| 58 | string codepage = summaryInformationRow.FieldAsString(1); | ||
| 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 | |||
| 109 | // add a summary information row for the create time/date property if its not already set | ||
| 110 | if (!foundCreateDataTime) | ||
| 111 | { | ||
| 112 | Row createTimeDateRow = summaryInformationTable.CreateRow(null); | ||
| 113 | createTimeDateRow[0] = 12; | ||
| 114 | createTimeDateRow[1] = now; | ||
| 115 | } | ||
| 116 | |||
| 117 | // add a summary information row for the last save time/date property if its not already set | ||
| 118 | if (!foundLastSaveDataTime) | ||
| 119 | { | ||
| 120 | Row lastSaveTimeDateRow = summaryInformationTable.CreateRow(null); | ||
| 121 | lastSaveTimeDateRow[0] = 13; | ||
| 122 | lastSaveTimeDateRow[1] = now; | ||
| 123 | } | ||
| 124 | |||
| 125 | // add a summary information row for the creating application property if its not already set | ||
| 126 | if (!foundCreatingApplication) | ||
| 127 | { | ||
| 128 | Row creatingApplicationRow = summaryInformationTable.CreateRow(null); | ||
| 129 | creatingApplicationRow[0] = 18; | ||
| 130 | creatingApplicationRow[1] = String.Format(CultureInfo.InvariantCulture, AppCommon.GetCreatingApplicationString()); | ||
| 131 | } | ||
| 132 | } | ||
| 133 | } | ||
| 134 | } | ||
| 135 | } | ||
