blob: 0bf3d3f9d7bb13920b08c7643cd42e86986d0861 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
// 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.
namespace WixToolset.Dtf.WindowsInstaller.Package
{
using System;
using System.IO;
using System.Globalization;
/// <summary>
/// Contains properties of a transform package (.MST).
/// </summary>
public class TransformInfo
{
/// <summary>
/// Reads transform information from a transform package.
/// </summary>
/// <param name="mstFile">Path to a transform package (.MST file).</param>
public TransformInfo(string mstFile)
{
this.name = Path.GetFileName(mstFile);
using (SummaryInfo transformSummInfo = new SummaryInfo(mstFile, false))
{
this.DecodeSummaryInfo(transformSummInfo);
}
}
/// <summary>
/// Reads transform information from the summary information of a transform package.
/// </summary>
/// <param name="name">Filename of the transform (optional).</param>
/// <param name="transformSummaryInfo">Handle to the summary information of a transform package (.MST file).</param>
public TransformInfo(string name, SummaryInfo transformSummaryInfo)
{
this.name = name;
this.DecodeSummaryInfo(transformSummaryInfo);
}
private void DecodeSummaryInfo(SummaryInfo transformSummaryInfo)
{
try
{
string[] rev = transformSummaryInfo.RevisionNumber.Split(new char[] { ';' }, 3);
this.targetProductCode = rev[0].Substring(0, 38);
this.targetProductVersion = rev[0].Substring(38);
this.upgradeProductCode = rev[1].Substring(0, 38);
this.upgradeProductVersion = rev[1].Substring(38);
this.upgradeCode = rev[2];
string[] templ = transformSummaryInfo.Template.Split(new Char[] { ';' }, 2);
this.targetPlatform = templ[0];
this.targetLanguage = 0;
if (templ.Length >= 2 && templ[1].Length > 0)
{
this.targetLanguage = Int32.Parse(templ[1], CultureInfo.InvariantCulture.NumberFormat);
}
this.validateFlags = (TransformValidations) transformSummaryInfo.CharacterCount;
}
catch (Exception ex)
{
throw new InstallerException("Invalid transform summary info", ex);
}
}
/// <summary>
/// Gets the filename of the transform.
/// </summary>
public string Name
{
get { return this.name; }
}
private string name;
/// <summary>
/// Gets the target product code of the transform.
/// </summary>
public string TargetProductCode
{
get { return this.targetProductCode; }
}
private string targetProductCode;
/// <summary>
/// Gets the target product version of the transform.
/// </summary>
public string TargetProductVersion
{
get { return this.targetProductVersion; }
}
private string targetProductVersion;
/// <summary>
/// Gets the upgrade product code of the transform.
/// </summary>
public string UpgradeProductCode
{
get { return this.upgradeProductCode; }
}
private string upgradeProductCode;
/// <summary>
/// Gets the upgrade product version of the transform.
/// </summary>
public string UpgradeProductVersion
{
get { return this.upgradeProductVersion; }
}
private string upgradeProductVersion;
/// <summary>
/// Gets the upgrade code of the transform.
/// </summary>
public string UpgradeCode
{
get { return this.upgradeCode; }
}
private string upgradeCode;
/// <summary>
/// Gets the target platform of the transform.
/// </summary>
public string TargetPlatform
{
get { return this.targetPlatform; }
}
private string targetPlatform;
/// <summary>
/// Gets the target language of the transform, or 0 if the transform is language-neutral.
/// </summary>
public int TargetLanguage
{
get { return this.targetLanguage; }
}
private int targetLanguage;
/// <summary>
/// Gets the validation flags specified when the transform was generated.
/// </summary>
public TransformValidations Validations
{
get { return this.validateFlags; }
}
private TransformValidations validateFlags;
/// <summary>
/// Returns the name of the transform.
/// </summary>
public override string ToString()
{
return (this.Name != null ? this.Name : "MST");
}
}
}
|