Simplify heat by creating a single executable
Rob Mensching committed
Apr 22, 2021 at 17:38 UTC
35606d2cd04a7b1bec1d669f9619501dff2bf9dc
60 files changed
+86996
-1
src/heat/AssemblyHarvester.cs
new
+41
@@ -0,0 +1,41 @@
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.Harvesters
4
+{
5
+ using System;
6
+ using System.Reflection;
7
+ using System.Runtime.InteropServices;
8
+ using Wix = WixToolset.Harvesters.Serialize;
9
+
10
+ /// <summary>
11
+ /// Harvest WiX authoring from an assembly file.
12
+ /// </summary>
13
+ internal class AssemblyHarvester
14
+ {
15
+ /// <summary>
16
+ /// Harvest the registry values written by RegisterAssembly.
17
+ /// </summary>
18
+ /// <param name="path">The file to harvest registry values from.</param>
19
+ /// <returns>The harvested registry values.</returns>
20
+ public Wix.RegistryValue[] HarvestRegistryValues(string path)
21
+ {
22
+#if NETCOREAPP
23
+ throw new PlatformNotSupportedException();
24
+#else
25
+ RegistrationServices regSvcs = new RegistrationServices();
26
+ Assembly assembly = Assembly.LoadFrom(path);
27
+
28
+ // must call this before overriding registry hives to prevent binding failures
29
+ // on exported types during RegisterAssembly
30
+ assembly.GetExportedTypes();
31
+
32
+ using (RegistryHarvester registryHarvester = new RegistryHarvester(true))
33
+ {
34
+ regSvcs.RegisterAssembly(assembly, AssemblyRegistrationFlags.SetCodeBase);
35
+
36
+ return registryHarvester.HarvestRegistry();
37
+ }
38
+#endif
39
+ }
40
+ }
41
+}
src/heat/Data/HarvesterErrors.cs
new
+205
@@ -0,0 +1,205 @@
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.Harvesters.Data
4
+{
5
+ using System;
6
+ using System.Resources;
7
+ using WixToolset.Data;
8
+
9
+#pragma warning disable 1591 // TODO: add documentation
10
+ public static class HarvesterErrors
11
+ {
12
+ public static Message ArgumentRequiresValue(string argument)
13
+ {
14
+ return Message(null, Ids.ArgumentRequiresValue, "The argument '{0}' does not have a value specified and it is required.", argument);
15
+ }
16
+
17
+ public static Message BuildErrorDuringHarvesting(string buildError)
18
+ {
19
+ return Message(null, Ids.BuildErrorDuringHarvesting, "Build error during harvesting: {0}", buildError);
20
+ }
21
+
22
+ public static Message BuildFailed()
23
+ {
24
+ return Message(null, Ids.BuildFailed, "Build failed.");
25
+ }
26
+
27
+ public static Message CannotBuildProject(string projectFile, string innerExceptionMessage)
28
+ {
29
+ return Message(null, Ids.CannotBuildProject, "Failed to build project {0}: {1}", projectFile, innerExceptionMessage);
30
+ }
31
+
32
+ public static Message CannotHarvestWebSite()
33
+ {
34
+ return Message(null, Ids.CannotHarvestWebSite, "Cannot harvest website. On Windows Vista, you must install IIS 6 Management Compatibility.");
35
+ }
36
+
37
+ public static Message CannotLoadMSBuildAssembly(string innerExceptionMessage)
38
+ {
39
+ return Message(null, Ids.CannotLoadMSBuildAssembly, "Failed to load MSBuild assembly: {0}", innerExceptionMessage);
40
+ }
41
+
42
+ public static Message CannotLoadMSBuildEngine(string innerExceptionMessage)
43
+ {
44
+ return Message(null, Ids.CannotLoadMSBuildEngine, "Failed to load MSBuild engine: {0}", innerExceptionMessage);
45
+ }
46
+
47
+ public static Message CannotLoadMSBuildWrapperAssembly(string innerExceptionMessage)
48
+ {
49
+ return Message(null, Ids.CannotLoadMSBuildWrapperAssembly, "Failed to load MSBuild wrapper assembly: {0}", innerExceptionMessage);
50
+ }
51
+
52
+ public static Message CannotLoadMSBuildWrapperObject(string innerExceptionMessage)
53
+ {
54
+ return Message(null, Ids.CannotLoadMSBuildWrapperObject, "Failed to load MSBuild wrapper object: {0}", innerExceptionMessage);
55
+ }
56
+
57
+ public static Message CannotLoadMSBuildWrapperType(string innerExceptionMessage)
58
+ {
59
+ return Message(null, Ids.CannotLoadMSBuildWrapperType, "Failed to load MSBuild wrapper type: {0}", innerExceptionMessage);
60
+ }
61
+
62
+ public static Message CannotLoadProject(string projectFile, string innerExceptionMessage)
63
+ {
64
+ return Message(null, Ids.CannotLoadProject, "Failed to load project {0}: {1}", projectFile, innerExceptionMessage);
65
+ }
66
+
67
+ public static Message DirectoryAttributeAccessorBadType(string attributeName)
68
+ {
69
+ return Message(null, Ids.DirectoryAttributeAccessorBadType, "DirectoryAttributeAccessor tried to access an invalid element type for attribute '{0'}.", attributeName);
70
+ }
71
+
72
+ public static Message DirectoryNotFound(string directory)
73
+ {
74
+ return Message(null, Ids.DirectoryNotFound, "The directory '{0}' could not be found.", directory);
75
+ }
76
+
77
+ public static Message EmptyDirectory(string directory)
78
+ {
79
+ return Message(null, Ids.EmptyDirectory, "The directory '{0}' did not contain any files or sub-directories and since empty directories are not being kept, there was nothing to harvest.", directory);
80
+ }
81
+
82
+ public static Message ErrorTransformingHarvestedWiX(string transform, string message)
83
+ {
84
+ return Message(null, Ids.ErrorTransformingHarvestedWiX, "Error applying transform {0} to harvested WiX: {1}", transform, message);
85
+ }
86
+
87
+ public static Message FileNotFound(string file)
88
+ {
89
+ return Message(null, Ids.FileNotFound, "The file '{0}' cannot be found.", file);
90
+ }
91
+
92
+ public static Message InsufficientPermissionHarvestWebSite()
93
+ {
94
+ return Message(null, Ids.InsufficientPermissionHarvestWebSite, "Not enough permissions to harvest website. On Windows Vista, you must run Heat elevated.");
95
+ }
96
+
97
+ public static Message InvalidDirectoryId(string generateType)
98
+ {
99
+ return Message(null, Ids.InvalidDirectoryId, "Invalid directory ID: {0}. Check that it doesn't start with a hyphen or slash.", generateType);
100
+ }
101
+
102
+ public static Message InvalidDirectoryOutputType(string generateType)
103
+ {
104
+ return Message(null, Ids.InvalidOutputType, "Invalid generated type: {0}. Must be one of: components, payloadgroup.", generateType);
105
+ }
106
+
107
+ public static Message InvalidOutputGroup(string outputGroup)
108
+ {
109
+ return Message(null, Ids.InvalidOutputGroup, "Invalid project output group: {0}.", outputGroup);
110
+ }
111
+
112
+ public static Message InvalidProjectOutputType(string generateType)
113
+ {
114
+ return Message(null, Ids.InvalidOutputType, "Invalid generated type: {0}. Must be one of: components, container, payloadgroup, packagegroup.", generateType);
115
+ }
116
+
117
+ public static Message InvalidProjectName(string generateType)
118
+ {
119
+ return Message(null, Ids.InvalidProjectName, "Invalid project name: {0}. Check that it doesn't start with a hyphen or slash.", generateType);
120
+ }
121
+
122
+ public static Message MissingProjectOutputGroup(string projectFile, string outputGroup)
123
+ {
124
+ return Message(null, Ids.MissingProjectOutputGroup, "Missing project output group '{1}' in project {0}.", projectFile, outputGroup);
125
+ }
126
+
127
+ public static Message MsbuildBinPathRequired(string version)
128
+ {
129
+ return Message(null, Ids.MsbuildBinPathRequired, "MSBuildBinPath required for ToolsVersion '{0}'", version);
130
+ }
131
+
132
+ public static Message NoOutputGroupSpecified()
133
+ {
134
+ return Message(null, Ids.NoOutputGroupSpecified, "No project output group specified.");
135
+ }
136
+
137
+ public static Message PerformanceCategoryNotFound(string key)
138
+ {
139
+ return Message(null, Ids.PerformanceCategoryNotFound, "Performance category '{0}' not found.", key);
140
+ }
141
+
142
+ public static Message SpacesNotAllowedInArgumentValue(string arg, string value)
143
+ {
144
+ return Message(null, Ids.SpacesNotAllowedInArgumentValue, "The switch '{0}' does not allow the spaces from the value. Please remove the spaces in from the value: {1}", arg, value);
145
+ }
146
+
147
+ public static Message UnableToOpenRegistryKey(string key)
148
+ {
149
+ return Message(null, Ids.UnableToOpenRegistryKey, "Unable to open registry key '{0}'.", key);
150
+ }
151
+
152
+ public static Message UnsupportedPerformanceCounterType(string key)
153
+ {
154
+ return Message(null, Ids.UnsupportedPerformanceCounterType, "Unsupported performance counter type '{0}'.", key);
155
+ }
156
+
157
+ public static Message WebSiteNotFound(string webSiteDescription)
158
+ {
159
+ return Message(null, Ids.WebSiteNotFound, "The web site '{0}' could not be found. Please check that the web site exists, and that it is spelled correctly (please note, you must use the correct case).", webSiteDescription);
160
+ }
161
+
162
+ private static Message Message(SourceLineNumber sourceLineNumber, Ids id, string format, params object[] args)
163
+ {
164
+ return new Message(sourceLineNumber, MessageLevel.Error, (int)id, format, args);
165
+ }
166
+
167
+ private static Message Message(SourceLineNumber sourceLineNumber, Ids id, ResourceManager resourceManager, string resourceName, params object[] args)
168
+ {
169
+ return new Message(sourceLineNumber, MessageLevel.Error, (int)id, resourceManager, resourceName, args);
170
+ }
171
+
172
+ public enum Ids
173
+ {
174
+ DirectoryNotFound = 5052,
175
+ EmptyDirectory = 5053,
176
+ ErrorTransformingHarvestedWiX = 5055,
177
+ UnableToOpenRegistryKey = 5056,
178
+ SpacesNotAllowedInArgumentValue = 5057,
179
+ ArgumentRequiresValue = 5058,
180
+ FileNotFound = 5059,
181
+ PerformanceCategoryNotFound = 5060,
182
+ UnsupportedPerformanceCounterType = 5061,
183
+ WebSiteNotFound = 5158,
184
+ InsufficientPermissionHarvestWebSite = 5159,
185
+ CannotHarvestWebSite = 5160,
186
+ InvalidOutputGroup = 5301,
187
+ NoOutputGroupSpecified = 5302,
188
+ CannotLoadMSBuildAssembly = 5303,
189
+ CannotLoadMSBuildEngine = 5304,
190
+ CannotLoadProject = 5305,
191
+ CannotBuildProject = 5306,
192
+ BuildFailed = 5307,
193
+ MissingProjectOutputGroup = 5308,
194
+ DirectoryAttributeAccessorBadType = 5309,
195
+ InvalidOutputType = 5310,
196
+ InvalidDirectoryId = 5311,
197
+ InvalidProjectName = 5312,
198
+ BuildErrorDuringHarvesting = 5313,
199
+ CannotLoadMSBuildWrapperAssembly = 5314,
200
+ CannotLoadMSBuildWrapperType = 5315,
201
+ CannotLoadMSBuildWrapperObject = 5316,
202
+ MsbuildBinPathRequired = 5317,
203
+ }
204
+ }
205
+}
src/heat/Data/HarvesterVerboses.cs
new
+62
@@ -0,0 +1,62 @@
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.Harvesters.Data
4
+{
5
+ using System;
6
+ using System.Resources;
7
+ using WixToolset.Data;
8
+
9
+#pragma warning disable 1591 // TODO: add documentation
10
+ public static class HarvesterVerboses
11
+ {
12
+ public static Message FoundToolsVersion(string toolsVersion)
13
+ {
14
+ return Message(null, Ids.FoundToolsVersion, "Found ToolsVersion {0} inside project file.", toolsVersion);
15
+ }
16
+
17
+ public static Message HarvestingAssembly(string fileName)
18
+ {
19
+ return Message(null, Ids.HarvestingAssembly, "Trying to harvest {0} as an assembly.", fileName);
20
+ }
21
+
22
+ public static Message HarvestingSelfReg(string fileName)
23
+ {
24
+ return Message(null, Ids.HarvestingSelfReg, "Trying to harvest self-registration information from native DLL {0}.", fileName);
25
+ }
26
+
27
+ public static Message HarvestingTypeLib(string fileName)
28
+ {
29
+ return Message(null, Ids.HarvestingTypeLib, "Trying to harvest type-library information from native DLL {0}.", fileName);
30
+ }
31
+
32
+ public static Message LoadingProjectWithBinPath(string msbuildBinPath)
33
+ {
34
+ return Message(null, Ids.LoadingProjectWithBinPath, "Loading project using MSBuild bin path {0}.", msbuildBinPath);
35
+ }
36
+
37
+ public static Message LoadingProjectWithVersion(string msbuildVersion)
38
+ {
39
+ return Message(null, Ids.LoadingProjectWithVersion, "Loading project using MSBuild version {0}.", msbuildVersion);
40
+ }
41
+
42
+ private static Message Message(SourceLineNumber sourceLineNumber, Ids id, string format, params object[] args)
43
+ {
44
+ return new Message(sourceLineNumber, MessageLevel.Verbose, (int)id, format, args);
45
+ }
46
+
47
+ private static Message Message(SourceLineNumber sourceLineNumber, Ids id, ResourceManager resourceManager, string resourceName, params object[] args)
48
+ {
49
+ return new Message(sourceLineNumber, MessageLevel.Verbose, (int)id, resourceManager, resourceName, args);
50
+ }
51
+
52
+ public enum Ids
53
+ {
54
+ HarvestingAssembly = 5100,
55
+ HarvestingSelfReg = 5101,
56
+ HarvestingTypeLib = 5102,
57
+ LoadingProjectWithVersion = 5378,
58
+ FoundToolsVersion = 5379,
59
+ LoadingProjectWithBinPath = 5380,
60
+ }
61
+ }
62
+}
src/heat/Data/HarvesterWarnings.cs
new
+79
@@ -0,0 +1,79 @@
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.Harvesters.Data
4
+{
5
+ using System;
6
+ using System.Resources;
7
+ using WixToolset.Data;
8
+
9
+#pragma warning disable 1591 // TODO: add documentation
10
+ public static class HarvesterWarnings
11
+ {
12
+ public static Message AssemblyHarvestFailed(string file, string message)
13
+ {
14
+ return Message(null, Ids.AssemblyHarvestFailed, "Could not harvest data from a file that was expected to be an assembly: {0}. If this file is not an assembly you can ignore this warning. Otherwise, this error detail may be helpful to diagnose the failure: {1}", file, message);
15
+ }
16
+
17
+ public static Message DuplicateDllRegistryEntry(string registryKey, string componentId)
18
+ {
19
+ return Message(null, Ids.DuplicateDllRegistryEntry, "Ignoring the registry key '{0}', it has already been added to the component '{1}'.", registryKey, componentId);
20
+ }
21
+
22
+ public static Message DuplicateDllRegistryEntry(string registryKey, string registryKeyValue, string componentId)
23
+ {
24
+ return Message(null, Ids.DuplicateDllRegistryEntry, "Ignoring the registry key '{0}', it has already been added to the component '{2}'. The registry key value '{1}' will not be harvested.", registryKey, registryKeyValue, componentId);
25
+ }
26
+
27
+ public static Message EncounteredNullDirectoryForWebSite(string directory)
28
+ {
29
+ return Message(null, Ids.EncounteredNullDirectoryForWebSite, "Could not harvest website directory: {0}. Please update the output with the appropriate directory ID before using.", directory);
30
+ }
31
+
32
+ public static Message NoLogger(string exceptionMessage)
33
+ {
34
+ return Message(null, Ids.NoLogger, "Failed to set loggers: {0}", exceptionMessage);
35
+ }
36
+
37
+ public static Message NoProjectConfiguration(string exceptionMessage)
38
+ {
39
+ return Message(null, Ids.NoProjectConfiguration, "Failed to set project configuration and platform: {0}", exceptionMessage);
40
+ }
41
+
42
+ public static Message SelfRegHarvestFailed(string file, string message)
43
+ {
44
+ return Message(null, Ids.SelfRegHarvestFailed, "Could not harvest data from a file that was expected to be a SelfReg DLL: {0}. If this file does not support SelfReg you can ignore this warning. Otherwise, this error detail may be helpful to diagnose the failure: {1}", file, message);
45
+ }
46
+
47
+ public static Message TypeLibLoadFailed(string file, string message)
48
+ {
49
+ return Message(null, Ids.TypeLibLoadFailed, "Could not load file that was expected to be a type library based off of file extension: {0}. If this file is not a type library you can ignore this warning. Otherwise, this error detail may be helpful to diagnose the load failure: {1}", file, message);
50
+ }
51
+
52
+ public static Message UnsupportedRegistryType(string registryValue, int regFileLineNumber, string unsupportedType)
53
+ {
54
+ return Message(null, Ids.UnsupportedRegistryType, "Ignoring the registry value '{0}' found on line {1}, because it is of a type unsupported by Windows Installer ({2}).", registryValue, regFileLineNumber, unsupportedType);
55
+ }
56
+
57
+ private static Message Message(SourceLineNumber sourceLineNumber, Ids id, string format, params object[] args)
58
+ {
59
+ return new Message(sourceLineNumber, MessageLevel.Warning, (int)id, format, args);
60
+ }
61
+
62
+ private static Message Message(SourceLineNumber sourceLineNumber, Ids id, ResourceManager resourceManager, string resourceName, params object[] args)
63
+ {
64
+ return new Message(sourceLineNumber, MessageLevel.Warning, (int)id, resourceManager, resourceName, args);
65
+ }
66
+
67
+ public enum Ids
68
+ {
69
+ SelfRegHarvestFailed = 5150,
70
+ AssemblyHarvestFailed = 5151,
71
+ TypeLibLoadFailed = 5152,
72
+ DuplicateDllRegistryEntry = 5156,
73
+ UnsupportedRegistryType = 5157,
74
+ NoProjectConfiguration = 5398,
75
+ NoLogger = 5399,
76
+ EncounteredNullDirectoryForWebSite = 5400,
77
+ }
78
+ }
79
+}
src/heat/Data/HeatCommandLineOption.cs
new
+31
@@ -0,0 +1,31 @@
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.Harvesters.Data
4
+{
5
+ /// <summary>
6
+ /// A command line option.
7
+ /// </summary>
8
+ public struct HeatCommandLineOption
9
+ {
10
+ /// <summary>
11
+ /// The option name used on the command line.
12
+ /// </summary>
13
+ public string Option;
14
+
15
+ /// <summary>
16
+ /// Description shown in Help command.
17
+ /// </summary>
18
+ public string Description;
19
+
20
+ /// <summary>
21
+ /// Instantiates a new CommandLineOption.
22
+ /// </summary>
23
+ /// <param name="option">The option name.</param>
24
+ /// <param name="description">The description of the option.</param>
25
+ public HeatCommandLineOption(string option, string description)
26
+ {
27
+ this.Option = option;
28
+ this.Description = description;
29
+ }
30
+ }
31
+}
src/heat/Data/IHeatCommandLine.cs
new
+12
@@ -0,0 +1,12 @@
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.Harvesters.Data
4
+{
5
+ using WixToolset.Extensibility.Data;
6
+
7
+#pragma warning disable 1591 // TODO: add documentation
8
+ public interface IHeatCommandLine
9
+ {
10
+ ICommandLineCommand ParseStandardCommandLine(ICommandLineArguments arguments);
11
+ }
12
+}
src/heat/DirectoryHarvester.cs
new
+308
@@ -0,0 +1,308 @@
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.Harvesters
4
+{
5
+ using System;
6
+ using System.IO;
7
+ using WixToolset.Data;
8
+ using WixToolset.Harvesters.Data;
9
+ using WixToolset.Harvesters.Extensibility;
10
+ using Wix = WixToolset.Harvesters.Serialize;
11
+
12
+ /// <summary>
13
+ /// Harvest WiX authoring for a directory from the file system.
14
+ /// </summary>
15
+ internal class DirectoryHarvester : BaseHarvesterExtension
16
+ {
17
+ private FileHarvester fileHarvester;
18
+
19
+ private const string ComponentPrefix = "cmp";
20
+ private const string DirectoryPrefix = "dir";
21
+ private const string FilePrefix = "fil";
22
+
23
+ /// <summary>
24
+ /// Instantiate a new DirectoryHarvester.
25
+ /// </summary>
26
+ public DirectoryHarvester()
27
+ {
28
+ this.fileHarvester = new FileHarvester();
29
+ this.SetUniqueIdentifiers = true;
30
+ }
31
+
32
+ /// <summary>
33
+ /// Gets or sets what type of elements are to be generated.
34
+ /// </summary>
35
+ /// <value>The type of elements being generated.</value>
36
+ public GenerateType GenerateType { get; set; }
37
+
38
+ /// <summary>
39
+ /// Gets or sets the option to keep empty directories.
40
+ /// </summary>
41
+ /// <value>The option to keep empty directories.</value>
42
+ public bool KeepEmptyDirectories { get; set; }
43
+
44
+ /// <summary>
45
+ /// Gets or sets the rooted DirectoryRef Id if the user has supplied it.
46
+ /// </summary>
47
+ /// <value>The DirectoryRef Id to use as the root.</value>
48
+ public string RootedDirectoryRef { get; set; }
49
+
50
+ /// <summary>
51
+ /// Gets of sets the option to set unique identifiers.
52
+ /// </summary>
53
+ /// <value>The option to set unique identifiers.</value>
54
+ public bool SetUniqueIdentifiers { get; set; }
55
+
56
+ /// <summary>
57
+ /// Gets or sets the option to suppress including the root directory as an element.
58
+ /// </summary>
59
+ /// <value>The option to suppress including the root directory as an element.</value>
60
+ public bool SuppressRootDirectory { get; set; }
61
+
62
+ /// <summary>
63
+ /// Harvest a directory.
64
+ /// </summary>
65
+ /// <param name="argument">The path of the directory.</param>
66
+ /// <returns>The harvested directory.</returns>
67
+ public override Wix.Fragment[] Harvest(string argument)
68
+ {
69
+ if (null == argument)
70
+ {
71
+ throw new ArgumentNullException("argument");
72
+ }
73
+
74
+ Wix.IParentElement harvestParent = this.HarvestDirectory(argument, true, this.GenerateType);
75
+ Wix.ISchemaElement harvestElement;
76
+
77
+ if (this.GenerateType == GenerateType.PayloadGroup)
78
+ {
79
+ Wix.PayloadGroup payloadGroup = (Wix.PayloadGroup)harvestParent;
80
+ payloadGroup.Id = this.RootedDirectoryRef;
81
+ harvestElement = payloadGroup;
82
+ }
83
+ else
84
+ {
85
+ Wix.Directory directory = (Wix.Directory)harvestParent;
86
+
87
+ Wix.DirectoryRef directoryRef = new Wix.DirectoryRef();
88
+ directoryRef.Id = this.RootedDirectoryRef;
89
+
90
+ if (this.SuppressRootDirectory)
91
+ {
92
+ foreach (Wix.ISchemaElement element in directory.Children)
93
+ {
94
+ directoryRef.AddChild(element);
95
+ }
96
+ }
97
+ else
98
+ {
99
+ directoryRef.AddChild(directory);
100
+ }
101
+ harvestElement = directoryRef;
102
+ }
103
+
104
+ Wix.Fragment fragment = new Wix.Fragment();
105
+ fragment.AddChild(harvestElement);
106
+
107
+ return new Wix.Fragment[] { fragment };
108
+ }
109
+
110
+ /// <summary>
111
+ /// Harvest a directory.
112
+ /// </summary>
113
+ /// <param name="path">The path of the directory.</param>
114
+ /// <param name="harvestChildren">The option to harvest child directories and files.</param>
115
+ /// <returns>The harvested directory.</returns>
116
+ public Wix.Directory HarvestDirectory(string path, bool harvestChildren)
117
+ {
118
+ if (null == path)
119
+ {
120
+ throw new ArgumentNullException("path");
121
+ }
122
+
123
+ return (Wix.Directory)this.HarvestDirectory(path, harvestChildren, GenerateType.Components);
124
+ }
125
+
126
+ /// <summary>
127
+ /// Harvest a directory.
128
+ /// </summary>
129
+ /// <param name="path">The path of the directory.</param>
130
+ /// <param name="harvestChildren">The option to harvest child directories and files.</param>
131
+ /// <param name="generateType">The type to generate.</param>
132
+ /// <returns>The harvested directory.</returns>
133
+ private Wix.IParentElement HarvestDirectory(string path, bool harvestChildren, GenerateType generateType)
134
+ {
135
+ if (File.Exists(path))
136
+ {
137
+ throw new WixException(ErrorMessages.ExpectedDirectoryGotFile("dir", path));
138
+ }
139
+
140
+ if (null == this.RootedDirectoryRef)
141
+ {
142
+ this.RootedDirectoryRef = "TARGETDIR";
143
+ }
144
+
145
+ // use absolute paths
146
+ path = Path.GetFullPath(path);
147
+
148
+ // Remove any trailing separator to ensure Path.GetFileName() will return the directory name.
149
+ path = path.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
150
+
151
+ Wix.IParentElement harvestParent;
152
+ if (generateType == GenerateType.PayloadGroup)
153
+ {
154
+ harvestParent = new Wix.PayloadGroup();
155
+ }
156
+ else
157
+ {
158
+ Wix.Directory directory = new Wix.Directory();
159
+ directory.Name = Path.GetFileName(path);
160
+ directory.FileSource = path;
161
+
162
+ if (this.SetUniqueIdentifiers)
163
+ {
164
+ if (this.SuppressRootDirectory)
165
+ {
166
+ directory.Id = this.Core.GenerateIdentifier(DirectoryPrefix, this.RootedDirectoryRef);
167
+ }
168
+ else
169
+ {
170
+ directory.Id = this.Core.GenerateIdentifier(DirectoryPrefix, this.RootedDirectoryRef, directory.Name);
171
+ }
172
+ }
173
+ harvestParent = directory;
174
+ }
175
+
176
+ if (harvestChildren)
177
+ {
178
+ try
179
+ {
180
+ int fileCount = this.HarvestDirectory(path, "SourceDir\\", harvestParent, generateType);
181
+
182
+ if (generateType != GenerateType.PayloadGroup)
183
+ {
184
+ // its an error to not harvest anything with the option to keep empty directories off
185
+ if (0 == fileCount && !this.KeepEmptyDirectories)
186
+ {
187
+ throw new WixException(HarvesterErrors.EmptyDirectory(path));
188
+ }
189
+ }
190
+ }
191
+ catch (DirectoryNotFoundException)
192
+ {
193
+ throw new WixException(HarvesterErrors.DirectoryNotFound(path));
194
+ }
195
+ }
196
+
197
+ return harvestParent;
198
+ }
199
+
200
+ /// <summary>
201
+ /// Harvest a directory.
202
+ /// </summary>
203
+ /// <param name="path">The path of the directory.</param>
204
+ /// <param name="relativePath">The relative path that will be used when harvesting.</param>
205
+ /// <param name="harvestParent">The directory for this path.</param>
206
+ /// <param name="generateType"></param>
207
+ /// <returns>The number of files harvested.</returns>
208
+ private int HarvestDirectory(string path, string relativePath, Wix.IParentElement harvestParent, GenerateType generateType)
209
+ {
210
+ int fileCount = 0;
211
+ Wix.Directory directory = generateType != GenerateType.PayloadGroup ? (Wix.Directory)harvestParent : null;
212
+
213
+ // harvest the child directories
214
+ foreach (string childDirectoryPath in Directory.GetDirectories(path))
215
+ {
216
+ var childDirectoryName = Path.GetFileName(childDirectoryPath);
217
+ Wix.IParentElement newParent;
218
+ Wix.Directory childDirectory = null;
219
+
220
+ if (generateType == GenerateType.PayloadGroup)
221
+ {
222
+ newParent = harvestParent;
223
+ }
224
+ else
225
+ {
226
+ childDirectory = new Wix.Directory();
227
+ newParent = childDirectory;
228
+
229
+ childDirectory.Name = childDirectoryName;
230
+ childDirectory.FileSource = childDirectoryPath;
231
+
232
+ if (this.SetUniqueIdentifiers)
233
+ {
234
+ childDirectory.Id = this.Core.GenerateIdentifier(DirectoryPrefix, directory.Id, childDirectory.Name);
235
+ }
236
+ }
237
+
238
+ int childFileCount = this.HarvestDirectory(childDirectoryPath, String.Concat(relativePath, childDirectoryName, "\\"), newParent, generateType);
239
+
240
+ if (generateType != GenerateType.PayloadGroup)
241
+ {
242
+ // keep the directory if it contained any files (or empty directories are being kept)
243
+ if (0 < childFileCount || this.KeepEmptyDirectories)
244
+ {
245
+ directory.AddChild(childDirectory);
246
+ }
247
+ }
248
+
249
+ fileCount += childFileCount;
250
+ }
251
+
252
+ // harvest the files
253
+ string[] files = Directory.GetFiles(path);
254
+ if (0 < files.Length)
255
+ {
256
+ foreach (string filePath in Directory.GetFiles(path))
257
+ {
258
+ string fileName = Path.GetFileName(filePath);
259
+ string source = String.Concat(relativePath, fileName);
260
+
261
+ Wix.ISchemaElement newChild;
262
+ if (generateType == GenerateType.PayloadGroup)
263
+ {
264
+ Wix.Payload payload = new Wix.Payload();
265
+ newChild = payload;
266
+
267
+ payload.SourceFile = source;
268
+ }
269
+ else
270
+ {
271
+ Wix.Component component = new Wix.Component();
272
+ newChild = component;
273
+
274
+ Wix.File file = this.fileHarvester.HarvestFile(filePath);
275
+ file.Source = source;
276
+
277
+ if (this.SetUniqueIdentifiers)
278
+ {
279
+ file.Id = this.Core.GenerateIdentifier(FilePrefix, directory.Id, fileName);
280
+ component.Id = this.Core.GenerateIdentifier(ComponentPrefix, directory.Id, file.Id);
281
+ }
282
+
283
+ component.AddChild(file);
284
+ }
285
+
286
+ harvestParent.AddChild(newChild);
287
+ }
288
+ }
289
+ else if (generateType != GenerateType.PayloadGroup && 0 == fileCount && this.KeepEmptyDirectories)
290
+ {
291
+ Wix.Component component = new Wix.Component();
292
+ component.KeyPath = Wix.YesNoType.yes;
293
+
294
+ if (this.SetUniqueIdentifiers)
295
+ {
296
+ component.Id = this.Core.GenerateIdentifier(ComponentPrefix, directory.Id);
297
+ }
298
+
299
+ Wix.CreateFolder createFolder = new Wix.CreateFolder();
300
+ component.AddChild(createFolder);
301
+
302
+ directory.AddChild(component);
303
+ }
304
+
305
+ return fileCount + files.Length;
306
+ }
307
+ }
308
+}
src/heat/DllHarvester.cs
new
+106
@@ -0,0 +1,106 @@
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.Harvesters
4
+{
5
+ using System;
6
+ using System.Reflection;
7
+ using System.Reflection.Emit;
8
+ using System.Runtime.InteropServices;
9
+ using Wix = WixToolset.Harvesters.Serialize;
10
+
11
+ /// <summary>
12
+ /// Harvest WiX authoring from a native DLL file.
13
+ /// </summary>
14
+ internal class DllHarvester
15
+ {
16
+ /// <summary>
17
+ /// Harvest the registry values written by calling DllRegisterServer on the specified file.
18
+ /// </summary>
19
+ /// <param name="file">The file to harvest registry values from.</param>
20
+ /// <returns>The harvested registry values.</returns>
21
+ public Wix.RegistryValue[] HarvestRegistryValues(string file)
22
+ {
23
+ // load the DLL
24
+ NativeMethods.LoadLibrary(file);
25
+
26
+ using (RegistryHarvester registryHarvester = new RegistryHarvester(true))
27
+ {
28
+ try
29
+ {
30
+ DynamicPInvoke(file, "DllRegisterServer", typeof(int), null, null);
31
+
32
+ return registryHarvester.HarvestRegistry();
33
+ }
34
+ catch (TargetInvocationException e)
35
+ {
36
+ e.Data["file"] = file;
37
+ throw;
38
+ }
39
+ }
40
+ }
41
+
42
+ /// <summary>
43
+ /// Dynamically PInvokes into a DLL.
44
+ /// </summary>
45
+ /// <param name="dll">Dynamic link library containing the entry point.</param>
46
+ /// <param name="entryPoint">Entry point into dynamic link library.</param>
47
+ /// <param name="returnType">Return type of entry point.</param>
48
+ /// <param name="parameterTypes">Type of parameters to entry point.</param>
49
+ /// <param name="parameterValues">Value of parameters to entry point.</param>
50
+ /// <returns>Value from invoked code.</returns>
51
+ private static object DynamicPInvoke(string dll, string entryPoint, Type returnType, Type[] parameterTypes, object[] parameterValues)
52
+ {
53
+#if NETCOREAPP
54
+ throw new PlatformNotSupportedException();
55
+#else
56
+ AssemblyName assemblyName = new AssemblyName();
57
+ assemblyName.Name = "wixTempAssembly";
58
+
59
+ AssemblyBuilder dynamicAssembly = AppDomain.CurrentDomain.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.Run);
60
+ ModuleBuilder dynamicModule = dynamicAssembly.DefineDynamicModule("wixTempModule");
61
+
62
+ MethodBuilder dynamicMethod = dynamicModule.DefinePInvokeMethod(entryPoint, dll, MethodAttributes.Static | MethodAttributes.Public | MethodAttributes.PinvokeImpl, CallingConventions.Standard, returnType, parameterTypes, CallingConvention.Winapi, CharSet.Ansi);
63
+ dynamicModule.CreateGlobalFunctions();
64
+
65
+ MethodInfo methodInfo = dynamicModule.GetMethod(entryPoint);
66
+ return methodInfo.Invoke(null, parameterValues);
67
+#endif
68
+ }
69
+
70
+ /// <summary>
71
+ /// Native methods for loading libraries.
72
+ /// </summary>
73
+ private sealed class NativeMethods
74
+ {
75
+ private const UInt32 LOAD_WITH_ALTERED_SEARCH_PATH = 0x00000008;
76
+
77
+ /// <summary>
78
+ /// Load a DLL library.
79
+ /// </summary>
80
+ /// <param name="file">The file name of the executable module.</param>
81
+ /// <returns>If the function succeeds, the return value is a handle to the mapped executable module.</returns>
82
+ internal static IntPtr LoadLibrary(string file)
83
+ {
84
+ IntPtr dllHandle = LoadLibraryEx(file, IntPtr.Zero, NativeMethods.LOAD_WITH_ALTERED_SEARCH_PATH);
85
+
86
+ if (IntPtr.Zero == dllHandle)
87
+ {
88
+ int lastError = Marshal.GetLastWin32Error();
89
+ throw new Exception(String.Format("Unable to load file: {0}, error: {1}", file, lastError));
90
+ }
91
+
92
+ return dllHandle;
93
+ }
94
+
95
+ /// <summary>
96
+ /// Maps the specified executable module into the address space of the calling process.
97
+ /// </summary>
98
+ /// <param name="file">The file name of the executable module.</param>
99
+ /// <param name="fileHandle">This parameter is reserved for future use. It must be NULL.</param>
100
+ /// <param name="flags">Action to take when loading the module.</param>
101
+ /// <returns>If the function succeeds, the return value is a handle to the mapped executable module.</returns>
102
+ [DllImport("kernel32.dll", CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Unicode, SetLastError = true)]
103
+ private static extern IntPtr LoadLibraryEx(string file, IntPtr fileHandle, UInt32 flags);
104
+ }
105
+ }
106
+}
src/heat/Extensibility/BaseHarvesterExtension.cs
new
+26
@@ -0,0 +1,26 @@
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.Harvesters.Extensibility
4
+{
5
+ using Wix = WixToolset.Harvesters.Serialize;
6
+
7
+ /// <summary>
8
+ /// The base harvester extension. Any of these methods can be overridden to change
9
+ /// the behavior of the harvester.
10
+ /// </summary>
11
+ public abstract class BaseHarvesterExtension : IHarvesterExtension
12
+ {
13
+ /// <summary>
14
+ /// Gets or sets the harvester core for the extension.
15
+ /// </summary>
16
+ /// <value>The harvester core for the extension.</value>
17
+ public IHarvesterCore Core { get; set; }
18
+
19
+ /// <summary>
20
+ /// Harvest a WiX document.
21
+ /// </summary>
22
+ /// <param name="argument">The argument for harvesting.</param>
23
+ /// <returns>The harvested Fragments.</returns>
24
+ public abstract Wix.Fragment[] Harvest(string argument);
25
+ }
26
+}
src/heat/Extensibility/BaseHeatExtension.cs
new
+55
@@ -0,0 +1,55 @@
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.Harvesters.Extensibility
4
+{
5
+ using System;
6
+ using WixToolset.Harvesters.Data;
7
+
8
+ /// <summary>
9
+ /// An extension for the WiX Toolset Harvester application.
10
+ /// </summary>
11
+ public abstract class BaseHeatExtension : IHeatExtension
12
+ {
13
+ /// <summary>
14
+ /// Gets or sets the heat core for the extension.
15
+ /// </summary>
16
+ /// <value>The heat core for the extension.</value>
17
+ public IHeatCore Core { get; set; }
18
+
19
+ /// <summary>
20
+ /// Gets the supported command line types for this extension.
21
+ /// </summary>
22
+ /// <value>The supported command line types for this extension.</value>
23
+ public virtual HeatCommandLineOption[] CommandLineTypes
24
+ {
25
+ get { return null; }
26
+ }
27
+
28
+ /// <summary>
29
+ /// Parse the command line options for this extension.
30
+ /// </summary>
31
+ /// <param name="type">The active harvester type.</param>
32
+ /// <param name="args">The option arguments.</param>
33
+ public virtual void ParseOptions(string type, string[] args)
34
+ {
35
+ }
36
+
37
+ /// <summary>
38
+ /// Determines if the index refers to an argument.
39
+ /// </summary>
40
+ /// <param name="args"></param>
41
+ /// <param name="index"></param>
42
+ /// <returns></returns>
43
+ public static bool IsValidArg(string[] args, int index)
44
+ {
45
+ if (args.Length <= index || String.IsNullOrEmpty(args[index]) || '/' == args[index][0] || '-' == args[index][0])
46
+ {
47
+ return false;
48
+ }
49
+ else
50
+ {
51
+ return true;
52
+ }
53
+ }
54
+ }
55
+}
src/heat/Extensibility/BaseMutatorExtension.cs
new
+202
@@ -0,0 +1,202 @@
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.Harvesters.Extensibility
4
+{
5
+ using System;
6
+ using System.Collections.Generic;
7
+ using System.Text;
8
+ using Wix = WixToolset.Harvesters.Serialize;
9
+
10
+ /// <summary>
11
+ /// The base mutator extension. Any of these methods can be overridden to change
12
+ /// the behavior of the mutator.
13
+ /// </summary>
14
+ public abstract class BaseMutatorExtension : IMutatorExtension
15
+ {
16
+ /// <summary>
17
+ /// Gets or sets the mutator core for the extension.
18
+ /// </summary>
19
+ /// <value>The mutator core for the extension.</value>
20
+ public IHarvesterCore Core { get; set; }
21
+
22
+ /// <summary>
23
+ /// Gets the sequence of the extension.
24
+ /// </summary>
25
+ /// <value>The sequence of the extension.</value>
26
+ public abstract int Sequence { get; }
27
+
28
+ /// <summary>
29
+ /// Mutate a WiX document.
30
+ /// </summary>
31
+ /// <param name="wix">The Wix document element.</param>
32
+ public virtual void Mutate(Wix.Wix wix)
33
+ {
34
+ }
35
+
36
+ /// <summary>
37
+ /// Mutate a WiX document as a string.
38
+ /// </summary>
39
+ /// <param name="wixString">The Wix document element as a string.</param>
40
+ /// <returns>The mutated Wix document as a string.</returns>
41
+ public virtual string Mutate(string wixString)
42
+ {
43
+ return wixString;
44
+ }
45
+
46
+ /// <summary>
47
+ /// Generate unique MSI identifiers.
48
+ /// </summary>
49
+ protected class IdentifierGenerator
50
+ {
51
+ /// <summary>
52
+ ///
53
+ /// </summary>
54
+ public const int MaxProductIdentifierLength = 72;
55
+
56
+ /// <summary>
57
+ ///
58
+ /// </summary>
59
+ public const int MaxModuleIdentifierLength = 35;
60
+
61
+ private string baseName;
62
+ private int maxLength;
63
+ private Dictionary<string, object> existingIdentifiers;
64
+ private Dictionary<string, object> possibleIdentifiers;
65
+ private IHarvesterCore harvesterCore;
66
+
67
+ /// <summary>
68
+ /// Instantiate a new IdentifierGenerator.
69
+ /// </summary>
70
+ /// <param name="baseName">The base resource name to use if a resource name contains no usable characters.</param>
71
+ /// <param name="harvesterCore"></param>
72
+ public IdentifierGenerator(string baseName, IHarvesterCore harvesterCore)
73
+ {
74
+ this.baseName = baseName;
75
+ this.maxLength = IdentifierGenerator.MaxProductIdentifierLength;
76
+ this.existingIdentifiers = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
77
+ this.possibleIdentifiers = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
78
+ this.harvesterCore = harvesterCore;
79
+ }
80
+
81
+ /// <summary>
82
+ /// Gets or sets the maximum length for generated identifiers.
83
+ /// </summary>
84
+ /// <value>Maximum length for generated identifiers. (Default is 72.)</value>
85
+ public int MaxIdentifierLength
86
+ {
87
+ get { return this.maxLength; }
88
+ set { this.maxLength = value; }
89
+ }
90
+
91
+ /// <summary>
92
+ /// Index an existing identifier for collision detection.
93
+ /// </summary>
94
+ /// <param name="identifier">The identifier.</param>
95
+ public void IndexExistingIdentifier(string identifier)
96
+ {
97
+ if (null == identifier)
98
+ {
99
+ throw new ArgumentNullException("identifier");
100
+ }
101
+
102
+ this.existingIdentifiers[identifier] = null;
103
+ }
104
+
105
+ /// <summary>
106
+ /// Index a resource name for collision detection.
107
+ /// </summary>
108
+ /// <param name="name">The resource name.</param>
109
+ public void IndexName(string name)
110
+ {
111
+ if (null == name)
112
+ {
113
+ throw new ArgumentNullException("name");
114
+ }
115
+
116
+ string identifier = this.CreateIdentifier(name, 0);
117
+
118
+ if (this.possibleIdentifiers.ContainsKey(identifier))
119
+ {
120
+ this.possibleIdentifiers[identifier] = String.Empty;
121
+ }
122
+ else
123
+ {
124
+ this.possibleIdentifiers.Add(identifier, null);
125
+ }
126
+ }
127
+
128
+ /// <summary>
129
+ /// Get the identifier for the given resource name.
130
+ /// </summary>
131
+ /// <param name="name">The resource name.</param>
132
+ /// <returns>A legal MSI identifier.</returns>
133
+ public string GetIdentifier(string name)
134
+ {
135
+ if (null == name)
136
+ {
137
+ throw new ArgumentNullException("name");
138
+ }
139
+
140
+ for (int i = 0; i <= Int32.MaxValue; i++)
141
+ {
142
+ string identifier = this.CreateIdentifier(name, i);
143
+
144
+ if (this.existingIdentifiers.ContainsKey(identifier) || // already used
145
+ (0 == i && 0 != this.possibleIdentifiers.Count && null != this.possibleIdentifiers[identifier]) || // needs an index because its duplicated
146
+ (0 != i && this.possibleIdentifiers.ContainsKey(identifier))) // collides with another possible identifier
147
+ {
148
+ continue;
149
+ }
150
+ else // use this identifier
151
+ {
152
+ this.existingIdentifiers.Add(identifier, null);
153
+
154
+ return identifier;
155
+ }
156
+ }
157
+
158
+ throw new InvalidOperationException("Could not find a unique identifier for the given resource name.");
159
+ }
160
+
161
+ /// <summary>
162
+ /// Create a legal MSI identifier from a resource name and an index.
163
+ /// </summary>
164
+ /// <param name="name">The name of the resource for which an identifier should be created.</param>
165
+ /// <param name="index">An index to append to the end of the identifier to make it unique.</param>
166
+ /// <returns>A legal MSI identifier.</returns>
167
+ public string CreateIdentifier(string name, int index)
168
+ {
169
+ if (null == name)
170
+ {
171
+ throw new ArgumentNullException("name");
172
+ }
173
+
174
+ StringBuilder identifier = new StringBuilder();
175
+
176
+ // Convert the name to a standard MSI identifier
177
+ identifier.Append(this.harvesterCore.CreateIdentifierFromFilename(name));
178
+
179
+ // no legal identifier characters were found, use the base id instead
180
+ if (0 == identifier.Length)
181
+ {
182
+ identifier.Append(this.baseName);
183
+ }
184
+
185
+ // truncate the identifier if it's too long (reserve 3 characters for up to 99 collisions)
186
+ int adjustedMaxLength = this.MaxIdentifierLength - (index != 0 ? 3 : 0);
187
+ if (adjustedMaxLength < identifier.Length)
188
+ {
189
+ identifier.Length = adjustedMaxLength;
190
+ }
191
+
192
+ // if the index is not zero, then append it to the identifier name
193
+ if (0 != index)
194
+ {
195
+ identifier.AppendFormat("_{0}", index);
196
+ }
197
+
198
+ return identifier.ToString();
199
+ }
200
+ }
201
+ }
202
+}
src/heat/Extensibility/IHarvester.cs
new
+31
@@ -0,0 +1,31 @@
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.Harvesters.Extensibility
4
+{
5
+ using Wix = WixToolset.Harvesters.Serialize;
6
+
7
+ /// <summary>
8
+ /// Interface for the harvester.
9
+ /// </summary>
10
+ public interface IHarvester
11
+ {
12
+ /// <summary>
13
+ /// Gets or sets the harvester core for the extension.
14
+ /// </summary>
15
+ /// <value>The harvester core for the extension.</value>
16
+ IHarvesterCore Core { get; }
17
+
18
+ /// <summary>
19
+ /// Gets or sets the extension.
20
+ /// </summary>
21
+ /// <value>The extension.</value>
22
+ IHarvesterExtension Extension { get; set; }
23
+
24
+ /// <summary>
25
+ /// Harvest wix authoring.
26
+ /// </summary>
27
+ /// <param name="argument">The argument for harvesting.</param>
28
+ /// <returns>The harvested wix authoring.</returns>
29
+ Wix.Wix Harvest(string argument);
30
+ }
31
+}
src/heat/Extensibility/IHarvesterCore.cs
new
+51
@@ -0,0 +1,51 @@
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.Harvesters.Extensibility
4
+{
5
+ using WixToolset.Extensibility.Services;
6
+
7
+ /// <summary>
8
+ /// The WiX Toolset harvester core.
9
+ /// </summary>
10
+ public interface IHarvesterCore
11
+ {
12
+ /// <summary>
13
+ ///
14
+ /// </summary>
15
+ IMessaging Messaging { get; set; }
16
+
17
+ /// <summary>
18
+ /// Gets or sets the value of the extension argument passed to heat.
19
+ /// </summary>
20
+ /// <value>The extension argument.</value>
21
+ string ExtensionArgument { get; set; }
22
+
23
+ /// <summary>
24
+ /// Gets or sets the value of the root directory that is being harvested.
25
+ /// </summary>
26
+ /// <value>The root directory being harvested.</value>
27
+ string RootDirectory { get; set; }
28
+
29
+ /// <summary>
30
+ /// Create an identifier based on passed file name
31
+ /// </summary>
32
+ /// <param name="filename">File name to generate identifer from</param>
33
+ /// <returns></returns>
34
+ string CreateIdentifierFromFilename(string filename);
35
+
36
+ /// <summary>
37
+ /// Generate an identifier by hashing data from the row.
38
+ /// </summary>
39
+ /// <param name="prefix">Three letter or less prefix for generated row identifier.</param>
40
+ /// <param name="args">Information to hash.</param>
41
+ /// <returns>The generated identifier.</returns>
42
+ string GenerateIdentifier(string prefix, params string[] args);
43
+
44
+ /// <summary>
45
+ /// Resolves a file's path if the Wix.File.Source value starts with "SourceDir\".
46
+ /// </summary>
47
+ /// <param name="fileSource">The Wix.File.Source value with "SourceDir\".</param>
48
+ /// <returns>The full path of the file.</returns>
49
+ string ResolveFilePath(string fileSource);
50
+ }
51
+}
src/heat/Extensibility/IHarvesterExtension.cs
new
+14
@@ -0,0 +1,14 @@
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.Harvesters.Extensibility
4
+{
5
+ using Wix = WixToolset.Harvesters.Serialize;
6
+
7
+#pragma warning disable 1591 // TODO: add documentation
8
+ public interface IHarvesterExtension
9
+ {
10
+ IHarvesterCore Core { get; set; }
11
+
12
+ Wix.Fragment[] Harvest(string argument);
13
+ }
14
+}
src/heat/Extensibility/IHeatCore.cs
new
+29
@@ -0,0 +1,29 @@
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.Harvesters.Extensibility
4
+{
5
+ using WixToolset.Extensibility.Services;
6
+
7
+ /// <summary>
8
+ /// The WiX Toolset Harvester application core.
9
+ /// </summary>
10
+ public interface IHeatCore
11
+ {
12
+ /// <summary>
13
+ /// Gets the harvester.
14
+ /// </summary>
15
+ /// <value>The harvester.</value>
16
+ IHarvester Harvester { get; }
17
+
18
+ /// <summary>
19
+ ///
20
+ /// </summary>
21
+ IMessaging Messaging { get; }
22
+
23
+ /// <summary>
24
+ /// Gets the mutator.
25
+ /// </summary>
26
+ /// <value>The mutator.</value>
27
+ IMutator Mutator { get; }
28
+ }
29
+}
src/heat/Extensibility/IHeatExtension.cs
new
+16
@@ -0,0 +1,16 @@
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.Harvesters.Extensibility
4
+{
5
+ using WixToolset.Harvesters.Data;
6
+
7
+#pragma warning disable 1591 // TODO: add documentation
8
+ public interface IHeatExtension
9
+ {
10
+ IHeatCore Core { get; set; }
11
+
12
+ HeatCommandLineOption[] CommandLineTypes { get; }
13
+
14
+ void ParseOptions(string type, string[] args);
15
+ }
16
+}
src/heat/Extensibility/IMutator.cs
new
+44
@@ -0,0 +1,44 @@
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.Harvesters.Extensibility
4
+{
5
+ using Wix = WixToolset.Harvesters.Serialize;
6
+
7
+ /// <summary>
8
+ /// Interface for a mutator.
9
+ /// </summary>
10
+ public interface IMutator
11
+ {
12
+ /// <summary>
13
+ /// Gets or sets the harvester core for the extension.
14
+ /// </summary>
15
+ /// <value>The harvester core for the extension.</value>
16
+ IHarvesterCore Core { get; }
17
+
18
+ /// <summary>
19
+ /// Gets or sets the value of the extension argument passed to heat.
20
+ /// </summary>
21
+ /// <value>The extension argument.</value>
22
+ string ExtensionArgument { get; }
23
+
24
+ /// <summary>
25
+ /// Adds a mutator extension.
26
+ /// </summary>
27
+ /// <param name="mutatorExtension">The mutator extension to add.</param>
28
+ void AddExtension(IMutatorExtension mutatorExtension);
29
+
30
+ /// <summary>
31
+ /// Mutate a WiX document.
32
+ /// </summary>
33
+ /// <param name="wix">The Wix document element.</param>
34
+ /// <returns>true if mutation was successful</returns>
35
+ bool Mutate(Wix.Wix wix);
36
+
37
+ /// <summary>
38
+ /// Mutate a WiX document.
39
+ /// </summary>
40
+ /// <param name="wixString">The Wix document as a string.</param>
41
+ /// <returns>The mutated Wix document as a string if mutation was successful, else null.</returns>
42
+ string Mutate(string wixString);
43
+ }
44
+}
src/heat/Extensibility/IMutatorExtension.cs
new
+18
@@ -0,0 +1,18 @@
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.Harvesters.Extensibility
4
+{
5
+ using Wix = WixToolset.Harvesters.Serialize;
6
+
7
+#pragma warning disable 1591 // TODO: add documentation
8
+ public interface IMutatorExtension
9
+ {
10
+ IHarvesterCore Core { get; set; }
11
+
12
+ int Sequence { get; }
13
+
14
+ void Mutate(Wix.Wix wix);
15
+
16
+ string Mutate(string wixString);
17
+ }
18
+}
src/heat/FileHarvester.cs
new
+156
@@ -0,0 +1,156 @@
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.Harvesters
4
+{
5
+ using System;
6
+ using System.IO;
7
+ using WixToolset.Data;
8
+ using WixToolset.Harvesters.Data;
9
+ using WixToolset.Harvesters.Extensibility;
10
+ using Wix = WixToolset.Harvesters.Serialize;
11
+
12
+ /// <summary>
13
+ /// Harvest WiX authoring for a file from the file system.
14
+ /// </summary>
15
+ internal class FileHarvester : BaseHarvesterExtension
16
+ {
17
+ private string rootedDirectoryRef;
18
+ private bool setUniqueIdentifiers;
19
+ private bool suppressRootDirectory;
20
+
21
+ private static readonly string ComponentPrefix = "cmp";
22
+ private static readonly string DirectoryPrefix = "dir";
23
+ private static readonly string FilePrefix = "fil";
24
+
25
+ /// <summary>
26
+ /// Instantiate a new FileHarvester.
27
+ /// </summary>
28
+ public FileHarvester()
29
+ {
30
+ this.setUniqueIdentifiers = true;
31
+ this.suppressRootDirectory = false;
32
+ }
33
+
34
+ /// <summary>
35
+ /// Gets or sets the rooted DirectoryRef Id if the user has supplied it.
36
+ /// </summary>
37
+ /// <value>The DirectoryRef Id to use as the root.</value>
38
+ public string RootedDirectoryRef
39
+ {
40
+ get { return this.rootedDirectoryRef; }
41
+ set { this.rootedDirectoryRef = value; }
42
+ }
43
+
44
+ /// <summary>
45
+ /// Gets of sets the option to set unique identifiers.
46
+ /// </summary>
47
+ /// <value>The option to set unique identifiers.</value>
48
+ public bool SetUniqueIdentifiers
49
+ {
50
+ get { return this.setUniqueIdentifiers; }
51
+ set { this.setUniqueIdentifiers = value; }
52
+ }
53
+
54
+ /// <summary>
55
+ /// Gets or sets the option to suppress including the root directory as an element.
56
+ /// </summary>
57
+ /// <value>The option to suppress including the root directory as an element.</value>
58
+ public bool SuppressRootDirectory
59
+ {
60
+ get { return this.suppressRootDirectory; }
61
+ set { this.suppressRootDirectory = value; }
62
+ }
63
+
64
+ /// <summary>
65
+ /// Harvest a file.
66
+ /// </summary>
67
+ /// <param name="argument">The path of the file.</param>
68
+ /// <returns>A harvested file.</returns>
69
+ public override Wix.Fragment[] Harvest(string argument)
70
+ {
71
+ if (null == argument)
72
+ {
73
+ throw new ArgumentNullException("argument");
74
+ }
75
+
76
+ if (null == this.rootedDirectoryRef)
77
+ {
78
+ this.rootedDirectoryRef = "TARGETDIR";
79
+ }
80
+
81
+ string fullPath = Path.GetFullPath(argument);
82
+
83
+ Wix.DirectoryRef directoryRef = new Wix.DirectoryRef();
84
+ directoryRef.Id = this.rootedDirectoryRef;
85
+
86
+ Wix.File file = this.HarvestFile(fullPath);
87
+
88
+ if (!this.suppressRootDirectory)
89
+ {
90
+ file.Source = String.Concat("SourceDir\\", Path.GetFileName(Path.GetDirectoryName(fullPath)), "\\", Path.GetFileName(fullPath));
91
+ }
92
+
93
+ Wix.Component component = new Wix.Component();
94
+ component.AddChild(file);
95
+
96
+ Wix.Directory directory = new Wix.Directory();
97
+
98
+ if (this.suppressRootDirectory)
99
+ {
100
+ directoryRef.AddChild(component);
101
+ }
102
+ else
103
+ {
104
+ string directoryPath = Path.GetDirectoryName(Path.GetFullPath(argument));
105
+ directory.Name = Path.GetFileName(directoryPath);
106
+
107
+ if (this.setUniqueIdentifiers)
108
+ {
109
+ directory.Id = this.Core.GenerateIdentifier(DirectoryPrefix, directoryRef.Id, directory.Name);
110
+ }
111
+ directory.AddChild(component);
112
+ directoryRef.AddChild(directory);
113
+ }
114
+
115
+ if (this.setUniqueIdentifiers)
116
+ {
117
+ file.Id = this.Core.GenerateIdentifier(FilePrefix, (this.suppressRootDirectory) ? directoryRef.Id : directory.Id, Path.GetFileName(file.Source));
118
+ component.Id = this.Core.GenerateIdentifier(ComponentPrefix, (this.suppressRootDirectory) ? directoryRef.Id : directory.Id, file.Id);
119
+ }
120
+
121
+ Wix.Fragment fragment = new Wix.Fragment();
122
+ fragment.AddChild(directoryRef);
123
+
124
+ return new Wix.Fragment[] { fragment };
125
+ }
126
+
127
+ /// <summary>
128
+ /// Harvest a file.
129
+ /// </summary>
130
+ /// <param name="path">The path of the file.</param>
131
+ /// <returns>A harvested file.</returns>
132
+ public Wix.File HarvestFile(string path)
133
+ {
134
+ if (null == path)
135
+ {
136
+ throw new ArgumentNullException("path");
137
+ }
138
+
139
+ if (!File.Exists(path))
140
+ {
141
+ throw new WixException(HarvesterErrors.FileNotFound(path));
142
+ }
143
+
144
+ Wix.File file = new Wix.File();
145
+
146
+ // use absolute paths
147
+ path = Path.GetFullPath(path);
148
+
149
+ file.KeyPath = Wix.YesNoType.yes;
150
+
151
+ file.Source = String.Concat("SourceDir\\", Path.GetFileName(path));
152
+
153
+ return file;
154
+ }
155
+ }
156
+}
src/heat/Harvester.cs
new
+65
@@ -0,0 +1,65 @@
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.Harvesters
4
+{
5
+ using System;
6
+ using WixToolset.Data;
7
+ using WixToolset.Harvesters.Extensibility;
8
+ using Wix = WixToolset.Harvesters.Serialize;
9
+
10
+ /// <summary>
11
+ /// The WiX Toolset harvester.
12
+ /// </summary>
13
+ internal class Harvester : IHarvester
14
+ {
15
+ private IHarvesterExtension harvesterExtension;
16
+
17
+ public IHarvesterCore Core { get; set; }
18
+
19
+ public IHarvesterExtension Extension
20
+ {
21
+ get
22
+ {
23
+ return this.harvesterExtension;
24
+ }
25
+ set
26
+ {
27
+ if (null != this.harvesterExtension)
28
+ {
29
+ throw new InvalidOperationException("Multiple harvester extensions specified.");
30
+ }
31
+
32
+ this.harvesterExtension = value;
33
+ }
34
+ }
35
+
36
+ public Wix.Wix Harvest(string argument)
37
+ {
38
+ if (null == argument)
39
+ {
40
+ throw new ArgumentNullException("argument");
41
+ }
42
+
43
+ if (null == this.harvesterExtension)
44
+ {
45
+ throw new WixException(ErrorMessages.HarvestTypeNotFound());
46
+ }
47
+
48
+ this.harvesterExtension.Core = this.Core;
49
+
50
+ Wix.Fragment[] fragments = this.harvesterExtension.Harvest(argument);
51
+ if (null == fragments || 0 == fragments.Length)
52
+ {
53
+ return null;
54
+ }
55
+
56
+ Wix.Wix wix = new Wix.Wix();
57
+ foreach (Wix.Fragment fragment in fragments)
58
+ {
59
+ wix.AddChild(fragment);
60
+ }
61
+
62
+ return wix;
63
+ }
64
+ }
65
+}
src/heat/HarvesterCore.cs
new
+76
@@ -0,0 +1,76 @@
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.Harvesters
4
+{
5
+ using System;
6
+ using System.IO;
7
+ using WixToolset.Extensibility.Services;
8
+ using WixToolset.Harvesters.Extensibility;
9
+
10
+ /// <summary>
11
+ /// The WiX Toolset harvester core.
12
+ /// </summary>
13
+ internal class HarvesterCore : IHarvesterCore
14
+ {
15
+ public IMessaging Messaging { get; set; }
16
+
17
+ public IParseHelper ParseHelper { get; set; }
18
+
19
+ /// <summary>
20
+ /// Gets or sets the value of the extension argument passed to heat.
21
+ /// </summary>
22
+ /// <value>The extension argument.</value>
23
+ public string ExtensionArgument { get; set; }
24
+
25
+ /// <summary>
26
+ /// Gets or sets the value of the root directory that is being harvested.
27
+ /// </summary>
28
+ /// <value>The root directory being harvested.</value>
29
+ public string RootDirectory { get; set; }
30
+
31
+ /// <summary>
32
+ /// Create an identifier based on passed file name
33
+ /// </summary>
34
+ /// <param name="filename">File name to generate identifer from</param>
35
+ /// <returns></returns>
36
+ public string CreateIdentifierFromFilename(string filename)
37
+ {
38
+ return this.ParseHelper.CreateIdentifierFromFilename(filename).Id;
39
+ }
40
+
41
+ /// <summary>
42
+ /// Generate an identifier by hashing data from the row.
43
+ /// </summary>
44
+ /// <param name="prefix">Three letter or less prefix for generated row identifier.</param>
45
+ /// <param name="args">Information to hash.</param>
46
+ /// <returns>The generated identifier.</returns>
47
+ public string GenerateIdentifier(string prefix, params string[] args)
48
+ {
49
+ return this.ParseHelper.CreateIdentifier(prefix, args).Id;
50
+ }
51
+
52
+ /// <summary>
53
+ /// Resolves a file's path if the Wix.File.Source value starts with "SourceDir\".
54
+ /// </summary>
55
+ /// <param name="fileSource">The Wix.File.Source value with "SourceDir\".</param>
56
+ /// <returns>The full path of the file.</returns>
57
+ public string ResolveFilePath(string fileSource)
58
+ {
59
+ if (fileSource.StartsWith("SourceDir\\", StringComparison.Ordinal))
60
+ {
61
+ string file = Path.GetFullPath(this.RootDirectory);
62
+ if (File.Exists(file))
63
+ {
64
+ return file;
65
+ }
66
+ else
67
+ {
68
+ fileSource = fileSource.Substring(10);
69
+ fileSource = Path.Combine(Path.GetFullPath(this.RootDirectory), fileSource);
70
+ }
71
+ }
72
+
73
+ return fileSource;
74
+ }
75
+ }
76
+}
src/heat/HeatCommand.cs
new
+275
@@ -0,0 +1,275 @@
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.Harvesters
4
+{
5
+ using System;
6
+ using System.Collections.Generic;
7
+ using System.Globalization;
8
+ using System.IO;
9
+ using System.Runtime.InteropServices;
10
+ using System.Threading;
11
+ using System.Threading.Tasks;
12
+ using System.Xml;
13
+ using WixToolset.Data;
14
+ using WixToolset.Extensibility.Data;
15
+ using WixToolset.Extensibility.Services;
16
+ using WixToolset.Harvesters.Extensibility;
17
+ using Wix = WixToolset.Harvesters.Serialize;
18
+
19
+ internal class HeatCommand : ICommandLineCommand
20
+ {
21
+ public HeatCommand(string harvestType, IList<IHeatExtension> extensions, IServiceProvider serviceProvider)
22
+ {
23
+ this.Extensions = extensions;
24
+ this.Messaging = serviceProvider.GetService<IMessaging>();
25
+ this.ServiceProvider = serviceProvider;
26
+
27
+ this.ExtensionType = harvestType;
28
+ this.ExtensionOptions.Add(harvestType);
29
+ }
30
+
31
+ private string ExtensionArgument { get; set; }
32
+
33
+ private List<string> ExtensionOptions { get; } = new List<string>();
34
+
35
+ private string ExtensionType { get; }
36
+
37
+ private IList<IHeatExtension> Extensions { get; }
38
+
39
+ private int Indent { get; set; } = 4;
40
+
41
+ private IMessaging Messaging { get; }
42
+
43
+ private string OutputFile { get; set; }
44
+
45
+ private IServiceProvider ServiceProvider { get; }
46
+
47
+ public bool ShowLogo { get; private set; }
48
+
49
+ public bool StopParsing { get; private set; }
50
+
51
+ public Task<int> ExecuteAsync(CancellationToken cancellationToken)
52
+ {
53
+ var exitCode = this.Harvest();
54
+ return Task.FromResult(exitCode);
55
+ }
56
+
57
+ public bool TryParseArgument(ICommandLineParser parser, string arg)
58
+ {
59
+ if (this.ExtensionArgument == null)
60
+ {
61
+ this.ExtensionArgument = arg;
62
+ }
63
+ else if ('-' == arg[0] || '/' == arg[0])
64
+ {
65
+ string parameter = arg.Substring(1);
66
+ if ("nologo" == parameter)
67
+ {
68
+ this.ShowLogo = false;
69
+ }
70
+ else if ("o" == parameter || "out" == parameter)
71
+ {
72
+ this.OutputFile = parser.GetNextArgumentAsFilePathOrError(arg);
73
+
74
+ if (String.IsNullOrEmpty(this.OutputFile))
75
+ {
76
+ return false;
77
+ }
78
+ }
79
+ else if ("swall" == parameter)
80
+ {
81
+ this.Messaging.Write(WarningMessages.DeprecatedCommandLineSwitch("swall", "sw"));
82
+ this.Messaging.SuppressAllWarnings = true;
83
+ }
84
+ else if (parameter.StartsWith("sw"))
85
+ {
86
+ string paramArg = parameter.Substring(2);
87
+ try
88
+ {
89
+ if (0 == paramArg.Length)
90
+ {
91
+ this.Messaging.SuppressAllWarnings = true;
92
+ }
93
+ else
94
+ {
95
+ int suppressWarning = Convert.ToInt32(paramArg, CultureInfo.InvariantCulture.NumberFormat);
96
+ if (0 >= suppressWarning)
97
+ {
98
+ this.Messaging.Write(ErrorMessages.IllegalSuppressWarningId(paramArg));
99
+ }
100
+
101
+ this.Messaging.SuppressWarningMessage(suppressWarning);
102
+ }
103
+ }
104
+ catch (FormatException)
105
+ {
106
+ this.Messaging.Write(ErrorMessages.IllegalSuppressWarningId(paramArg));
107
+ }
108
+ catch (OverflowException)
109
+ {
110
+ this.Messaging.Write(ErrorMessages.IllegalSuppressWarningId(paramArg));
111
+ }
112
+ }
113
+ else if ("wxall" == parameter)
114
+ {
115
+ this.Messaging.Write(WarningMessages.DeprecatedCommandLineSwitch("wxall", "wx"));
116
+ this.Messaging.WarningsAsError = true;
117
+ }
118
+ else if (parameter.StartsWith("wx"))
119
+ {
120
+ string paramArg = parameter.Substring(2);
121
+ try
122
+ {
123
+ if (0 == paramArg.Length)
124
+ {
125
+ this.Messaging.WarningsAsError = true;
126
+ }
127
+ else
128
+ {
129
+ int elevateWarning = Convert.ToInt32(paramArg, CultureInfo.InvariantCulture.NumberFormat);
130
+ if (0 >= elevateWarning)
131
+ {
132
+ this.Messaging.Write(ErrorMessages.IllegalWarningIdAsError(paramArg));
133
+ }
134
+
135
+ this.Messaging.ElevateWarningMessage(elevateWarning);
136
+ }
137
+ }
138
+ catch (FormatException)
139
+ {
140
+ this.Messaging.Write(ErrorMessages.IllegalWarningIdAsError(paramArg));
141
+ }
142
+ catch (OverflowException)
143
+ {
144
+ this.Messaging.Write(ErrorMessages.IllegalWarningIdAsError(paramArg));
145
+ }
146
+ }
147
+ else if ("v" == parameter)
148
+ {
149
+ this.Messaging.ShowVerboseMessages = true;
150
+ }
151
+ else if ("indent" == parameter)
152
+ {
153
+ try
154
+ {
155
+ this.Indent = Int32.Parse(parser.GetNextArgumentOrError(arg), CultureInfo.InvariantCulture);
156
+ }
157
+ catch
158
+ {
159
+ throw new ArgumentException("Invalid numeric argument.", parameter);
160
+ }
161
+ }
162
+ }
163
+
164
+ this.ExtensionOptions.Add(arg);
165
+ return true;
166
+ }
167
+
168
+ private int Harvest()
169
+ {
170
+ try
171
+ {
172
+ if (String.IsNullOrEmpty(this.ExtensionArgument))
173
+ {
174
+ this.Messaging.Write(ErrorMessages.HarvestSourceNotSpecified());
175
+ }
176
+ else if (String.IsNullOrEmpty(this.OutputFile))
177
+ {
178
+ this.Messaging.Write(ErrorMessages.OutputTargetNotSpecified());
179
+ }
180
+
181
+ // exit if there was an error parsing the core command line
182
+ if (this.Messaging.EncounteredError)
183
+ {
184
+ return this.Messaging.LastErrorNumber;
185
+ }
186
+
187
+ if (this.ShowLogo)
188
+ {
189
+ HelpCommand.DisplayToolHeader();
190
+ }
191
+
192
+ var heatCore = new HeatCore(this.ServiceProvider, this.ExtensionArgument);
193
+
194
+ // parse the extension's command line arguments
195
+ var extensionOptionsArray = this.ExtensionOptions.ToArray();
196
+ foreach (var heatExtension in this.Extensions)
197
+ {
198
+ heatExtension.Core = heatCore;
199
+ heatExtension.ParseOptions(this.ExtensionType, extensionOptionsArray);
200
+ }
201
+
202
+ // exit if there was an error parsing the command line (otherwise the logo appears after error messages)
203
+ if (this.Messaging.EncounteredError)
204
+ {
205
+ return this.Messaging.LastErrorNumber;
206
+ }
207
+
208
+ // harvest the output
209
+ Wix.Wix wix = heatCore.Harvester.Harvest(this.ExtensionArgument);
210
+ if (null == wix)
211
+ {
212
+ return this.Messaging.LastErrorNumber;
213
+ }
214
+
215
+ // mutate the output
216
+ if (!heatCore.Mutator.Mutate(wix))
217
+ {
218
+ return this.Messaging.LastErrorNumber;
219
+ }
220
+
221
+ XmlWriterSettings xmlSettings = new XmlWriterSettings();
222
+ xmlSettings.Indent = true;
223
+ xmlSettings.IndentChars = new string(' ', this.Indent);
224
+ xmlSettings.OmitXmlDeclaration = true;
225
+
226
+ string wixString;
227
+ using (StringWriter stringWriter = new StringWriter())
228
+ {
229
+ using (XmlWriter xmlWriter = XmlWriter.Create(stringWriter, xmlSettings))
230
+ {
231
+ wix.OutputXml(xmlWriter);
232
+ }
233
+
234
+ wixString = stringWriter.ToString();
235
+ }
236
+
237
+ string mutatedWixString = heatCore.Mutator.Mutate(wixString);
238
+ if (String.IsNullOrEmpty(mutatedWixString))
239
+ {
240
+ return this.Messaging.LastErrorNumber;
241
+ }
242
+
243
+ Directory.CreateDirectory(Path.GetDirectoryName(this.OutputFile));
244
+
245
+ using (StreamWriter streamWriter = new StreamWriter(this.OutputFile, false, System.Text.Encoding.UTF8))
246
+ {
247
+ xmlSettings.OmitXmlDeclaration = false;
248
+ xmlSettings.Encoding = System.Text.Encoding.UTF8;
249
+ using (XmlWriter xmlWriter = XmlWriter.Create(streamWriter, xmlSettings))
250
+ {
251
+ xmlWriter.WriteStartDocument();
252
+ xmlWriter.Flush();
253
+ }
254
+
255
+ streamWriter.WriteLine();
256
+ streamWriter.Write(mutatedWixString);
257
+ }
258
+ }
259
+ catch (WixException we)
260
+ {
261
+ this.Messaging.Write(we.Error);
262
+ }
263
+ catch (Exception e)
264
+ {
265
+ this.Messaging.Write(ErrorMessages.UnexpectedException(e));
266
+ if (e is NullReferenceException || e is SEHException)
267
+ {
268
+ throw;
269
+ }
270
+ }
271
+
272
+ return this.Messaging.LastErrorNumber;
273
+ }
274
+ }
275
+}
src/heat/HeatCommandLine.cs
new
+91
@@ -0,0 +1,91 @@
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.Harvesters
4
+{
5
+ using System;
6
+ using System.Collections.Generic;
7
+ using System.Linq;
8
+ using WixToolset.Data;
9
+ using WixToolset.Extensibility.Data;
10
+ using WixToolset.Extensibility.Services;
11
+ using WixToolset.Harvesters.Data;
12
+ using WixToolset.Harvesters.Extensibility;
13
+
14
+ internal class HeatCommandLine : IHeatCommandLine
15
+ {
16
+ private readonly List<IHeatExtension> extensions;
17
+ private readonly IMessaging messaging;
18
+ private readonly IServiceProvider serviceProvider;
19
+
20
+ public HeatCommandLine(IServiceProvider serviceProvider, IEnumerable<IHeatExtension> heatExtensions)
21
+ {
22
+ this.extensions = new List<IHeatExtension> { new IIsHeatExtension(), new UtilHeatExtension(serviceProvider), new VSHeatExtension() };
23
+ if (heatExtensions != null)
24
+ {
25
+ this.extensions.AddRange(heatExtensions);
26
+ }
27
+ this.messaging = serviceProvider.GetService<IMessaging>();
28
+ this.serviceProvider = serviceProvider;
29
+ }
30
+
31
+ public ICommandLineCommand ParseStandardCommandLine(ICommandLineArguments arguments)
32
+ {
33
+ ICommandLineCommand command = null;
34
+ var parser = arguments.Parse();
35
+
36
+ while (command?.StopParsing != true &&
37
+ String.IsNullOrEmpty(parser.ErrorArgument) &&
38
+ parser.TryGetNextSwitchOrArgument(out var arg))
39
+ {
40
+ if (String.IsNullOrWhiteSpace(arg)) // skip blank arguments.
41
+ {
42
+ continue;
43
+ }
44
+
45
+ // First argument must be the command or global switch (that creates a command).
46
+ if (command == null)
47
+ {
48
+ if (!this.TryParseUnknownCommandArg(arg, parser, out command))
49
+ {
50
+ parser.ReportErrorArgument(arg, ErrorMessages.HarvestTypeNotFound(arg));
51
+ }
52
+ }
53
+ else if (!command.TryParseArgument(parser, arg))
54
+ {
55
+ parser.ReportErrorArgument(arg);
56
+ }
57
+ }
58
+
59
+ return command ?? new HelpCommand(this.extensions);
60
+ }
61
+
62
+ public bool TryParseUnknownCommandArg(string arg, ICommandLineParser parser, out ICommandLineCommand command)
63
+ {
64
+ command = null;
65
+
66
+ if (parser.IsSwitch(arg))
67
+ {
68
+ var parameter = arg.Substring(1);
69
+ switch (parameter.ToLowerInvariant())
70
+ {
71
+ case "?":
72
+ case "h":
73
+ case "help":
74
+ command = new HelpCommand(this.extensions);
75
+ return true;
76
+ }
77
+ }
78
+
79
+ foreach (var heatExtension in this.extensions)
80
+ {
81
+ if (heatExtension.CommandLineTypes.Any(o => o.Option == arg))
82
+ {
83
+ command = new HeatCommand(arg, this.extensions, this.serviceProvider);
84
+ return true;
85
+ }
86
+ }
87
+
88
+ return false;
89
+ }
90
+ }
91
+}
src/heat/HeatCommandLineFactory.cs
new
+27
@@ -0,0 +1,27 @@
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.Harvesters
4
+{
5
+ using System;
6
+ using System.Collections.Generic;
7
+ using WixToolset.Extensibility.Services;
8
+ using WixToolset.Harvesters.Data;
9
+ using WixToolset.Harvesters.Extensibility;
10
+
11
+ /// <summary>
12
+ /// Extension methods to use Harvesters services.
13
+ /// </summary>
14
+ public class HeatCommandLineFactory
15
+ {
16
+ /// <summary>
17
+ /// Creates <see cref="IHeatCommandLine"/> service.
18
+ /// </summary>
19
+ /// <param name="serviceProvider"></param>
20
+ /// <param name="heatExtensions"></param>
21
+ /// <returns></returns>
22
+ public static IHeatCommandLine CreateCommandLine(IServiceProvider serviceProvider, IEnumerable<IHeatExtension> heatExtensions = null)
23
+ {
24
+ return new HeatCommandLine(serviceProvider, heatExtensions);
25
+ }
26
+ }
27
+}
src/heat/HeatCore.cs
new
+45
@@ -0,0 +1,45 @@
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.Harvesters
4
+{
5
+ using System;
6
+ using WixToolset.Extensibility.Services;
7
+ using WixToolset.Harvesters.Extensibility;
8
+
9
+ /// <summary>
10
+ /// The WiX Toolset Harvester application core.
11
+ /// </summary>
12
+ internal class HeatCore : IHeatCore
13
+ {
14
+ /// <summary>
15
+ /// Instantiates a new HeatCore.
16
+ /// </summary>
17
+ /// <param name="serviceProvider">The service provider.</param>
18
+ /// <param name="extensionArgument">The extension argument.</param>
19
+ public HeatCore(IServiceProvider serviceProvider, string extensionArgument)
20
+ {
21
+ this.Messaging = serviceProvider.GetService<IMessaging>();
22
+ var harvesterCore = new HarvesterCore
23
+ {
24
+ ExtensionArgument = extensionArgument,
25
+ Messaging = this.Messaging,
26
+ ParseHelper = serviceProvider.GetService<IParseHelper>(),
27
+ };
28
+
29
+ this.Harvester = new Harvester
30
+ {
31
+ Core = harvesterCore,
32
+ };
33
+ this.Mutator = new Mutator
34
+ {
35
+ Core = harvesterCore,
36
+ };
37
+ }
38
+
39
+ public IHarvester Harvester { get; }
40
+
41
+ public IMessaging Messaging { get; }
42
+
43
+ public IMutator Mutator { get; }
44
+ }
45
+}
src/heat/HelpCommand.cs
new
+97
@@ -0,0 +1,97 @@
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.Harvesters
4
+{
5
+ using System;
6
+ using System.Collections;
7
+ using System.Collections.Generic;
8
+ using System.Diagnostics;
9
+ using System.Threading;
10
+ using System.Threading.Tasks;
11
+ using WixToolset.Extensibility.Data;
12
+ using WixToolset.Extensibility.Services;
13
+ using WixToolset.Harvesters.Data;
14
+ using WixToolset.Harvesters.Extensibility;
15
+
16
+ internal class HelpCommand : ICommandLineCommand
17
+ {
18
+ const string HelpMessageOptionFormat = " {0,-7} {1}";
19
+
20
+ public HelpCommand(IList<IHeatExtension> extensions)
21
+ {
22
+ this.Extensions = extensions;
23
+ }
24
+
25
+ private IList<IHeatExtension> Extensions { get; }
26
+
27
+ public bool ShowLogo => false;
28
+
29
+ public bool StopParsing => true;
30
+
31
+ public Task<int> ExecuteAsync(CancellationToken cancellationToken)
32
+ {
33
+ var exitCode = this.DisplayHelp();
34
+ return Task.FromResult(exitCode);
35
+ }
36
+
37
+ public static void DisplayToolHeader()
38
+ {
39
+ var wixcopAssembly = typeof(HelpCommand).Assembly;
40
+ var fv = FileVersionInfo.GetVersionInfo(wixcopAssembly.Location);
41
+
42
+ Console.WriteLine("WiX Toolset Harvester version {0}", fv.FileVersion);
43
+ Console.WriteLine("Copyright (C) .NET Foundation and contributors. All rights reserved.");
44
+ Console.WriteLine();
45
+ }
46
+
47
+ public bool TryParseArgument(ICommandLineParser parser, string argument) => true;
48
+
49
+ private int DisplayHelp()
50
+ {
51
+ DisplayToolHeader();
52
+
53
+ // output the harvest types alphabetically
54
+ SortedList harvestOptions = new SortedList();
55
+ foreach (var heatExtension in this.Extensions)
56
+ {
57
+ foreach (HeatCommandLineOption commandLineOption in heatExtension.CommandLineTypes)
58
+ {
59
+ harvestOptions.Add(commandLineOption.Option, commandLineOption);
60
+ }
61
+ }
62
+
63
+ harvestOptions.Add("-nologo", new HeatCommandLineOption("-nologo", "skip printing heat logo information"));
64
+ harvestOptions.Add("-indent <N>", new HeatCommandLineOption("-indent <N>", "indentation multiple (overrides default of 4)"));
65
+ harvestOptions.Add("-o[ut]", new HeatCommandLineOption("-out", "specify output file (default: write to current directory)"));
66
+ harvestOptions.Add("-sw<N>", new HeatCommandLineOption("-sw<N>", "suppress all warnings or a specific message ID\r\n (example: -sw1011 -sw1012)"));
67
+ harvestOptions.Add("-swall", new HeatCommandLineOption("-swall", "suppress all warnings (deprecated)"));
68
+ harvestOptions.Add("-v", new HeatCommandLineOption("-v", "verbose output"));
69
+ harvestOptions.Add("-wx[N]", new HeatCommandLineOption("-wx[N]", "treat all warnings or a specific message ID as an error\r\n (example: -wx1011 -wx1012)"));
70
+ harvestOptions.Add("-wxall", new HeatCommandLineOption("-wxall", "treat all warnings as errors (deprecated)"));
71
+
72
+ foreach (HeatCommandLineOption commandLineOption in harvestOptions.Values)
73
+ {
74
+ if (!commandLineOption.Option.StartsWith("-"))
75
+ {
76
+ Console.WriteLine(HelpMessageOptionFormat, commandLineOption.Option, commandLineOption.Description);
77
+ }
78
+ }
79
+
80
+ Console.WriteLine();
81
+ Console.WriteLine("Options:");
82
+
83
+ foreach (HeatCommandLineOption commandLineOption in harvestOptions.Values)
84
+ {
85
+ if (commandLineOption.Option.StartsWith("-"))
86
+ {
87
+ Console.WriteLine(HelpMessageOptionFormat, commandLineOption.Option, commandLineOption.Description);
88
+ }
89
+ }
90
+
91
+ Console.WriteLine(HelpMessageOptionFormat, "-? | -help", "this help information");
92
+ Console.WriteLine("For more information see: https://wixtoolset.org/");
93
+
94
+ return 0;
95
+ }
96
+ }
97
+}
src/heat/IIsFinalizeHarvesterMutator.cs
new
+160
@@ -0,0 +1,160 @@
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.Harvesters
4
+{
5
+ using System;
6
+ using System.Collections;
7
+ using System.Collections.Specialized;
8
+ using WixToolset.Harvesters.Data;
9
+ using WixToolset.Harvesters.Extensibility;
10
+ using Wix = WixToolset.Harvesters.Serialize;
11
+ using IIs = Serialize.IIs;
12
+
13
+ /// <summary>
14
+ /// The finalize harvester mutator for the WiX Toolset Internet Information Services Extension.
15
+ /// </summary>
16
+ internal class IIsFinalizeHarvesterMutator : BaseMutatorExtension
17
+ {
18
+ private Hashtable directoryPaths;
19
+ private Hashtable filePaths;
20
+ private ArrayList webFilters;
21
+ private ArrayList webSites;
22
+ private ArrayList webVirtualDirs;
23
+
24
+ /// <summary>
25
+ /// Instantiate a new IIsFinalizeHarvesterMutator.
26
+ /// </summary>
27
+ public IIsFinalizeHarvesterMutator()
28
+ {
29
+ this.directoryPaths = CollectionsUtil.CreateCaseInsensitiveHashtable();
30
+ this.filePaths = CollectionsUtil.CreateCaseInsensitiveHashtable();
31
+ this.webFilters = new ArrayList();
32
+ this.webSites = new ArrayList();
33
+ this.webVirtualDirs = new ArrayList();
34
+ }
35
+
36
+ /// <summary>
37
+ /// Gets the sequence of this mutator extension.
38
+ /// </summary>
39
+ /// <value>The sequence of this mutator extension.</value>
40
+ public override int Sequence
41
+ {
42
+ get { return 1900; }
43
+ }
44
+
45
+ /// <summary>
46
+ /// Mutate a WiX document.
47
+ /// </summary>
48
+ /// <param name="wix">The Wix document element.</param>
49
+ public override void Mutate(Wix.Wix wix)
50
+ {
51
+ this.directoryPaths.Clear();
52
+ this.filePaths.Clear();
53
+ this.webFilters.Clear();
54
+ this.webSites.Clear();
55
+ this.webVirtualDirs.Clear();
56
+
57
+ this.IndexElement(wix);
58
+
59
+ this.MutateWebFilters();
60
+ this.MutateWebSites();
61
+ this.MutateWebVirtualDirs();
62
+ }
63
+
64
+ /// <summary>
65
+ /// Index an element.
66
+ /// </summary>
67
+ /// <param name="element">The element to index.</param>
68
+ private void IndexElement(Wix.ISchemaElement element)
69
+ {
70
+ if (element is IIs.WebFilter)
71
+ {
72
+ this.webFilters.Add(element);
73
+ }
74
+ else if (element is IIs.WebSite)
75
+ {
76
+ this.webSites.Add(element);
77
+ }
78
+ else if (element is IIs.WebVirtualDir)
79
+ {
80
+ this.webVirtualDirs.Add(element);
81
+ }
82
+ else if (element is Wix.Directory)
83
+ {
84
+ Wix.Directory directory = (Wix.Directory)element;
85
+
86
+ if (null != directory.Id && null != directory.FileSource)
87
+ {
88
+ this.directoryPaths.Add(directory.FileSource, directory.Id);
89
+ }
90
+ }
91
+ else if (element is Wix.File)
92
+ {
93
+ Wix.File file = (Wix.File)element;
94
+
95
+ if (null != file.Id && null != file.Source)
96
+ {
97
+ this.filePaths[file.Source] = String.Concat("[#", file.Id, "]");
98
+ }
99
+ }
100
+
101
+ // index the child elements
102
+ if (element is Wix.IParentElement)
103
+ {
104
+ foreach (Wix.ISchemaElement childElement in ((Wix.IParentElement)element).Children)
105
+ {
106
+ this.IndexElement(childElement);
107
+ }
108
+ }
109
+ }
110
+
111
+ /// <summary>
112
+ /// Mutate the WebFilters.
113
+ /// </summary>
114
+ private void MutateWebFilters()
115
+ {
116
+ foreach (IIs.WebFilter webFilter in this.webFilters)
117
+ {
118
+ webFilter.Path = (string)this.filePaths[webFilter.Path];
119
+ }
120
+ }
121
+
122
+ /// <summary>
123
+ /// Mutate the WebSites.
124
+ /// </summary>
125
+ private void MutateWebSites()
126
+ {
127
+ foreach (IIs.WebSite webSite in this.webSites)
128
+ {
129
+ string path = (string)this.directoryPaths[webSite.Directory];
130
+ if (null == path)
131
+ {
132
+ this.Core.Messaging.Write(HarvesterWarnings.EncounteredNullDirectoryForWebSite(path));
133
+ }
134
+ else
135
+ {
136
+ webSite.Directory = path;
137
+ }
138
+ }
139
+ }
140
+
141
+ /// <summary>
142
+ /// Mutate the WebVirtualDirs.
143
+ /// </summary>
144
+ private void MutateWebVirtualDirs()
145
+ {
146
+ foreach (IIs.WebVirtualDir webVirtualDir in this.webVirtualDirs)
147
+ {
148
+ string path = (string)this.directoryPaths[webVirtualDir.Directory];
149
+ if (null == path)
150
+ {
151
+ this.Core.Messaging.Write(HarvesterWarnings.EncounteredNullDirectoryForWebSite(path));
152
+ }
153
+ else
154
+ {
155
+ webVirtualDir.Directory = path;
156
+ }
157
+ }
158
+ }
159
+ }
160
+}
src/heat/IIsHarvesterMutator.cs
new
+429
@@ -0,0 +1,429 @@
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.Harvesters
4
+{
5
+ using System;
6
+ using System.Collections;
7
+ using System.Collections.Specialized;
8
+ using System.IO;
9
+ using WixToolset.Harvesters.Extensibility;
10
+ using IIs = Serialize.IIs;
11
+ using Wix = WixToolset.Harvesters.Serialize;
12
+
13
+ /// <summary>
14
+ /// The harvester mutator for the WiX Toolset Internet Information Services Extension.
15
+ /// </summary>
16
+ internal class IIsHarvesterMutator : BaseMutatorExtension
17
+ {
18
+ private ArrayList components;
19
+ private DirectoryHarvester directoryHarvester;
20
+ private Hashtable directoryPaths;
21
+ private FileHarvester fileHarvester;
22
+ private Wix.IParentElement rootElement;
23
+ private bool setUniqueIdentifiers;
24
+ private ArrayList webAddresses;
25
+ private ArrayList webDirs;
26
+ private ArrayList webDirProperties;
27
+ private ArrayList webFilters;
28
+ private ArrayList webSites;
29
+ private ArrayList webVirtualDirs;
30
+
31
+ /// <summary>
32
+ /// Instantiate a new IIsHarvesterMutator.
33
+ /// </summary>
34
+ public IIsHarvesterMutator()
35
+ {
36
+ this.components = new ArrayList();
37
+ this.directoryHarvester = new DirectoryHarvester();
38
+ this.directoryPaths = CollectionsUtil.CreateCaseInsensitiveHashtable();
39
+ this.fileHarvester = new FileHarvester();
40
+ this.webAddresses = new ArrayList();
41
+ this.webDirs = new ArrayList();
42
+ this.webDirProperties = new ArrayList();
43
+ this.webFilters = new ArrayList();
44
+ this.webSites = new ArrayList();
45
+ this.webVirtualDirs = new ArrayList();
46
+ }
47
+
48
+ /// <summary>
49
+ /// Gets the sequence of this mutator extension.
50
+ /// </summary>
51
+ /// <value>The sequence of this mutator extension.</value>
52
+ public override int Sequence
53
+ {
54
+ get { return 100; }
55
+ }
56
+
57
+ /// <summary>
58
+ /// Gets of sets the option to set unique identifiers.
59
+ /// </summary>
60
+ /// <value>The option to set unique identifiers.</value>
61
+ public bool SetUniqueIdentifiers
62
+ {
63
+ get { return this.setUniqueIdentifiers; }
64
+ set { this.setUniqueIdentifiers = value; }
65
+ }
66
+
67
+ /// <summary>
68
+ /// Mutate a WiX document.
69
+ /// </summary>
70
+ /// <param name="wix">The Wix document element.</param>
71
+ public override void Mutate(Wix.Wix wix)
72
+ {
73
+ this.components.Clear();
74
+ this.directoryPaths.Clear();
75
+ this.webAddresses.Clear();
76
+ this.webDirs.Clear();
77
+ this.webDirProperties.Clear();
78
+ this.webFilters.Clear();
79
+ this.webSites.Clear();
80
+ this.webVirtualDirs.Clear();
81
+ this.rootElement = null;
82
+
83
+ this.IndexElement(wix);
84
+
85
+ this.MutateWebAddresses();
86
+
87
+ this.MutateWebDirs();
88
+
89
+ this.MutateWebDirProperties();
90
+
91
+ this.MutateWebSites();
92
+
93
+ this.MutateWebVirtualDirs();
94
+
95
+ // this must come after the web virtual dirs in case they harvest a directory containing a web filter file
96
+ this.MutateWebFilters();
97
+
98
+ // this must come after the web site identifiers are created
99
+ this.MutateComponents();
100
+ }
101
+
102
+ /// <summary>
103
+ /// Harvest a new directory or return one that was previously harvested.
104
+ /// </summary>
105
+ /// <param name="path">The path of the directory.</param>
106
+ /// <param name="harvestChildren">The option to harvest the children of the directory.</param>
107
+ /// <returns>The harvested directory.</returns>
108
+ private Wix.Directory HarvestUniqueDirectory(string path, bool harvestChildren)
109
+ {
110
+ if (this.directoryPaths.Contains(path))
111
+ {
112
+ return (Wix.Directory)this.directoryPaths[path];
113
+ }
114
+ else
115
+ {
116
+ Wix.Directory directory = this.directoryHarvester.HarvestDirectory(path, harvestChildren);
117
+
118
+ this.rootElement.AddChild(directory);
119
+
120
+ // index this new directory and all of its children
121
+ this.IndexElement(directory);
122
+
123
+ return directory;
124
+ }
125
+ }
126
+
127
+ /// <summary>
128
+ /// Index an element.
129
+ /// </summary>
130
+ /// <param name="element">The element to index.</param>
131
+ private void IndexElement(Wix.ISchemaElement element)
132
+ {
133
+ if (element is IIs.WebAddress)
134
+ {
135
+ this.webAddresses.Add(element);
136
+ }
137
+ else if (element is IIs.WebDir)
138
+ {
139
+ this.webDirs.Add(element);
140
+ }
141
+ else if (element is IIs.WebDirProperties)
142
+ {
143
+ this.webDirProperties.Add(element);
144
+ }
145
+ else if (element is IIs.WebFilter)
146
+ {
147
+ this.webFilters.Add(element);
148
+ }
149
+ else if (element is IIs.WebSite)
150
+ {
151
+ this.webSites.Add(element);
152
+ }
153
+ else if (element is IIs.WebVirtualDir)
154
+ {
155
+ this.webVirtualDirs.Add(element);
156
+ }
157
+ else if (element is Wix.Component)
158
+ {
159
+ this.components.Add(element);
160
+ }
161
+ else if (element is Wix.Directory)
162
+ {
163
+ Wix.Directory directory = (Wix.Directory)element;
164
+
165
+ if (null != directory.FileSource)
166
+ {
167
+ this.directoryPaths.Add(directory.FileSource, directory);
168
+ }
169
+ }
170
+ else if (element is Wix.Fragment || element is Wix.Module || element is Wix.PatchCreation || element is Wix.Package)
171
+ {
172
+ this.rootElement = (Wix.IParentElement)element;
173
+ }
174
+
175
+ // index the child elements
176
+ if (element is Wix.IParentElement)
177
+ {
178
+ foreach (Wix.ISchemaElement childElement in ((Wix.IParentElement)element).Children)
179
+ {
180
+ this.IndexElement(childElement);
181
+ }
182
+ }
183
+ }
184
+
185
+ /// <summary>
186
+ /// Mutate the Component elements.
187
+ /// </summary>
188
+ private void MutateComponents()
189
+ {
190
+ if (this.setUniqueIdentifiers)
191
+ {
192
+ IdentifierGenerator identifierGenerator = new IdentifierGenerator("Component", this.Core);
193
+
194
+ // index all the existing identifiers
195
+ foreach (Wix.Component component in this.components)
196
+ {
197
+ if (null != component.Id)
198
+ {
199
+ identifierGenerator.IndexExistingIdentifier(component.Id);
200
+ }
201
+ }
202
+
203
+ // index all the web site identifiers
204
+ foreach (IIs.WebSite webSite in this.webSites)
205
+ {
206
+ if (webSite.ParentElement is Wix.Component)
207
+ {
208
+ identifierGenerator.IndexName(webSite.Id);
209
+ }
210
+ }
211
+
212
+ // create an identifier for each component based on its child web site identifier
213
+ foreach (IIs.WebSite webSite in this.webSites)
214
+ {
215
+ Wix.Component component = webSite.ParentElement as Wix.Component;
216
+
217
+ if (null != component)
218
+ {
219
+ component.Id = identifierGenerator.GetIdentifier(webSite.Id);
220
+ }
221
+ }
222
+ }
223
+ }
224
+
225
+ /// <summary>
226
+ /// Mutate the WebAddress elements.
227
+ /// </summary>
228
+ private void MutateWebAddresses()
229
+ {
230
+ if (this.setUniqueIdentifiers)
231
+ {
232
+ IdentifierGenerator identifierGenerator = new IdentifierGenerator("WebAddress", this.Core);
233
+
234
+ // index all the existing identifiers and names
235
+ foreach (IIs.WebAddress webAddress in this.webAddresses)
236
+ {
237
+ if (null != webAddress.Id)
238
+ {
239
+ identifierGenerator.IndexExistingIdentifier(webAddress.Id);
240
+ }
241
+ else
242
+ {
243
+ identifierGenerator.IndexName(String.Concat(webAddress.IP, "_", webAddress.Port));
244
+ }
245
+ }
246
+
247
+ foreach (IIs.WebAddress webAddress in this.webAddresses)
248
+ {
249
+ if (null == webAddress.Id)
250
+ {
251
+ webAddress.Id = identifierGenerator.GetIdentifier(String.Concat(webAddress.IP, "_", webAddress.Port));
252
+ }
253
+ }
254
+ }
255
+ }
256
+
257
+ /// <summary>
258
+ /// Mutate the WebDir elements.
259
+ /// </summary>
260
+ private void MutateWebDirs()
261
+ {
262
+ if (this.setUniqueIdentifiers)
263
+ {
264
+ IdentifierGenerator identifierGenerator = new IdentifierGenerator("WebDir", this.Core);
265
+
266
+ // index all the existing identifiers and names
267
+ foreach (IIs.WebDir webDir in this.webDirs)
268
+ {
269
+ if (null != webDir.Id)
270
+ {
271
+ identifierGenerator.IndexExistingIdentifier(webDir.Id);
272
+ }
273
+ else
274
+ {
275
+ identifierGenerator.IndexName(webDir.Path);
276
+ }
277
+ }
278
+
279
+ foreach (IIs.WebDir webDir in this.webDirs)
280
+ {
281
+ if (null == webDir.Id)
282
+ {
283
+ webDir.Id = identifierGenerator.GetIdentifier(webDir.Path);
284
+ }
285
+ }
286
+ }
287
+ }
288
+
289
+ /// <summary>
290
+ /// Mutate the WebDirProperties elements.
291
+ /// </summary>
292
+ private void MutateWebDirProperties()
293
+ {
294
+ if (this.setUniqueIdentifiers)
295
+ {
296
+ IdentifierGenerator identifierGenerator = new IdentifierGenerator("WebDirProperties", this.Core);
297
+
298
+ // index all the existing identifiers and names
299
+ foreach (IIs.WebDirProperties webDirProperties in this.webDirProperties)
300
+ {
301
+ if (null != webDirProperties.Id)
302
+ {
303
+ identifierGenerator.IndexExistingIdentifier(webDirProperties.Id);
304
+ }
305
+ }
306
+
307
+ foreach (IIs.WebDirProperties webDirProperties in this.webDirProperties)
308
+ {
309
+ if (null == webDirProperties.Id)
310
+ {
311
+ webDirProperties.Id = identifierGenerator.GetIdentifier(String.Empty);
312
+ }
313
+ }
314
+ }
315
+ }
316
+
317
+ /// <summary>
318
+ /// Mutate the WebFilter elements.
319
+ /// </summary>
320
+ private void MutateWebFilters()
321
+ {
322
+ IdentifierGenerator identifierGenerator = null;
323
+
324
+ if (this.setUniqueIdentifiers)
325
+ {
326
+ identifierGenerator = new IdentifierGenerator("WebFilter", this.Core);
327
+
328
+ // index all the existing identifiers and names
329
+ foreach (IIs.WebFilter webFilter in this.webFilters)
330
+ {
331
+ if (null != webFilter.Id)
332
+ {
333
+ identifierGenerator.IndexExistingIdentifier(webFilter.Id);
334
+ }
335
+ else
336
+ {
337
+ identifierGenerator.IndexName(webFilter.Name);
338
+ }
339
+ }
340
+ }
341
+
342
+ foreach (IIs.WebFilter webFilter in this.webFilters)
343
+ {
344
+ if (this.setUniqueIdentifiers && null == webFilter.Id)
345
+ {
346
+ webFilter.Id = identifierGenerator.GetIdentifier(webFilter.Name);
347
+ }
348
+
349
+ // harvest the file for this WebFilter
350
+ Wix.Directory directory = this.HarvestUniqueDirectory(Path.GetDirectoryName(webFilter.Path), false);
351
+
352
+ Wix.Component component = new Wix.Component();
353
+ directory.AddChild(component);
354
+
355
+ Wix.File file = this.fileHarvester.HarvestFile(webFilter.Path);
356
+ component.AddChild(file);
357
+ }
358
+ }
359
+
360
+ /// <summary>
361
+ /// Mutate the WebSite elements.
362
+ /// </summary>
363
+ private void MutateWebSites()
364
+ {
365
+ if (this.setUniqueIdentifiers)
366
+ {
367
+ IdentifierGenerator identifierGenerator = new IdentifierGenerator("WebSite", this.Core);
368
+
369
+ // index all the existing identifiers and names
370
+ foreach (IIs.WebSite webSite in this.webSites)
371
+ {
372
+ if (null != webSite.Id)
373
+ {
374
+ identifierGenerator.IndexExistingIdentifier(webSite.Id);
375
+ }
376
+ else
377
+ {
378
+ identifierGenerator.IndexName(webSite.Description);
379
+ }
380
+ }
381
+
382
+ foreach (IIs.WebSite webSite in this.webSites)
383
+ {
384
+ if (null == webSite.Id)
385
+ {
386
+ webSite.Id = identifierGenerator.GetIdentifier(webSite.Description);
387
+ }
388
+ }
389
+ }
390
+ }
391
+
392
+ /// <summary>
393
+ /// Mutate the WebVirtualDir elements.
394
+ /// </summary>
395
+ private void MutateWebVirtualDirs()
396
+ {
397
+ IdentifierGenerator identifierGenerator = null;
398
+
399
+ if (this.setUniqueIdentifiers)
400
+ {
401
+ identifierGenerator = new IdentifierGenerator("WebVirtualDir", this.Core);
402
+
403
+ // index all the existing identifiers and names
404
+ foreach (IIs.WebVirtualDir webVirtualDir in this.webVirtualDirs)
405
+ {
406
+ if (null != webVirtualDir.Id)
407
+ {
408
+ identifierGenerator.IndexExistingIdentifier(webVirtualDir.Id);
409
+ }
410
+ else
411
+ {
412
+ identifierGenerator.IndexName(webVirtualDir.Alias);
413
+ }
414
+ }
415
+ }
416
+
417
+ foreach (IIs.WebVirtualDir webVirtualDir in this.webVirtualDirs)
418
+ {
419
+ if (this.setUniqueIdentifiers && null == webVirtualDir.Id)
420
+ {
421
+ webVirtualDir.Id = identifierGenerator.GetIdentifier(webVirtualDir.Alias);
422
+ }
423
+
424
+ // harvest the directory for this WebVirtualDir
425
+ this.HarvestUniqueDirectory(webVirtualDir.Directory, true);
426
+ }
427
+ }
428
+ }
429
+}
src/heat/IIsHeatExtension.cs
new
+80
@@ -0,0 +1,80 @@
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.Harvesters
4
+{
5
+ using WixToolset.Harvesters.Data;
6
+ using WixToolset.Harvesters.Extensibility;
7
+
8
+ /// <summary>
9
+ /// An IIS harvesting extension for the WiX Toolset Harvester application.
10
+ /// </summary>
11
+ internal class IIsHeatExtension : BaseHeatExtension
12
+ {
13
+ /// <summary>
14
+ /// Gets the supported command line types for this extension.
15
+ /// </summary>
16
+ /// <value>The supported command line types for this extension.</value>
17
+ public override HeatCommandLineOption[] CommandLineTypes
18
+ {
19
+ get
20
+ {
21
+ return new HeatCommandLineOption[]
22
+ {
23
+ new HeatCommandLineOption("website", "harvest an IIS web site"),
24
+ };
25
+ }
26
+ }
27
+
28
+ /// <summary>
29
+ /// Parse the command line options for this extension.
30
+ /// </summary>
31
+ /// <param name="type">The active harvester type.</param>
32
+ /// <param name="args">The option arguments.</param>
33
+ public override void ParseOptions(string type, string[] args)
34
+ {
35
+ bool active = false;
36
+ IHarvesterExtension harvesterExtension = null;
37
+ IIsHarvesterMutator iisHarvesterMutator = new IIsHarvesterMutator();
38
+
39
+ // select the harvester
40
+ switch (type)
41
+ {
42
+ case "website":
43
+ harvesterExtension = new IIsWebSiteHarvester();
44
+ active = true;
45
+ break;
46
+ }
47
+
48
+ // set default settings
49
+ iisHarvesterMutator.SetUniqueIdentifiers = true;
50
+
51
+ // parse the options
52
+ foreach (string arg in args)
53
+ {
54
+ if (null == arg || 0 == arg.Length) // skip blank arguments
55
+ {
56
+ continue;
57
+ }
58
+
59
+ if ('-' == arg[0] || '/' == arg[0])
60
+ {
61
+ string parameter = arg.Substring(1);
62
+
63
+ if ("suid" == parameter)
64
+ {
65
+ iisHarvesterMutator.SetUniqueIdentifiers = false;
66
+ }
67
+ }
68
+ }
69
+
70
+ // set the appropriate harvester extension
71
+ if (active)
72
+ {
73
+ this.Core.Harvester.Extension = harvesterExtension;
74
+ this.Core.Mutator.AddExtension(iisHarvesterMutator);
75
+ this.Core.Mutator.AddExtension(new IIsFinalizeHarvesterMutator());
76
+ this.Core.Mutator.AddExtension(new UtilFinalizeHarvesterMutator());
77
+ }
78
+ }
79
+ }
80
+}
src/heat/IIsWebSiteHarvester.cs
new
+439
@@ -0,0 +1,439 @@
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.Harvesters
4
+{
5
+ using System;
6
+ using System.DirectoryServices;
7
+ using System.Globalization;
8
+ using System.Runtime.InteropServices;
9
+ using WixToolset.Data;
10
+ using WixToolset.Harvesters.Data;
11
+ using WixToolset.Harvesters.Extensibility;
12
+ using IIs = WixToolset.Harvesters.Serialize.IIs;
13
+ using Wix = WixToolset.Harvesters.Serialize;
14
+
15
+ /// <summary>
16
+ /// The web site harvester for the WiX Toolset Internet Information Services Extension.
17
+ /// </summary>
18
+ internal class IIsWebSiteHarvester : BaseHarvesterExtension
19
+ {
20
+ /// <summary>
21
+ /// Harvest a WiX document.
22
+ /// </summary>
23
+ /// <param name="argument">The argument for harvesting.</param>
24
+ /// <returns>The harvested Fragment.</returns>
25
+ public override Wix.Fragment[] Harvest(string argument)
26
+ {
27
+ DirectoryHarvester directoryHarvester = new DirectoryHarvester();
28
+ directoryHarvester.Core = this.Core;
29
+ directoryHarvester.KeepEmptyDirectories = true;
30
+
31
+ IIsWebSiteHarvester iisWebSiteHarvester = new IIsWebSiteHarvester();
32
+ iisWebSiteHarvester.Core = this.Core;
33
+
34
+ IIs.WebSite webSite = iisWebSiteHarvester.HarvestWebSite(argument);
35
+
36
+ Wix.Component component = new Wix.Component();
37
+ component.AddChild(new Wix.CreateFolder());
38
+ component.AddChild(webSite);
39
+
40
+ this.Core.RootDirectory = webSite.Directory;
41
+ Wix.Directory directory = directoryHarvester.HarvestDirectory(webSite.Directory, true);
42
+ directory.AddChild(component);
43
+
44
+ Wix.Fragment fragment = new Wix.Fragment();
45
+ fragment.AddChild(directory);
46
+
47
+ return new Wix.Fragment[] { fragment };
48
+ }
49
+
50
+ /// <summary>
51
+ /// Harvest a web site.
52
+ /// </summary>
53
+ /// <param name="name">The name of the web site.</param>
54
+ /// <returns>The harvested web site.</returns>
55
+ public IIs.WebSite HarvestWebSite(string name)
56
+ {
57
+ try
58
+ {
59
+ DirectoryEntry directoryEntry = new DirectoryEntry("IIS://localhost/W3SVC");
60
+
61
+ foreach (DirectoryEntry childEntry in directoryEntry.Children)
62
+ {
63
+ if ("IIsWebServer" == childEntry.SchemaClassName)
64
+ {
65
+ if (String.Equals((string)childEntry.Properties["ServerComment"].Value, name, StringComparison.OrdinalIgnoreCase))
66
+ {
67
+ return this.HarvestWebSite(childEntry);
68
+ }
69
+ }
70
+ }
71
+ }
72
+ catch (COMException ce)
73
+ {
74
+ // 0x8007005 - access denied
75
+ // If we don't have permission to harvest a website, it's likely because we're on
76
+ // Vista or higher and aren't an Admin.
77
+ if ((0x80070005 == unchecked((uint)ce.ErrorCode)))
78
+ {
79
+ throw new WixException(HarvesterErrors.InsufficientPermissionHarvestWebSite());
80
+ }
81
+ // 0x80005000 - unknown error
82
+ else if ((0x80005000 == unchecked((uint)ce.ErrorCode)))
83
+ {
84
+ throw new WixException(HarvesterErrors.CannotHarvestWebSite());
85
+ }
86
+ }
87
+
88
+ throw new WixException(HarvesterErrors.WebSiteNotFound(name));
89
+ }
90
+
91
+ /// <summary>
92
+ /// Harvest a web site.
93
+ /// </summary>
94
+ /// <param name="webSiteEntry">The web site directory entry.</param>
95
+ /// <returns>The harvested web site.</returns>
96
+ private IIs.WebSite HarvestWebSite(DirectoryEntry webSiteEntry)
97
+ {
98
+ IIs.WebSite webSite = new IIs.WebSite();
99
+
100
+ foreach (string propertyName in webSiteEntry.Properties.PropertyNames)
101
+ {
102
+ PropertyValueCollection property = webSiteEntry.Properties[propertyName];
103
+ PropertyValueCollection parentProperty = webSiteEntry.Parent.Properties[propertyName];
104
+
105
+ if (null == parentProperty.Value || parentProperty.Value.ToString() != property.Value.ToString())
106
+ {
107
+ switch (propertyName)
108
+ {
109
+ case "SecureBindings":
110
+ IIs.WebAddress secureWebAddress = this.HarvestBindings(propertyName, property);
111
+ if (null != secureWebAddress)
112
+ {
113
+ webSite.AddChild(secureWebAddress);
114
+ }
115
+ break;
116
+ case "ServerBindings":
117
+ IIs.WebAddress webAddress = this.HarvestBindings(propertyName, property);
118
+ if (null != webAddress)
119
+ {
120
+ webSite.AddChild(webAddress);
121
+ }
122
+ break;
123
+ case "ServerComment":
124
+ webSite.Description = (string)property.Value;
125
+ break;
126
+ }
127
+ }
128
+ }
129
+
130
+ foreach (DirectoryEntry childEntry in webSiteEntry.Children)
131
+ {
132
+ switch (childEntry.SchemaClassName)
133
+ {
134
+ case "IIsFilters":
135
+ string loadOrder = (string)childEntry.Properties["FilterLoadOrder"].Value;
136
+ if (loadOrder.Length > 0)
137
+ {
138
+ string[] filterNames = loadOrder.Split(",".ToCharArray());
139
+
140
+ for (int i = 0; i < filterNames.Length; i++)
141
+ {
142
+ using (DirectoryEntry webFilterEntry = new DirectoryEntry(String.Concat(childEntry.Path, '/', filterNames[i])))
143
+ {
144
+ IIs.WebFilter webFilter = this.HarvestWebFilter(webFilterEntry);
145
+
146
+ webFilter.LoadOrder = (i + 1).ToString(CultureInfo.InvariantCulture);
147
+
148
+ webSite.AddChild(webFilter);
149
+ }
150
+ }
151
+ }
152
+ break;
153
+ case "IIsWebDirectory":
154
+ this.HarvestWebDirectory(childEntry, webSite);
155
+ break;
156
+ case "IIsWebVirtualDir":
157
+ foreach (string propertyName in childEntry.Properties.PropertyNames)
158
+ {
159
+ PropertyValueCollection property = childEntry.Properties[propertyName];
160
+
161
+ switch (propertyName)
162
+ {
163
+ case "Path":
164
+ webSite.Directory = (string)property.Value;
165
+ break;
166
+ }
167
+ }
168
+
169
+ IIs.WebDirProperties webDirProps = this.HarvestWebDirProperties(childEntry);
170
+ if (null != webDirProps)
171
+ {
172
+ webSite.AddChild(webDirProps);
173
+ }
174
+
175
+ foreach (DirectoryEntry child2Entry in childEntry.Children)
176
+ {
177
+ switch (child2Entry.SchemaClassName)
178
+ {
179
+ case "IIsWebDirectory":
180
+ this.HarvestWebDirectory(child2Entry, webSite);
181
+ break;
182
+ case "IIsWebVirtualDir":
183
+ this.HarvestWebVirtualDir(child2Entry, webSite);
184
+ break;
185
+ }
186
+ }
187
+ break;
188
+ }
189
+ }
190
+
191
+ return webSite;
192
+ }
193
+
194
+ /// <summary>
195
+ /// Harvest bindings.
196
+ /// </summary>
197
+ /// <param name="propertyName">The property name of the bindings property.</param>
198
+ /// <param name="bindingsProperty">The bindings property.</param>
199
+ /// <returns>The harvested bindings.</returns>
200
+ private IIs.WebAddress HarvestBindings(string propertyName, PropertyValueCollection bindingsProperty)
201
+ {
202
+ if (1 == bindingsProperty.Count)
203
+ {
204
+ IIs.WebAddress webAddress = new IIs.WebAddress();
205
+
206
+ string[] bindings = ((string)bindingsProperty[0]).Split(":".ToCharArray());
207
+
208
+ if (0 < bindings[0].Length)
209
+ {
210
+ webAddress.IP = bindings[0];
211
+ }
212
+
213
+ if (0 < bindings[1].Length)
214
+ {
215
+ webAddress.Port = bindings[1];
216
+ }
217
+
218
+ if (0 < bindings[2].Length)
219
+ {
220
+ webAddress.Header = bindings[2];
221
+ }
222
+
223
+ if ("SecureBindings" == propertyName)
224
+ {
225
+ webAddress.Secure = IIs.YesNoType.yes;
226
+ }
227
+
228
+ return webAddress;
229
+ }
230
+
231
+ return null;
232
+ }
233
+
234
+ /// <summary>
235
+ /// Harvest a web directory.
236
+ /// </summary>
237
+ /// <param name="webDirectoryEntry">The web directory directory entry.</param>
238
+ /// <param name="webSite">The parent web site.</param>
239
+ private void HarvestWebDirectory(DirectoryEntry webDirectoryEntry, IIs.WebSite webSite)
240
+ {
241
+ foreach (DirectoryEntry childEntry in webDirectoryEntry.Children)
242
+ {
243
+ switch (childEntry.SchemaClassName)
244
+ {
245
+ case "IIsWebDirectory":
246
+ this.HarvestWebDirectory(childEntry, webSite);
247
+ break;
248
+ case "IIsWebVirtualDir":
249
+ this.HarvestWebVirtualDir(childEntry, webSite);
250
+ break;
251
+ }
252
+ }
253
+
254
+ IIs.WebDirProperties webDirProperties = this.HarvestWebDirProperties(webDirectoryEntry);
255
+
256
+ if (null != webDirProperties)
257
+ {
258
+ IIs.WebDir webDir = new IIs.WebDir();
259
+
260
+ int indexOfRoot = webDirectoryEntry.Path.IndexOf("ROOT/", StringComparison.OrdinalIgnoreCase);
261
+ webDir.Path = webDirectoryEntry.Path.Substring(indexOfRoot + 5);
262
+
263
+ webDir.AddChild(webDirProperties);
264
+
265
+ webSite.AddChild(webDir);
266
+ }
267
+ }
268
+
269
+ /// <summary>
270
+ /// Harvest a web filter.
271
+ /// </summary>
272
+ /// <param name="webFilterEntry">The web filter directory entry.</param>
273
+ /// <returns>The harvested web filter.</returns>
274
+ private IIs.WebFilter HarvestWebFilter(DirectoryEntry webFilterEntry)
275
+ {
276
+ IIs.WebFilter webFilter = new IIs.WebFilter();
277
+
278
+ webFilter.Name = webFilterEntry.Name;
279
+
280
+ foreach (string propertyName in webFilterEntry.Properties.PropertyNames)
281
+ {
282
+ PropertyValueCollection property = webFilterEntry.Properties[propertyName];
283
+
284
+ switch (propertyName)
285
+ {
286
+ case "FilterDescription":
287
+ webFilter.Description = (string)property.Value;
288
+ break;
289
+ case "FilterFlags":
290
+ webFilter.Flags = (int)property.Value;
291
+ break;
292
+ case "FilterPath":
293
+ webFilter.Path = (string)property.Value;
294
+ break;
295
+ }
296
+ }
297
+
298
+ return webFilter;
299
+ }
300
+
301
+ /// <summary>
302
+ /// Harvest a web directory's properties.
303
+ /// </summary>
304
+ /// <param name="directoryEntry">The web directory directory entry.</param>
305
+ /// <returns>The harvested web directory's properties.</returns>
306
+ private IIs.WebDirProperties HarvestWebDirProperties(DirectoryEntry directoryEntry)
307
+ {
308
+ bool foundProperties = false;
309
+ IIs.WebDirProperties webDirProperties = new IIs.WebDirProperties();
310
+
311
+ // Cannot read properties for "iisadmin" site.
312
+ if (String.Equals("iisadmin", directoryEntry.Name, StringComparison.OrdinalIgnoreCase) &&
313
+ String.Equals("ROOT", directoryEntry.Parent.Name, StringComparison.OrdinalIgnoreCase))
314
+ {
315
+ return null;
316
+ }
317
+
318
+ foreach (string propertyName in directoryEntry.Properties.PropertyNames)
319
+ {
320
+ PropertyValueCollection property = directoryEntry.Properties[propertyName];
321
+ PropertyValueCollection parentProperty = directoryEntry.Parent.Properties[propertyName];
322
+
323
+ if (null == parentProperty.Value || parentProperty.Value.ToString() != property.Value.ToString())
324
+ {
325
+ switch (propertyName)
326
+ {
327
+ case "AccessFlags":
328
+ int access = (int)property.Value;
329
+
330
+ if (0x1 == (access & 0x1))
331
+ {
332
+ webDirProperties.Read = IIs.YesNoType.yes;
333
+ }
334
+
335
+ if (0x2 == (access & 0x2))
336
+ {
337
+ webDirProperties.Write = IIs.YesNoType.yes;
338
+ }
339
+
340
+ if (0x4 == (access & 0x4))
341
+ {
342
+ webDirProperties.Execute = IIs.YesNoType.yes;
343
+ }
344
+
345
+ if (0x200 == (access & 0x200))
346
+ {
347
+ webDirProperties.Script = IIs.YesNoType.yes;
348
+ }
349
+
350
+ foundProperties = true;
351
+ break;
352
+ case "AuthFlags":
353
+ int authorization = (int)property.Value;
354
+
355
+ if (0x1 == (authorization & 0x1))
356
+ {
357
+ webDirProperties.AnonymousAccess = IIs.YesNoType.yes;
358
+ }
359
+
360
+ if (0x2 == (authorization & 0x2))
361
+ {
362
+ webDirProperties.BasicAuthentication = IIs.YesNoType.yes;
363
+ }
364
+
365
+ if (0x4 == (authorization & 0x4))
366
+ {
367
+ webDirProperties.WindowsAuthentication = IIs.YesNoType.yes;
368
+ }
369
+
370
+ if (0x10 == (authorization & 0x10))
371
+ {
372
+ webDirProperties.DigestAuthentication = IIs.YesNoType.yes;
373
+ }
374
+
375
+ if (0x40 == (authorization & 0x40))
376
+ {
377
+ webDirProperties.PassportAuthentication = IIs.YesNoType.yes;
378
+ }
379
+
380
+ foundProperties = true;
381
+ break;
382
+ }
383
+ }
384
+ }
385
+
386
+ return foundProperties ? webDirProperties : null;
387
+ }
388
+
389
+ /// <summary>
390
+ /// Harvest a web virtual directory.
391
+ /// </summary>
392
+ /// <param name="webVirtualDirEntry">The web virtual directory directory entry.</param>
393
+ /// <param name="webSite">The parent web site.</param>
394
+ private void HarvestWebVirtualDir(DirectoryEntry webVirtualDirEntry, IIs.WebSite webSite)
395
+ {
396
+ IIs.WebVirtualDir webVirtualDir = new IIs.WebVirtualDir();
397
+
398
+ foreach (string propertyName in webVirtualDirEntry.Properties.PropertyNames)
399
+ {
400
+ PropertyValueCollection property = webVirtualDirEntry.Properties[propertyName];
401
+ PropertyValueCollection parentProperty = webVirtualDirEntry.Parent.Properties[propertyName];
402
+
403
+ if (null == parentProperty.Value || parentProperty.Value.ToString() != property.Value.ToString())
404
+ {
405
+ switch (propertyName)
406
+ {
407
+ case "Path":
408
+ webVirtualDir.Directory = (string)property.Value;
409
+ break;
410
+ }
411
+ }
412
+ }
413
+
414
+ int indexOfRoot = webVirtualDirEntry.Path.IndexOf("ROOT/", StringComparison.OrdinalIgnoreCase);
415
+ webVirtualDir.Alias = webVirtualDirEntry.Path.Substring(indexOfRoot + 5);
416
+
417
+ IIs.WebDirProperties webDirProps = this.HarvestWebDirProperties(webVirtualDirEntry);
418
+ if (webDirProps != null)
419
+ {
420
+ webVirtualDir.AddChild(webDirProps);
421
+ }
422
+
423
+ foreach (DirectoryEntry childEntry in webVirtualDirEntry.Children)
424
+ {
425
+ switch (childEntry.SchemaClassName)
426
+ {
427
+ case "IIsWebDirectory":
428
+ this.HarvestWebDirectory(childEntry, webSite);
429
+ break;
430
+ case "IIsWebVirtualDir":
431
+ this.HarvestWebVirtualDir(childEntry, webSite);
432
+ break;
433
+ }
434
+ }
435
+
436
+ webSite.AddChild(webVirtualDir);
437
+ }
438
+ }
439
+}
src/heat/Mutator.cs
new
+93
@@ -0,0 +1,93 @@
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.Harvesters
4
+{
5
+ using System;
6
+ using System.Collections;
7
+ using WixToolset.Harvesters.Extensibility;
8
+ using Wix = WixToolset.Harvesters.Serialize;
9
+
10
+ /// <summary>
11
+ /// The WiX Toolset mutator.
12
+ /// </summary>
13
+ internal class Mutator : IMutator
14
+ {
15
+ private SortedList extensions;
16
+ private string extensionArgument;
17
+
18
+ /// <summary>
19
+ /// Instantiate a new mutator.
20
+ /// </summary>
21
+ public Mutator()
22
+ {
23
+ this.extensions = new SortedList();
24
+ }
25
+
26
+ public IHarvesterCore Core { get; set; }
27
+
28
+ public string ExtensionArgument
29
+ {
30
+ get { return this.extensionArgument; }
31
+ set { this.extensionArgument = value; }
32
+ }
33
+
34
+ public void AddExtension(IMutatorExtension mutatorExtension)
35
+ {
36
+ this.extensions.Add(mutatorExtension.Sequence, mutatorExtension);
37
+ }
38
+
39
+ public bool Mutate(Wix.Wix wix)
40
+ {
41
+ bool encounteredError = false;
42
+
43
+ try
44
+ {
45
+ foreach (IMutatorExtension mutatorExtension in this.extensions.Values)
46
+ {
47
+ if (null == mutatorExtension.Core)
48
+ {
49
+ mutatorExtension.Core = this.Core;
50
+ }
51
+
52
+ mutatorExtension.Mutate(wix);
53
+ }
54
+ }
55
+ finally
56
+ {
57
+ encounteredError = this.Core.Messaging.EncounteredError;
58
+ }
59
+
60
+ // return the Wix document element only if mutation completed successfully
61
+ return !encounteredError;
62
+ }
63
+
64
+ public string Mutate(string wixString)
65
+ {
66
+ bool encounteredError = false;
67
+
68
+ try
69
+ {
70
+ foreach (IMutatorExtension mutatorExtension in this.extensions.Values)
71
+ {
72
+ if (null == mutatorExtension.Core)
73
+ {
74
+ mutatorExtension.Core = this.Core;
75
+ }
76
+
77
+ wixString = mutatorExtension.Mutate(wixString);
78
+
79
+ if (String.IsNullOrEmpty(wixString) || this.Core.Messaging.EncounteredError)
80
+ {
81
+ break;
82
+ }
83
+ }
84
+ }
85
+ finally
86
+ {
87
+ encounteredError = this.Core.Messaging.EncounteredError;
88
+ }
89
+
90
+ return encounteredError ? null : wixString;
91
+ }
92
+ }
93
+}
src/heat/PayloadHarvester.cs
new
+129
@@ -0,0 +1,129 @@
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.Harvesters
4
+{
5
+ using System;
6
+ using System.IO;
7
+ using WixToolset.Core.Burn.Interfaces;
8
+ using WixToolset.Data;
9
+ using WixToolset.Data.Symbols;
10
+ using WixToolset.Harvesters.Data;
11
+ using WixToolset.Harvesters.Extensibility;
12
+ using Wix = WixToolset.Harvesters.Serialize;
13
+
14
+ /// <summary>
15
+ /// Harvest WiX authoring for a payload from the file system.
16
+ /// </summary>
17
+ internal class PayloadHarvester : BaseHarvesterExtension
18
+ {
19
+ private bool setUniqueIdentifiers;
20
+ private WixBundlePackageType packageType;
21
+
22
+ private IPayloadHarvester payloadHarvester;
23
+
24
+ /// <summary>
25
+ /// Instantiate a new PayloadHarvester.
26
+ /// </summary>
27
+ public PayloadHarvester(IPayloadHarvester payloadHarvester, WixBundlePackageType packageType)
28
+ {
29
+ this.payloadHarvester = payloadHarvester;
30
+
31
+ this.packageType = packageType;
32
+ this.setUniqueIdentifiers = true;
33
+ }
34
+
35
+ /// <summary>
36
+ /// Gets of sets the option to set unique identifiers.
37
+ /// </summary>
38
+ /// <value>The option to set unique identifiers.</value>
39
+ public bool SetUniqueIdentifiers
40
+ {
41
+ get { return this.setUniqueIdentifiers; }
42
+ set { this.setUniqueIdentifiers = value; }
43
+ }
44
+
45
+ /// <summary>
46
+ /// Harvest a payload.
47
+ /// </summary>
48
+ /// <param name="argument">The path of the payload.</param>
49
+ /// <returns>A harvested payload.</returns>
50
+ public override Wix.Fragment[] Harvest(string argument)
51
+ {
52
+ if (null == argument)
53
+ {
54
+ throw new ArgumentNullException("argument");
55
+ }
56
+
57
+ string fullPath = Path.GetFullPath(argument);
58
+
59
+ var remotePayload = this.HarvestRemotePayload(fullPath);
60
+
61
+ var fragment = new Wix.Fragment();
62
+ fragment.AddChild(remotePayload);
63
+
64
+ return new Wix.Fragment[] { fragment };
65
+ }
66
+
67
+ /// <summary>
68
+ /// Harvest a payload.
69
+ /// </summary>
70
+ /// <param name="path">The path of the payload.</param>
71
+ /// <returns>A harvested payload.</returns>
72
+ public Wix.RemotePayload HarvestRemotePayload(string path)
73
+ {
74
+ if (null == path)
75
+ {
76
+ throw new ArgumentNullException("path");
77
+ }
78
+
79
+ if (!File.Exists(path))
80
+ {
81
+ throw new WixException(HarvesterErrors.FileNotFound(path));
82
+ }
83
+
84
+ Wix.RemotePayload remotePayload;
85
+
86
+ switch (this.packageType)
87
+ {
88
+ case WixBundlePackageType.Exe:
89
+ remotePayload = new Wix.ExePackagePayload();
90
+ break;
91
+ case WixBundlePackageType.Msu:
92
+ remotePayload = new Wix.MsuPackagePayload();
93
+ break;
94
+ default:
95
+ throw new NotImplementedException();
96
+ }
97
+
98
+ var payloadSymbol = new WixBundlePayloadSymbol
99
+ {
100
+ SourceFile = new IntermediateFieldPathValue { Path = path },
101
+ };
102
+
103
+ this.payloadHarvester.HarvestStandardInformation(payloadSymbol);
104
+
105
+ if (payloadSymbol.FileSize.HasValue)
106
+ {
107
+ remotePayload.Size = payloadSymbol.FileSize.Value;
108
+ }
109
+ remotePayload.Hash = payloadSymbol.Hash;
110
+
111
+ if (!String.IsNullOrEmpty(payloadSymbol.Version))
112
+ {
113
+ remotePayload.Version = payloadSymbol.Version;
114
+ }
115
+
116
+ if (!String.IsNullOrEmpty(payloadSymbol.Description))
117
+ {
118
+ remotePayload.Description = payloadSymbol.Description;
119
+ }
120
+
121
+ if (!String.IsNullOrEmpty(payloadSymbol.DisplayName))
122
+ {
123
+ remotePayload.ProductName = payloadSymbol.DisplayName;
124
+ }
125
+
126
+ return remotePayload;
127
+ }
128
+ }
129
+}
src/heat/PerformanceCategoryHarvester.cs
new
+207
@@ -0,0 +1,207 @@
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.Harvesters
4
+{
5
+ using System;
6
+ using System.Linq;
7
+ using System.Diagnostics;
8
+ using WixToolset.Data;
9
+ using WixToolset.Harvesters.Data;
10
+ using WixToolset.Harvesters.Extensibility;
11
+ using Util = WixToolset.Harvesters.Serialize.Util;
12
+ using Wix = WixToolset.Harvesters.Serialize;
13
+
14
+ /// <summary>
15
+ /// Harvest WiX authoring for a file from the file system.
16
+ /// </summary>
17
+ internal class PerformanceCategoryHarvester : BaseHarvesterExtension
18
+ {
19
+ /// <summary>
20
+ /// Harvest a performance category.
21
+ /// </summary>
22
+ /// <param name="argument">The name of the performance category.</param>
23
+ /// <returns>A harvested performance category.</returns>
24
+ public override Wix.Fragment[] Harvest(string argument)
25
+ {
26
+ if (null == argument)
27
+ {
28
+ throw new ArgumentNullException("argument");
29
+ }
30
+
31
+ Util.PerformanceCategory perf = this.HarvestPerformanceCategory(argument);
32
+
33
+ Wix.Component component = new Wix.Component();
34
+ component.Id = this.Core.CreateIdentifierFromFilename(argument);
35
+ component.KeyPath = Wix.YesNoType.yes;
36
+ component.AddChild(perf);
37
+
38
+ Wix.Directory directory = new Wix.Directory();
39
+ directory.Id = "TARGETDIR";
40
+ //directory.Name = directory.Id;
41
+ directory.AddChild(component);
42
+
43
+ Wix.Fragment fragment = new Wix.Fragment();
44
+ fragment.AddChild(directory);
45
+
46
+ return new Wix.Fragment[] { fragment };
47
+ }
48
+
49
+ /// <summary>
50
+ /// Harvest a performance category.
51
+ /// </summary>
52
+ /// <param name="category">The name of the performance category.</param>
53
+ /// <returns>A harvested file.</returns>
54
+ public Util.PerformanceCategory HarvestPerformanceCategory(string category)
55
+ {
56
+ if (null == category)
57
+ {
58
+ throw new ArgumentNullException("category");
59
+ }
60
+
61
+ if (PerformanceCounterCategory.Exists(category))
62
+ {
63
+ Util.PerformanceCategory perfCategory = new Util.PerformanceCategory();
64
+
65
+ // Get the performance counter category and set the appropriate WiX attributes
66
+ PerformanceCounterCategory pcc = PerformanceCounterCategory.GetCategories().Single(c => string.Equals(c.CategoryName, category));
67
+ perfCategory.Id = this.Core.CreateIdentifierFromFilename(pcc.CategoryName);
68
+ perfCategory.Name = pcc.CategoryName;
69
+ perfCategory.Help = pcc.CategoryHelp;
70
+ if (PerformanceCounterCategoryType.MultiInstance == pcc.CategoryType)
71
+ {
72
+ perfCategory.MultiInstance = Util.YesNoType.yes;
73
+ }
74
+
75
+ // If it's multi-instance, check if there are any instances and get counters from there; else we get
76
+ // the counters straight up. For multi-instance, GetCounters() fails if there are any instances. If there
77
+ // are no instances, then GetCounters(instance) can't be called since there is no instance. Instances
78
+ // will exist for each counter even if only one of the counters was "intialized."
79
+ string[] instances = pcc.GetInstanceNames();
80
+ bool hasInstances = instances.Length > 0;
81
+ PerformanceCounter[] counters = hasInstances
82
+ ? pcc.GetCounters(instances.First())
83
+ : pcc.GetCounters();
84
+
85
+ foreach (PerformanceCounter counter in counters)
86
+ {
87
+ Util.PerformanceCounter perfCounter = new Util.PerformanceCounter();
88
+
89
+ // Get the performance counter and set the appropriate WiX attributes
90
+ perfCounter.Name = counter.CounterName;
91
+ perfCounter.Type = this.CounterTypeToWix(counter.CounterType);
92
+ perfCounter.Help = counter.CounterHelp;
93
+
94
+ perfCategory.AddChild(perfCounter);
95
+ }
96
+
97
+ return perfCategory;
98
+ }
99
+ else
100
+ {
101
+ throw new WixException(HarvesterErrors.PerformanceCategoryNotFound(category));
102
+ }
103
+ }
104
+
105
+ /// <summary>
106
+ /// Get the WiX performance counter type.
107
+ /// </summary>
108
+ /// <param name="pct">The performance counter value to get.</param>
109
+ /// <returns>The WiX performance counter type.</returns>
110
+ private Util.PerformanceCounterTypesType CounterTypeToWix(PerformanceCounterType pct)
111
+ {
112
+ Util.PerformanceCounterTypesType type;
113
+
114
+ switch (pct)
115
+ {
116
+ case PerformanceCounterType.AverageBase:
117
+ type = Util.PerformanceCounterTypesType.averageBase;
118
+ break;
119
+ case PerformanceCounterType.AverageCount64:
120
+ type = Util.PerformanceCounterTypesType.averageCount64;
121
+ break;
122
+ case PerformanceCounterType.AverageTimer32:
123
+ type = Util.PerformanceCounterTypesType.averageTimer32;
124
+ break;
125
+ case PerformanceCounterType.CounterDelta32:
126
+ type = Util.PerformanceCounterTypesType.counterDelta32;
127
+ break;
128
+ case PerformanceCounterType.CounterTimerInverse:
129
+ type = Util.PerformanceCounterTypesType.counterTimerInverse;
130
+ break;
131
+ case PerformanceCounterType.SampleFraction:
132
+ type = Util.PerformanceCounterTypesType.sampleFraction;
133
+ break;
134
+ case PerformanceCounterType.Timer100Ns:
135
+ type = Util.PerformanceCounterTypesType.timer100Ns;
136
+ break;
137
+ case PerformanceCounterType.CounterTimer:
138
+ type = Util.PerformanceCounterTypesType.counterTimer;
139
+ break;
140
+ case PerformanceCounterType.RawFraction:
141
+ type = Util.PerformanceCounterTypesType.rawFraction;
142
+ break;
143
+ case PerformanceCounterType.Timer100NsInverse:
144
+ type = Util.PerformanceCounterTypesType.timer100NsInverse;
145
+ break;
146
+ case PerformanceCounterType.CounterMultiTimer:
147
+ type = Util.PerformanceCounterTypesType.counterMultiTimer;
148
+ break;
149
+ case PerformanceCounterType.CounterMultiTimer100Ns:
150
+ type = Util.PerformanceCounterTypesType.counterMultiTimer100Ns;
151
+ break;
152
+ case PerformanceCounterType.CounterMultiTimerInverse:
153
+ type = Util.PerformanceCounterTypesType.counterMultiTimerInverse;
154
+ break;
155
+ case PerformanceCounterType.CounterMultiTimer100NsInverse:
156
+ type = Util.PerformanceCounterTypesType.counterMultiTimer100NsInverse;
157
+ break;
158
+ case PerformanceCounterType.ElapsedTime:
159
+ type = Util.PerformanceCounterTypesType.elapsedTime;
160
+ break;
161
+ case PerformanceCounterType.SampleBase:
162
+ type = Util.PerformanceCounterTypesType.sampleBase;
163
+ break;
164
+ case PerformanceCounterType.RawBase:
165
+ type = Util.PerformanceCounterTypesType.rawBase;
166
+ break;
167
+ case PerformanceCounterType.CounterMultiBase:
168
+ type = Util.PerformanceCounterTypesType.counterMultiBase;
169
+ break;
170
+ case PerformanceCounterType.RateOfCountsPerSecond64:
171
+ type = Util.PerformanceCounterTypesType.rateOfCountsPerSecond64;
172
+ break;
173
+ case PerformanceCounterType.RateOfCountsPerSecond32:
174
+ type = Util.PerformanceCounterTypesType.rateOfCountsPerSecond32;
175
+ break;
176
+ case PerformanceCounterType.CountPerTimeInterval64:
177
+ type = Util.PerformanceCounterTypesType.countPerTimeInterval64;
178
+ break;
179
+ case PerformanceCounterType.CountPerTimeInterval32:
180
+ type = Util.PerformanceCounterTypesType.countPerTimeInterval32;
181
+ break;
182
+ case PerformanceCounterType.SampleCounter:
183
+ type = Util.PerformanceCounterTypesType.sampleCounter;
184
+ break;
185
+ case PerformanceCounterType.CounterDelta64:
186
+ type = Util.PerformanceCounterTypesType.counterDelta64;
187
+ break;
188
+ case PerformanceCounterType.NumberOfItems64:
189
+ type = Util.PerformanceCounterTypesType.numberOfItems64;
190
+ break;
191
+ case PerformanceCounterType.NumberOfItems32:
192
+ type = Util.PerformanceCounterTypesType.numberOfItems32;
193
+ break;
194
+ case PerformanceCounterType.NumberOfItemsHEX64:
195
+ type = Util.PerformanceCounterTypesType.numberOfItemsHEX64;
196
+ break;
197
+ case PerformanceCounterType.NumberOfItemsHEX32:
198
+ type = Util.PerformanceCounterTypesType.numberOfItemsHEX32;
199
+ break;
200
+ default:
201
+ throw new WixException(HarvesterErrors.UnsupportedPerformanceCounterType(pct.ToString()));
202
+ }
203
+
204
+ return type;
205
+ }
206
+ }
207
+}
src/heat/RegFileHarvester.cs
new
+438
@@ -0,0 +1,438 @@
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.Harvesters
4
+{
5
+ using System;
6
+ using System.Collections;
7
+ using System.Globalization;
8
+ using System.IO;
9
+ using WixToolset.Data;
10
+ using WixToolset.Harvesters.Data;
11
+ using WixToolset.Harvesters.Extensibility;
12
+ using Wix = WixToolset.Harvesters.Serialize;
13
+
14
+ /// <summary>
15
+ /// Harvest WiX authoring for a reg file.
16
+ /// </summary>
17
+ internal class RegFileHarvester : BaseHarvesterExtension
18
+ {
19
+ private static readonly string ComponentPrefix = "cmp";
20
+
21
+ /// <summary>
22
+ /// Current line in the reg file being processed.
23
+ /// </summary>
24
+ private int currentLineNumber = 0;
25
+
26
+ /// <summary>
27
+ /// Flag indicating whether this is a unicode registry file.
28
+ /// </summary>
29
+ private bool unicodeRegistry;
30
+
31
+ /// <summary>
32
+ /// Harvest a file.
33
+ /// </summary>
34
+ /// <param name="argument">The path of the file.</param>
35
+ /// <returns>A harvested file.</returns>
36
+ public override Wix.Fragment[] Harvest(string argument)
37
+ {
38
+ if (null == argument)
39
+ {
40
+ throw new ArgumentNullException("argument");
41
+ }
42
+
43
+ // Harvest the keys from the registry file
44
+ Wix.Fragment fragment = this.HarvestRegFile(argument);
45
+
46
+ return new Wix.Fragment[] { fragment };
47
+ }
48
+
49
+ /// <summary>
50
+ /// Harvest a reg file.
51
+ /// </summary>
52
+ /// <param name="path">The path of the file.</param>
53
+ /// <returns>A harvested registy file.</returns>
54
+ public Wix.Fragment HarvestRegFile(string path)
55
+ {
56
+ if (null == path)
57
+ {
58
+ throw new ArgumentNullException("path");
59
+ }
60
+
61
+ if (!File.Exists(path))
62
+ {
63
+ throw new WixException(HarvesterErrors.FileNotFound(path));
64
+ }
65
+
66
+ Wix.Directory directory = new Wix.Directory();
67
+ directory.Id = "TARGETDIR";
68
+
69
+ // Use absolute paths
70
+ path = Path.GetFullPath(path);
71
+ FileInfo file = new FileInfo(path);
72
+
73
+ using (StreamReader sr = file.OpenText())
74
+ {
75
+ string line;
76
+ this.currentLineNumber = 0;
77
+
78
+ while (null != (line = this.GetNextLine(sr)))
79
+ {
80
+ if (line.StartsWith(@"Windows Registry Editor Version 5.00"))
81
+ {
82
+ this.unicodeRegistry = true;
83
+ }
84
+ else if (line.StartsWith(@"REGEDIT4"))
85
+ {
86
+ this.unicodeRegistry = false;
87
+ }
88
+ else if (line.StartsWith(@"[HKEY_CLASSES_ROOT\"))
89
+ {
90
+ this.ConvertKey(sr, ref directory, Wix.RegistryRootType.HKCR, line.Substring(19, line.Length - 20));
91
+ }
92
+ else if (line.StartsWith(@"[HKEY_CURRENT_USER\"))
93
+ {
94
+ this.ConvertKey(sr, ref directory, Wix.RegistryRootType.HKCU, line.Substring(19, line.Length - 20));
95
+ }
96
+ else if (line.StartsWith(@"[HKEY_LOCAL_MACHINE\"))
97
+ {
98
+ this.ConvertKey(sr, ref directory, Wix.RegistryRootType.HKLM, line.Substring(20, line.Length - 21));
99
+ }
100
+ else if (line.StartsWith(@"[HKEY_USERS\"))
101
+ {
102
+ this.ConvertKey(sr, ref directory, Wix.RegistryRootType.HKU, line.Substring(12, line.Length - 13));
103
+ }
104
+ }
105
+ }
106
+
107
+ Console.WriteLine("Processing complete");
108
+
109
+ Wix.Fragment fragment = new Wix.Fragment();
110
+ fragment.AddChild(directory);
111
+
112
+ return fragment;
113
+ }
114
+
115
+ /// <summary>
116
+ /// Converts the registry key to a WiX component element.
117
+ /// </summary>
118
+ /// <param name="sr">The registry file stream.</param>
119
+ /// <param name="directory">A WiX directory reference.</param>
120
+ /// <param name="root">The root key.</param>
121
+ /// <param name="line">The current line.</param>
122
+ private void ConvertKey(StreamReader sr, ref Wix.Directory directory, Wix.RegistryRootType root, string line)
123
+ {
124
+ Wix.Component component = new Wix.Component();
125
+
126
+ component.Id = this.Core.GenerateIdentifier(ComponentPrefix, line);
127
+ component.KeyPath = Wix.YesNoType.yes;
128
+
129
+ this.ConvertValues(sr, ref component, root, line);
130
+ directory.AddChild(component);
131
+ }
132
+
133
+ /// <summary>
134
+ /// Converts the registry values to WiX regisry key element.
135
+ /// </summary>
136
+ /// <param name="sr">The registry file stream.</param>
137
+ /// <param name="component">A WiX component reference.</param>
138
+ /// <param name="root">The root key.</param>
139
+ /// <param name="line">The current line.</param>
140
+ private void ConvertValues(StreamReader sr, ref Wix.Component component, Wix.RegistryRootType root, string line)
141
+ {
142
+ string name = null;
143
+ string value = null;
144
+ Wix.RegistryValue.TypeType type;
145
+ Wix.RegistryKey registryKey = new Wix.RegistryKey();
146
+
147
+ registryKey.Root = root;
148
+ registryKey.Key = line;
149
+
150
+ while (this.GetValue(sr, ref name, ref value, out type))
151
+ {
152
+ Wix.RegistryValue registryValue = new Wix.RegistryValue();
153
+ ArrayList charArray;
154
+
155
+ // Don't specifiy name for default attribute
156
+ if (!string.IsNullOrEmpty(name))
157
+ {
158
+ registryValue.Name = name;
159
+ }
160
+
161
+ registryValue.Type = type;
162
+
163
+ switch (type)
164
+ {
165
+ case Wix.RegistryValue.TypeType.binary:
166
+ registryValue.Value = value.Replace(",", string.Empty).ToUpper();
167
+ break;
168
+
169
+ case Wix.RegistryValue.TypeType.integer:
170
+ registryValue.Value = Int32.Parse(value, NumberStyles.HexNumber).ToString();
171
+ break;
172
+
173
+ case Wix.RegistryValue.TypeType.expandable:
174
+ charArray = this.ConvertCharList(value);
175
+ value = string.Empty;
176
+
177
+ // create the string, remove the terminating null
178
+ for (int i = 0; i < charArray.Count; i++)
179
+ {
180
+ if ('\0' != (char)charArray[i])
181
+ {
182
+ value += charArray[i];
183
+ }
184
+ }
185
+
186
+ registryValue.Value = value;
187
+ break;
188
+
189
+ case Wix.RegistryValue.TypeType.multiString:
190
+ charArray = this.ConvertCharList(value);
191
+ value = string.Empty;
192
+
193
+ // Convert the character array to a string so we can simply split it at the nulls, ignore the final null null.
194
+ for (int i = 0; i < (charArray.Count - 2); i++)
195
+ {
196
+ value += charArray[i];
197
+ }
198
+
199
+ // Although the value can use [~] the preffered way is to use MultiStringValue
200
+ string[] parts = value.Split("\0".ToCharArray());
201
+ foreach (string part in parts)
202
+ {
203
+ Wix.MultiStringValue multiStringValue = new Wix.MultiStringValue();
204
+ multiStringValue.Content = part;
205
+ registryValue.AddChild(multiStringValue);
206
+ }
207
+
208
+ break;
209
+
210
+ case Wix.RegistryValue.TypeType.@string:
211
+ // Remove \\ and \"
212
+ value = value.ToString().Replace("\\\"", "\"");
213
+ value = value.ToString().Replace(@"\\", @"\");
214
+ // Escape [ and ]
215
+ value = value.ToString().Replace(@"[", @"[\[]");
216
+ value = value.ToString().Replace(@"]", @"[\]]");
217
+ // This undoes the duplicate escaping caused by the second replace
218
+ value = value.ToString().Replace(@"[\[[\]]", @"[\[]");
219
+ // Escape $
220
+ value = value.ToString().Replace(@"$", @"$$");
221
+
222
+ registryValue.Value = value;
223
+ break;
224
+
225
+ default:
226
+ throw new ApplicationException(String.Format("Did not recognize the type of reg value on line {0}", this.currentLineNumber));
227
+ }
228
+
229
+ registryKey.AddChild(registryValue);
230
+ }
231
+
232
+ // Make sure empty keys are created
233
+ if (null == value)
234
+ {
235
+ registryKey.ForceCreateOnInstall = Wix.YesNoType.yes;
236
+ }
237
+
238
+ component.AddChild(registryKey);
239
+ }
240
+
241
+ /// <summary>
242
+ /// Parse a value from a line.
243
+ /// </summary>
244
+ /// <param name="sr">Reader for the reg file.</param>
245
+ /// <param name="name">Name of the value.</param>
246
+ /// <param name="value">Value of the value.</param>
247
+ /// <param name="type">Type of the value.</param>
248
+ /// <returns>true if the value can be parsed, false otherwise.</returns>
249
+ private bool GetValue(StreamReader sr, ref string name, ref string value, out Wix.RegistryValue.TypeType type)
250
+ {
251
+ string line = this.GetNextLine(sr);
252
+
253
+ if (null == line || 0 == line.Length)
254
+ {
255
+ type = 0;
256
+ return false;
257
+ }
258
+
259
+ string[] parts;
260
+
261
+ if (line.StartsWith("@"))
262
+ {
263
+ // Special case for default value
264
+ parts = line.Trim().Split("=".ToCharArray(), 2);
265
+
266
+ name = null;
267
+ }
268
+ else
269
+ {
270
+ parts = line.Trim().Split("=".ToCharArray());
271
+
272
+ // It is valid to have an '=' in the name or the data. This is probably a string so the separator will be '"="'.
273
+ if (2 != parts.Length)
274
+ {
275
+ string[] stringSeparator = new string[] { "\"=\"" };
276
+ parts = line.Trim().Split(stringSeparator, StringSplitOptions.None);
277
+
278
+ if (2 != parts.Length)
279
+ {
280
+ // Line still no parsed correctly
281
+ throw new ApplicationException(String.Format("Cannot parse value: {0} at line {1}.", line, this.currentLineNumber));
282
+ }
283
+
284
+ // Put back quotes stripped by Split()
285
+ parts[0] += "\"";
286
+ parts[1] = "\"" + parts[1];
287
+ }
288
+
289
+ name = parts[0].Substring(1, parts[0].Length - 2);
290
+ }
291
+
292
+ if (parts[1].StartsWith("hex:"))
293
+ {
294
+ // binary
295
+ value = parts[1].Substring(4);
296
+ type = Wix.RegistryValue.TypeType.binary;
297
+ }
298
+ else if (parts[1].StartsWith("dword:"))
299
+ {
300
+ // dword
301
+ value = parts[1].Substring(6);
302
+ type = Wix.RegistryValue.TypeType.integer;
303
+ }
304
+ else if (parts[1].StartsWith("hex(2):"))
305
+ {
306
+ // expandable string
307
+ value = parts[1].Substring(7);
308
+ type = Wix.RegistryValue.TypeType.expandable;
309
+ }
310
+ else if (parts[1].StartsWith("hex(7):"))
311
+ {
312
+ // multi-string
313
+ value = parts[1].Substring(7);
314
+ type = Wix.RegistryValue.TypeType.multiString;
315
+ }
316
+ else if (parts[1].StartsWith("hex("))
317
+ {
318
+ // Give a better error when we find something that isn't supported
319
+ // by specifying the type that isn't supported.
320
+ string unsupportedType = "";
321
+
322
+ if (parts[1].StartsWith("hex(0")) { unsupportedType = "REG_NONE"; }
323
+ else if (parts[1].StartsWith("hex(6")) { unsupportedType = "REG_LINK"; }
324
+ else if (parts[1].StartsWith("hex(8")) { unsupportedType = "REG_RESOURCE_LIST"; }
325
+ else if (parts[1].StartsWith("hex(9")) { unsupportedType = "REG_FULL_RESOURCE_DESCRIPTOR"; }
326
+ else if (parts[1].StartsWith("hex(a")) { unsupportedType = "REG_RESOURCE_REQUIREMENTS_LIST"; }
327
+ else if (parts[1].StartsWith("hex(b")) { unsupportedType = "REG_QWORD"; }
328
+
329
+ // REG_NONE(0), REG_LINK(6), REG_RESOURCE_LIST(8), REG_FULL_RESOURCE_DESCRIPTOR(9), REG_RESOURCE_REQUIREMENTS_LIST(a), REG_QWORD(b)
330
+ this.Core.Messaging.Write(HarvesterWarnings.UnsupportedRegistryType(parts[0], this.currentLineNumber, unsupportedType));
331
+
332
+ type = 0;
333
+ return false;
334
+ }
335
+ else if (parts[1].StartsWith("\""))
336
+ {
337
+ // string
338
+ value = parts[1].Substring(1, parts[1].Length - 2);
339
+ type = Wix.RegistryValue.TypeType.@string;
340
+ }
341
+ else
342
+ {
343
+ // unsupported value
344
+ throw new ApplicationException(String.Format("Unsupported registry value {0} at line {1}.", line, this.currentLineNumber));
345
+ }
346
+
347
+ return true;
348
+ }
349
+
350
+ /// <summary>
351
+ /// Get the next line from the reg file input stream.
352
+ /// </summary>
353
+ /// <param name="sr">Reader for the reg file.</param>
354
+ /// <returns>The next line.</returns>
355
+ private string GetNextLine(StreamReader sr)
356
+ {
357
+ string line;
358
+ string totalLine = null;
359
+
360
+ while (null != (line = sr.ReadLine()))
361
+ {
362
+ bool stop = true;
363
+
364
+ this.currentLineNumber++;
365
+ line = line.Trim();
366
+ Console.Write("Processing line: {0}\r", this.currentLineNumber);
367
+
368
+ if (line.EndsWith("\\"))
369
+ {
370
+ stop = false;
371
+ line = line.Substring(0, line.Length - 1);
372
+ }
373
+
374
+ if (null == totalLine)
375
+ {
376
+ // first line
377
+ totalLine = line;
378
+ }
379
+ else
380
+ {
381
+ // other lines
382
+ totalLine += line;
383
+ }
384
+
385
+ // break if there is no more info for this line
386
+ if (stop)
387
+ {
388
+ break;
389
+ }
390
+ }
391
+
392
+ return totalLine;
393
+ }
394
+
395
+ /// <summary>
396
+ /// Convert a character list into the proper WiX format for either unicode or ansi lists.
397
+ /// </summary>
398
+ /// <param name="charList">List of characters.</param>
399
+ /// <returns>Array of characters.</returns>
400
+ private ArrayList ConvertCharList(string charList)
401
+ {
402
+ if (string.IsNullOrEmpty(charList))
403
+ {
404
+ return new ArrayList();
405
+ }
406
+
407
+ string[] strChars = charList.Split(",".ToCharArray());
408
+
409
+ ArrayList charArray = new ArrayList();
410
+
411
+ if (this.unicodeRegistry)
412
+ {
413
+ if (0 != strChars.Length % 2)
414
+ {
415
+ throw new ApplicationException(String.Format("Problem parsing Expandable string data at line {0}, its probably not Unicode.", this.currentLineNumber));
416
+ }
417
+
418
+ for (int i = 0; i < strChars.Length; i += 2)
419
+ {
420
+ string chars = strChars[i + 1] + strChars[i];
421
+ int unicodeInt = Int32.Parse(chars, NumberStyles.HexNumber);
422
+ char unicodeChar = (char)unicodeInt;
423
+ charArray.Add(unicodeChar);
424
+ }
425
+ }
426
+ else
427
+ {
428
+ for (int i = 0; i < strChars.Length; i++)
429
+ {
430
+ char charValue = (char)Int32.Parse(strChars[i], NumberStyles.HexNumber);
431
+ charArray.Add(charValue);
432
+ }
433
+ }
434
+
435
+ return charArray;
436
+ }
437
+ }
438
+}
src/heat/RegistryHarvester.cs
new
+477
@@ -0,0 +1,477 @@
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.Harvesters
4
+{
5
+ using System;
6
+ using System.Collections;
7
+ using System.Diagnostics;
8
+ using System.Globalization;
9
+ using System.Runtime.InteropServices;
10
+ using System.Text;
11
+ using Microsoft.Win32;
12
+ using WixToolset.Data;
13
+ using WixToolset.Harvesters.Data;
14
+ using Wix = WixToolset.Harvesters.Serialize;
15
+
16
+ /// <summary>
17
+ /// Harvest WiX authoring from the registry.
18
+ /// </summary>
19
+ internal class RegistryHarvester : IDisposable
20
+ {
21
+ private const string HKCRPathInHKLM = @"Software\Classes";
22
+ private string remappedPath;
23
+ private static readonly int majorOSVersion = Environment.OSVersion.Version.Major;
24
+ private RegistryKey regKeyToOverride = Registry.LocalMachine;
25
+ private IntPtr regRootToOverride = NativeMethods.HkeyLocalMachine;
26
+
27
+ /// <summary>
28
+ /// Instantiate a new RegistryHarvester.
29
+ /// </summary>
30
+ /// <param name="remap">Set to true to remap the entire registry to a private location for this process.</param>
31
+ public RegistryHarvester(bool remap)
32
+ {
33
+ // Detect OS major version and set the hive to use when
34
+ // redirecting registry writes. We want to redirect registry
35
+ // writes to HKCU on Windows Vista and higher to avoid UAC
36
+ // problems, and to HKLM on downlevel OS's.
37
+ if (majorOSVersion >= 6)
38
+ {
39
+ this.regKeyToOverride = Registry.CurrentUser;
40
+ this.regRootToOverride = NativeMethods.HkeyCurrentUser;
41
+ }
42
+
43
+ // create a path in the registry for redirected keys which is process-specific
44
+ if (remap)
45
+ {
46
+ this.remappedPath = String.Concat(@"SOFTWARE\WiX\heat\", Process.GetCurrentProcess().Id.ToString(CultureInfo.InvariantCulture));
47
+
48
+ // remove the previous remapped key if it exists
49
+ this.RemoveRemappedKey();
50
+
51
+ // remap the registry roots supported by MSI
52
+ // note - order is important here - the hive being used to redirect
53
+ // to must be overridden last to avoid creating the other override
54
+ // hives in the wrong location in the registry. For example, if HKLM is
55
+ // the redirect destination, overriding it first will cause other hives
56
+ // to be overridden under HKLM\Software\WiX\heat\HKLM\Software\WiX\HKCR
57
+ // instead of under HKLM\Software\WiX\heat\HKCR
58
+ if (majorOSVersion < 6)
59
+ {
60
+ this.RemapRegistryKey(NativeMethods.HkeyClassesRoot, String.Concat(this.remappedPath, @"\\HKEY_CLASSES_ROOT"));
61
+ this.RemapRegistryKey(NativeMethods.HkeyCurrentUser, String.Concat(this.remappedPath, @"\\HKEY_CURRENT_USER"));
62
+ this.RemapRegistryKey(NativeMethods.HkeyUsers, String.Concat(this.remappedPath, @"\\HKEY_USERS"));
63
+ this.RemapRegistryKey(NativeMethods.HkeyLocalMachine, String.Concat(this.remappedPath, @"\\HKEY_LOCAL_MACHINE"));
64
+ }
65
+ else
66
+ {
67
+ this.RemapRegistryKey(NativeMethods.HkeyClassesRoot, String.Concat(this.remappedPath, @"\\HKEY_CLASSES_ROOT"));
68
+ this.RemapRegistryKey(NativeMethods.HkeyLocalMachine, String.Concat(this.remappedPath, @"\\HKEY_LOCAL_MACHINE"));
69
+ this.RemapRegistryKey(NativeMethods.HkeyUsers, String.Concat(this.remappedPath, @"\\HKEY_USERS"));
70
+ this.RemapRegistryKey(NativeMethods.HkeyCurrentUser, String.Concat(this.remappedPath, @"\\HKEY_CURRENT_USER"));
71
+
72
+ // Typelib registration on Windows Vista requires that the key
73
+ // HKLM\Software\Classes exist, so add it to the remapped root
74
+ Registry.LocalMachine.CreateSubKey(HKCRPathInHKLM);
75
+ }
76
+ }
77
+ }
78
+
79
+ /// <summary>
80
+ /// Close the RegistryHarvester and remove any remapped registry keys.
81
+ /// </summary>
82
+ public void Close()
83
+ {
84
+ // note - order is important here - we must quit overriding the hive
85
+ // being used to redirect first
86
+ if (majorOSVersion < 6)
87
+ {
88
+ NativeMethods.OverrideRegistryKey(NativeMethods.HkeyLocalMachine, IntPtr.Zero);
89
+ NativeMethods.OverrideRegistryKey(NativeMethods.HkeyClassesRoot, IntPtr.Zero);
90
+ NativeMethods.OverrideRegistryKey(NativeMethods.HkeyCurrentUser, IntPtr.Zero);
91
+ NativeMethods.OverrideRegistryKey(NativeMethods.HkeyUsers, IntPtr.Zero);
92
+ }
93
+ else
94
+ {
95
+ NativeMethods.OverrideRegistryKey(NativeMethods.HkeyCurrentUser, IntPtr.Zero);
96
+ NativeMethods.OverrideRegistryKey(NativeMethods.HkeyClassesRoot, IntPtr.Zero);
97
+ NativeMethods.OverrideRegistryKey(NativeMethods.HkeyLocalMachine, IntPtr.Zero);
98
+ NativeMethods.OverrideRegistryKey(NativeMethods.HkeyUsers, IntPtr.Zero);
99
+ }
100
+
101
+ this.RemoveRemappedKey();
102
+ }
103
+
104
+ /// <summary>
105
+ /// Dispose the RegistryHarvester.
106
+ /// </summary>
107
+ public void Dispose()
108
+ {
109
+ this.Close();
110
+ }
111
+
112
+ /// <summary>
113
+ /// Harvest all registry roots supported by Windows Installer.
114
+ /// </summary>
115
+ /// <returns>The registry keys and values in the registry.</returns>
116
+ public Wix.RegistryValue[] HarvestRegistry()
117
+ {
118
+ ArrayList registryValues = new ArrayList();
119
+
120
+ this.HarvestRegistryKey(Registry.ClassesRoot, registryValues);
121
+ this.HarvestRegistryKey(Registry.CurrentUser, registryValues);
122
+ this.HarvestRegistryKey(Registry.LocalMachine, registryValues);
123
+ this.HarvestRegistryKey(Registry.Users, registryValues);
124
+
125
+ return (Wix.RegistryValue[])registryValues.ToArray(typeof(Wix.RegistryValue));
126
+ }
127
+
128
+ /// <summary>
129
+ /// Harvest a registry key.
130
+ /// </summary>
131
+ /// <param name="path">The path of the registry key to harvest.</param>
132
+ /// <returns>The registry keys and values under the key.</returns>
133
+ public Wix.RegistryValue[] HarvestRegistryKey(string path)
134
+ {
135
+ RegistryKey registryKey = null;
136
+ ArrayList registryValues = new ArrayList();
137
+
138
+ string[] parts = GetPathParts(path);
139
+
140
+ try
141
+ {
142
+ switch (parts[0])
143
+ {
144
+ case "HKEY_CLASSES_ROOT":
145
+ registryKey = Registry.ClassesRoot;
146
+ break;
147
+ case "HKEY_CURRENT_USER":
148
+ registryKey = Registry.CurrentUser;
149
+ break;
150
+ case "HKEY_LOCAL_MACHINE":
151
+ registryKey = Registry.LocalMachine;
152
+ break;
153
+ case "HKEY_USERS":
154
+ registryKey = Registry.Users;
155
+ break;
156
+ default:
157
+ // TODO: put a better exception here
158
+ throw new Exception();
159
+ }
160
+
161
+ if (1 < parts.Length)
162
+ {
163
+ registryKey = registryKey.OpenSubKey(parts[1]);
164
+
165
+ if (null == registryKey)
166
+ {
167
+ throw new WixException(HarvesterErrors.UnableToOpenRegistryKey(parts[1]));
168
+ }
169
+ }
170
+
171
+ this.HarvestRegistryKey(registryKey, registryValues);
172
+ }
173
+ finally
174
+ {
175
+ if (null != registryKey)
176
+ {
177
+ registryKey.Close();
178
+ }
179
+ }
180
+
181
+ return (Wix.RegistryValue[])registryValues.ToArray(typeof(Wix.RegistryValue));
182
+ }
183
+
184
+ /// <summary>
185
+ /// Gets the parts of a registry key's path.
186
+ /// </summary>
187
+ /// <param name="path">The registry key path.</param>
188
+ /// <returns>The root and key parts of the registry key path.</returns>
189
+ private static string[] GetPathParts(string path)
190
+ {
191
+ return path.Split(@"\".ToCharArray(), 2);
192
+ }
193
+
194
+ /// <summary>
195
+ /// Harvest a registry key.
196
+ /// </summary>
197
+ /// <param name="registryKey">The registry key to harvest.</param>
198
+ /// <param name="registryValues">The collected registry values.</param>
199
+ private void HarvestRegistryKey(RegistryKey registryKey, ArrayList registryValues)
200
+ {
201
+ // harvest the sub-keys
202
+ foreach (string subKeyName in registryKey.GetSubKeyNames())
203
+ {
204
+ using (RegistryKey subKey = registryKey.OpenSubKey(subKeyName))
205
+ {
206
+ this.HarvestRegistryKey(subKey, registryValues);
207
+ }
208
+ }
209
+
210
+ string[] parts = GetPathParts(registryKey.Name);
211
+
212
+ Wix.RegistryRootType root;
213
+ switch (parts[0])
214
+ {
215
+ case "HKEY_CLASSES_ROOT":
216
+ root = Wix.RegistryRootType.HKCR;
217
+ break;
218
+ case "HKEY_CURRENT_USER":
219
+ root = Wix.RegistryRootType.HKCU;
220
+ break;
221
+ case "HKEY_LOCAL_MACHINE":
222
+ // HKLM\Software\Classes is equivalent to HKCR
223
+ if (1 < parts.Length && parts[1].StartsWith(HKCRPathInHKLM, StringComparison.OrdinalIgnoreCase))
224
+ {
225
+ root = Wix.RegistryRootType.HKCR;
226
+ parts[1] = parts[1].Remove(0, HKCRPathInHKLM.Length);
227
+
228
+ if (0 < parts[1].Length)
229
+ {
230
+ parts[1] = parts[1].TrimStart('\\');
231
+ }
232
+
233
+ if (String.IsNullOrEmpty(parts[1]))
234
+ {
235
+ parts = new [] { parts[0] };
236
+ }
237
+ }
238
+ else
239
+ {
240
+ root = Wix.RegistryRootType.HKLM;
241
+ }
242
+ break;
243
+ case "HKEY_USERS":
244
+ root = Wix.RegistryRootType.HKU;
245
+ break;
246
+ default:
247
+ // TODO: put a better exception here
248
+ throw new Exception();
249
+ }
250
+
251
+ // harvest the values
252
+ foreach (string valueName in registryKey.GetValueNames())
253
+ {
254
+ Wix.RegistryValue registryValue = new Wix.RegistryValue();
255
+
256
+ registryValue.Action = Wix.RegistryValue.ActionType.write;
257
+
258
+ registryValue.Root = root;
259
+
260
+ if (1 < parts.Length)
261
+ {
262
+ registryValue.Key = parts[1];
263
+ }
264
+
265
+ if (null != valueName && 0 < valueName.Length)
266
+ {
267
+ registryValue.Name = valueName;
268
+ }
269
+
270
+ object value = registryKey.GetValue(valueName);
271
+
272
+ if (value is byte[]) // binary
273
+ {
274
+ StringBuilder hexadecimalValue = new StringBuilder();
275
+
276
+ // convert the byte array to hexadecimal
277
+ foreach (byte byteValue in (byte[])value)
278
+ {
279
+ hexadecimalValue.Append(byteValue.ToString("X2", CultureInfo.InvariantCulture.NumberFormat));
280
+ }
281
+
282
+ registryValue.Type = Wix.RegistryValue.TypeType.binary;
283
+ registryValue.Value = hexadecimalValue.ToString();
284
+ }
285
+ else if (value is int) // integer
286
+ {
287
+ registryValue.Type = Wix.RegistryValue.TypeType.integer;
288
+ registryValue.Value = ((int)value).ToString(CultureInfo.InvariantCulture);
289
+ }
290
+ else if (value is string[]) // multi-string
291
+ {
292
+ registryValue.Type = Wix.RegistryValue.TypeType.multiString;
293
+
294
+ if (0 == ((string[])value).Length)
295
+ {
296
+ Wix.MultiStringValue multiStringValue = new Wix.MultiStringValue();
297
+
298
+ multiStringValue.Content = String.Empty;
299
+
300
+ registryValue.AddChild(multiStringValue);
301
+ }
302
+ else
303
+ {
304
+ foreach (string multiStringValueContent in (string[])value)
305
+ {
306
+ Wix.MultiStringValue multiStringValue = new Wix.MultiStringValue();
307
+
308
+ multiStringValue.Content = multiStringValueContent;
309
+
310
+ registryValue.AddChild(multiStringValue);
311
+ }
312
+ }
313
+ }
314
+ else if (value is string) // string, expandable (there is no way to differentiate a string and expandable value in .NET 1.1)
315
+ {
316
+ registryValue.Type = Wix.RegistryValue.TypeType.@string;
317
+ registryValue.Value = (string)value;
318
+ }
319
+ else
320
+ {
321
+ // TODO: put a better exception here
322
+ throw new Exception();
323
+ }
324
+
325
+ registryValues.Add(registryValue);
326
+ }
327
+
328
+ // If there were no subkeys and no values, we still need an element for this empty registry key.
329
+ // But specifically avoid SOFTWARE\Classes because it shouldn't be harvested as an empty key.
330
+ if (parts.Length > 1 && registryKey.SubKeyCount == 0 && registryKey.ValueCount == 0 &&
331
+ !String.Equals(parts[1], HKCRPathInHKLM, StringComparison.OrdinalIgnoreCase))
332
+ {
333
+ Wix.RegistryValue emptyRegistryKey = new Wix.RegistryValue();
334
+ emptyRegistryKey.Root = root;
335
+ emptyRegistryKey.Key = parts[1];
336
+ emptyRegistryKey.Type = Wix.RegistryValue.TypeType.@string;
337
+ emptyRegistryKey.Value = String.Empty;
338
+ emptyRegistryKey.Action = Wix.RegistryValue.ActionType.write;
339
+ registryValues.Add(emptyRegistryKey);
340
+ }
341
+ }
342
+
343
+ /// <summary>
344
+ /// Remap a registry key to an alternative location.
345
+ /// </summary>
346
+ /// <param name="registryKey">The registry key to remap.</param>
347
+ /// <param name="remappedPath">The path to remap the registry key to under HKLM.</param>
348
+ private void RemapRegistryKey(IntPtr registryKey, string remappedPath)
349
+ {
350
+ IntPtr remappedKey = IntPtr.Zero;
351
+
352
+ try
353
+ {
354
+ remappedKey = NativeMethods.OpenRegistryKey(this.regRootToOverride, remappedPath);
355
+
356
+ NativeMethods.OverrideRegistryKey(registryKey, remappedKey);
357
+ }
358
+ finally
359
+ {
360
+ if (IntPtr.Zero != remappedKey)
361
+ {
362
+ NativeMethods.CloseRegistryKey(remappedKey);
363
+ }
364
+ }
365
+ }
366
+
367
+ /// <summary>
368
+ /// Remove the remapped registry key.
369
+ /// </summary>
370
+ private void RemoveRemappedKey()
371
+ {
372
+ try
373
+ {
374
+ this.regKeyToOverride.DeleteSubKeyTree(this.remappedPath);
375
+ }
376
+ catch (ArgumentException)
377
+ {
378
+ // ignore the error where the key does not exist
379
+ }
380
+ }
381
+
382
+ /// <summary>
383
+ /// The native methods for re-mapping registry keys.
384
+ /// </summary>
385
+ private sealed class NativeMethods
386
+ {
387
+ internal static readonly IntPtr HkeyClassesRoot = (IntPtr)unchecked((Int32)0x80000000);
388
+ internal static readonly IntPtr HkeyCurrentUser = (IntPtr)unchecked((Int32)0x80000001);
389
+ internal static readonly IntPtr HkeyLocalMachine = (IntPtr)unchecked((Int32)0x80000002);
390
+ internal static readonly IntPtr HkeyUsers = (IntPtr)unchecked((Int32)0x80000003);
391
+
392
+ private const uint GenericRead = 0x80000000;
393
+ private const uint GenericWrite = 0x40000000;
394
+ private const uint GenericExecute = 0x20000000;
395
+ private const uint GenericAll = 0x10000000;
396
+ private const uint StandardRightsAll = 0x001F0000;
397
+
398
+ /// <summary>
399
+ /// Opens a registry key.
400
+ /// </summary>
401
+ /// <param name="key">Base key to open.</param>
402
+ /// <param name="path">Path to subkey to open.</param>
403
+ /// <returns>Handle to new key.</returns>
404
+ internal static IntPtr OpenRegistryKey(IntPtr key, string path)
405
+ {
406
+ IntPtr newKey = IntPtr.Zero;
407
+ uint disposition = 0;
408
+ uint sam = StandardRightsAll | GenericRead | GenericWrite | GenericExecute | GenericAll;
409
+
410
+ if (0 != RegCreateKeyEx(key, path, 0, null, 0, sam, 0, out newKey, out disposition))
411
+ {
412
+ throw new Exception();
413
+ }
414
+
415
+ return newKey;
416
+ }
417
+
418
+ /// <summary>
419
+ /// Closes a previously open registry key.
420
+ /// </summary>
421
+ /// <param name="key">Handle to key to close.</param>
422
+ internal static void CloseRegistryKey(IntPtr key)
423
+ {
424
+ if (0 != RegCloseKey(key))
425
+ {
426
+ throw new Exception();
427
+ }
428
+ }
429
+
430
+ /// <summary>
431
+ /// Override a registry key.
432
+ /// </summary>
433
+ /// <param name="key">Handle of the key to override.</param>
434
+ /// <param name="newKey">Handle to override key.</param>
435
+ internal static void OverrideRegistryKey(IntPtr key, IntPtr newKey)
436
+ {
437
+ if (0 != RegOverridePredefKey(key, newKey))
438
+ {
439
+ throw new Exception();
440
+ }
441
+ }
442
+
443
+ /// <summary>
444
+ /// Interop to RegCreateKeyW.
445
+ /// </summary>
446
+ /// <param name="key">Handle to base key.</param>
447
+ /// <param name="subkey">Subkey to create.</param>
448
+ /// <param name="reserved">Always 0</param>
449
+ /// <param name="className">Just pass null.</param>
450
+ /// <param name="options">Just pass 0.</param>
451
+ /// <param name="desiredSam">Rights to registry key.</param>
452
+ /// <param name="securityAttributes">Just pass null.</param>
453
+ /// <param name="openedKey">Opened key.</param>
454
+ /// <param name="disposition">Whether key was opened or created.</param>
455
+ /// <returns>Handle to registry key.</returns>
456
+ [DllImport("advapi32.dll", EntryPoint = "RegCreateKeyExW", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
457
+ private static extern int RegCreateKeyEx(IntPtr key, string subkey, uint reserved, string className, uint options, uint desiredSam, uint securityAttributes, out IntPtr openedKey, out uint disposition);
458
+
459
+ /// <summary>
460
+ /// Interop to RegCloseKey.
461
+ /// </summary>
462
+ /// <param name="key">Handle to key to close.</param>
463
+ /// <returns>0 if success.</returns>
464
+ [DllImport("advapi32.dll", EntryPoint = "RegCloseKey", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
465
+ private static extern int RegCloseKey(IntPtr key);
466
+
467
+ /// <summary>
468
+ /// Interop to RegOverridePredefKey.
469
+ /// </summary>
470
+ /// <param name="key">Handle to key to override.</param>
471
+ /// <param name="newKey">Handle to override key.</param>
472
+ /// <returns>0 if success.</returns>
473
+ [DllImport("advapi32.dll", EntryPoint = "RegOverridePredefKey", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
474
+ private static extern int RegOverridePredefKey(IntPtr key, IntPtr newKey);
475
+ }
476
+ }
477
+}
src/heat/Serialize/CodeDomInterfaces.cs
new
+96
@@ -0,0 +1,96 @@
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.Harvesters.Serialize
4
+{
5
+ using System;
6
+ using System.Collections;
7
+ using System.Xml;
8
+
9
+ /// <summary>
10
+ /// Interface for generated schema elements.
11
+ /// </summary>
12
+ public interface ISchemaElement
13
+ {
14
+ /// <summary>
15
+ /// Gets and sets the parent of this element. May be null.
16
+ /// </summary>
17
+ /// <value>An ISchemaElement that has this element as a child.</value>
18
+ ISchemaElement ParentElement
19
+ {
20
+ get;
21
+ set;
22
+ }
23
+
24
+ /// <summary>
25
+ /// Outputs xml representing this element, including the associated attributes
26
+ /// and any nested elements.
27
+ /// </summary>
28
+ /// <param name="writer">XmlWriter to be used when outputting the element.</param>
29
+ void OutputXml(XmlWriter writer);
30
+ }
31
+
32
+ /// <summary>
33
+ /// Interface for generated schema elements. Implemented by elements that have child
34
+ /// elements.
35
+ /// </summary>
36
+ public interface IParentElement
37
+ {
38
+ /// <summary>
39
+ /// Gets an enumerable collection of the children of this element.
40
+ /// </summary>
41
+ /// <value>An enumerable collection of the children of this element.</value>
42
+ IEnumerable Children
43
+ {
44
+ get;
45
+ }
46
+
47
+ /// <summary>
48
+ /// Gets an enumerable collection of the children of this element, filtered
49
+ /// by the passed in type.
50
+ /// </summary>
51
+ /// <param name="childType">The type of children to retrieve.</param>
52
+ IEnumerable this[Type childType]
53
+ {
54
+ get;
55
+ }
56
+
57
+ /// <summary>
58
+ /// Adds a child to this element.
59
+ /// </summary>
60
+ /// <param name="child">Child to add.</param>
61
+ void AddChild(ISchemaElement child);
62
+
63
+ /// <summary>
64
+ /// Removes a child from this element.
65
+ /// </summary>
66
+ /// <param name="child">Child to remove.</param>
67
+ void RemoveChild(ISchemaElement child);
68
+ }
69
+
70
+ /// <summary>
71
+ /// Interface for generated schema elements. Implemented by classes with attributes.
72
+ /// </summary>
73
+ public interface ISetAttributes
74
+ {
75
+ /// <summary>
76
+ /// Sets the attribute with the given name to the given value. The value here is
77
+ /// a string, and is converted to the strongly-typed version inside this method.
78
+ /// </summary>
79
+ /// <param name="name">The name of the attribute to set.</param>
80
+ /// <param name="value">The value to assign to the attribute.</param>
81
+ void SetAttribute(string name, string value);
82
+ }
83
+
84
+ /// <summary>
85
+ /// Interface for generated schema elements. Implemented by classes with children.
86
+ /// </summary>
87
+ public interface ICreateChildren
88
+ {
89
+ /// <summary>
90
+ /// Creates an instance of the child with the passed in name.
91
+ /// </summary>
92
+ /// <param name="childName">String matching the element name of the child when represented in XML.</param>
93
+ /// <returns>An instance of that child.</returns>
94
+ ISchemaElement CreateChild(string childName);
95
+ }
96
+}
src/heat/Serialize/CodeDomReader.cs
new
+162
@@ -0,0 +1,162 @@
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.Harvesters.Serialize
4
+{
5
+ using System;
6
+ using System.Diagnostics.CodeAnalysis;
7
+ using System.Globalization;
8
+ using System.Reflection;
9
+ using System.Xml;
10
+ using WixToolset.Harvesters.Extensibility.Serialize;
11
+
12
+ /// <summary>
13
+ /// Class used for reading XML files in to the CodeDom.
14
+ /// </summary>
15
+ public class CodeDomReader
16
+ {
17
+ private Assembly[] assemblies;
18
+
19
+ /// <summary>
20
+ /// Creates a new CodeDomReader, using the current assembly.
21
+ /// </summary>
22
+ public CodeDomReader()
23
+ {
24
+ this.assemblies = new Assembly[] { Assembly.GetExecutingAssembly() };
25
+ }
26
+
27
+ /// <summary>
28
+ /// Creates a new CodeDomReader, and takes in a list of assemblies in which to
29
+ /// look for elements.
30
+ /// </summary>
31
+ /// <param name="assemblies">Assemblies in which to look for types that correspond
32
+ /// to elements.</param>
33
+ public CodeDomReader(Assembly[] assemblies)
34
+ {
35
+ this.assemblies = assemblies;
36
+ }
37
+
38
+ /// <summary>
39
+ /// Loads an XML file into a strongly-typed code dom.
40
+ /// </summary>
41
+ /// <param name="filePath">File to load into the code dom.</param>
42
+ /// <returns>The strongly-typed object at the root of the tree.</returns>
43
+ [SuppressMessage("Microsoft.Globalization", "CA1303:DoNotPassLiteralsAsLocalizedParameters", MessageId = "System.InvalidOperationException.#ctor(System.String)")]
44
+ public ISchemaElement Load(string filePath)
45
+ {
46
+ XmlDocument document = new XmlDocument();
47
+ document.Load(filePath);
48
+ ISchemaElement schemaElement = null;
49
+
50
+ foreach (XmlNode node in document.ChildNodes)
51
+ {
52
+ XmlElement element = node as XmlElement;
53
+ if (element != null)
54
+ {
55
+ if (schemaElement != null)
56
+ {
57
+ throw new InvalidOperationException(WixHarvesterStrings.EXP_MultipleRootElementsFoundInFile);
58
+ }
59
+
60
+ schemaElement = this.CreateObjectFromElement(element);
61
+ this.ParseObjectFromElement(schemaElement, element);
62
+ }
63
+ }
64
+ return schemaElement;
65
+ }
66
+
67
+ /// <summary>
68
+ /// Sets an attribute on an ISchemaElement.
69
+ /// </summary>
70
+ /// <param name="schemaElement">Schema element to set attribute on.</param>
71
+ /// <param name="name">Name of the attribute to set.</param>
72
+ /// <param name="value">Value to set on the attribute.</param>
73
+ [SuppressMessage("Microsoft.Globalization", "CA1303:DoNotPassLiteralsAsLocalizedParameters", MessageId = "System.InvalidOperationException.#ctor(System.String)")]
74
+ private static void SetAttributeOnObject(ISchemaElement schemaElement, string name, string value)
75
+ {
76
+ ISetAttributes setAttributes = schemaElement as ISetAttributes;
77
+ if (setAttributes == null)
78
+ {
79
+ throw new InvalidOperationException(String.Format(CultureInfo.CurrentUICulture, WixHarvesterStrings.EXP_ISchemaElementDoesnotImplementISetAttribute, schemaElement.GetType().FullName));
80
+ }
81
+ else
82
+ {
83
+ setAttributes.SetAttribute(name, value);
84
+ }
85
+ }
86
+
87
+ /// <summary>
88
+ /// Parses an ISchemaElement from the XmlElement.
89
+ /// </summary>
90
+ /// <param name="schemaElement">ISchemaElement to fill in.</param>
91
+ /// <param name="element">XmlElement to parse from.</param>
92
+ [SuppressMessage("Microsoft.Globalization", "CA1303:DoNotPassLiteralsAsLocalizedParameters", MessageId = "System.InvalidOperationException.#ctor(System.String)")]
93
+ private void ParseObjectFromElement(ISchemaElement schemaElement, XmlElement element)
94
+ {
95
+ foreach (XmlAttribute attribute in element.Attributes)
96
+ {
97
+ SetAttributeOnObject(schemaElement, attribute.LocalName, attribute.Value);
98
+ }
99
+
100
+ foreach (XmlNode node in element.ChildNodes)
101
+ {
102
+ XmlElement childElement = node as XmlElement;
103
+ if (childElement != null)
104
+ {
105
+ ISchemaElement childSchemaElement = null;
106
+ ICreateChildren createChildren = schemaElement as ICreateChildren;
107
+ if (createChildren == null)
108
+ {
109
+ throw new InvalidOperationException(String.Format(CultureInfo.CurrentUICulture, WixHarvesterStrings.EXP_ISchemaElementDoesnotImplementICreateChildren, element.LocalName));
110
+ }
111
+ else
112
+ {
113
+ childSchemaElement = createChildren.CreateChild(childElement.LocalName);
114
+ }
115
+
116
+ if (childSchemaElement == null)
117
+ {
118
+ childSchemaElement = this.CreateObjectFromElement(childElement);
119
+ if (childSchemaElement == null)
120
+ {
121
+ throw new InvalidOperationException(String.Format(CultureInfo.CurrentUICulture, WixHarvesterStrings.EXP_XmlElementDoesnotHaveISchemaElement, childElement.LocalName));
122
+ }
123
+ }
124
+
125
+ this.ParseObjectFromElement(childSchemaElement, childElement);
126
+ IParentElement parentElement = (IParentElement)schemaElement;
127
+ parentElement.AddChild(childSchemaElement);
128
+ }
129
+ else
130
+ {
131
+ XmlText childText = node as XmlText;
132
+ if (childText != null)
133
+ {
134
+ SetAttributeOnObject(schemaElement, "Content", childText.Value);
135
+ }
136
+ }
137
+ }
138
+ }
139
+
140
+ /// <summary>
141
+ /// Creates an object from an XML element by digging through the assembly list.
142
+ /// </summary>
143
+ /// <param name="element">XML Element to create an ISchemaElement from.</param>
144
+ /// <returns>A constructed ISchemaElement.</returns>
145
+ private ISchemaElement CreateObjectFromElement(XmlElement element)
146
+ {
147
+ ISchemaElement schemaElement = null;
148
+ foreach (Assembly assembly in this.assemblies)
149
+ {
150
+ foreach (Type type in assembly.GetTypes())
151
+ {
152
+ if (type.FullName.EndsWith(element.LocalName, StringComparison.Ordinal)
153
+ && typeof(ISchemaElement).IsAssignableFrom(type))
154
+ {
155
+ schemaElement = (ISchemaElement)Activator.CreateInstance(type);
156
+ }
157
+ }
158
+ }
159
+ return schemaElement;
160
+ }
161
+ }
162
+}
src/heat/Serialize/ElementCollection.cs
new
+618
@@ -0,0 +1,618 @@
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.Harvesters.Serialize
4
+{
5
+ using System;
6
+ using System.Collections;
7
+ using System.Globalization;
8
+ using WixToolset.Harvesters.Extensibility.Serialize;
9
+
10
+ /// <summary>
11
+ /// Collection used in the CodeDOM for the children of a given element. Provides type-checking
12
+ /// on the allowed children to ensure that only allowed types are added.
13
+ /// </summary>
14
+ public class ElementCollection : ICollection, IEnumerable
15
+ {
16
+ private CollectionType collectionType;
17
+ private int totalContainedItems;
18
+ private int containersUsed;
19
+ private ArrayList items;
20
+
21
+ /// <summary>
22
+ /// Creates a new element collection.
23
+ /// </summary>
24
+ /// <param name="collectionType">Type of the collection to create.</param>
25
+ public ElementCollection(CollectionType collectionType)
26
+ {
27
+ this.collectionType = collectionType;
28
+ this.items = new ArrayList();
29
+ }
30
+
31
+ /// <summary>
32
+ /// Enum representing types of XML collections.
33
+ /// </summary>
34
+ public enum CollectionType
35
+ {
36
+ /// <summary>
37
+ /// A choice type, corresponding to the XSD choice element.
38
+ /// </summary>
39
+ Choice,
40
+
41
+ /// <summary>
42
+ /// A sequence type, corresponding to the XSD sequence element.
43
+ /// </summary>
44
+ Sequence
45
+ }
46
+
47
+ /// <summary>
48
+ /// Gets the type of collection.
49
+ /// </summary>
50
+ /// <value>The type of collection.</value>
51
+ public CollectionType Type
52
+ {
53
+ get { return this.collectionType; }
54
+ }
55
+
56
+ /// <summary>
57
+ /// Gets the count of child elements in this collection (counts ISchemaElements, not nested collections).
58
+ /// </summary>
59
+ /// <value>The count of child elements in this collection (counts ISchemaElements, not nested collections).</value>
60
+ public int Count
61
+ {
62
+ get { return this.totalContainedItems; }
63
+ }
64
+
65
+ /// <summary>
66
+ /// Gets the flag specifying whether this collection is synchronized. Always returns false.
67
+ /// </summary>
68
+ /// <value>The flag specifying whether this collection is synchronized. Always returns false.</value>
69
+ public bool IsSynchronized
70
+ {
71
+ get { return false; }
72
+ }
73
+
74
+ /// <summary>
75
+ /// Gets an object external callers can synchronize on.
76
+ /// </summary>
77
+ /// <value>An object external callers can synchronize on.</value>
78
+ public object SyncRoot
79
+ {
80
+ get { return this; }
81
+ }
82
+
83
+ /// <summary>
84
+ /// Adds a child element to this collection.
85
+ /// </summary>
86
+ /// <param name="element">The element to add.</param>
87
+ /// <exception cref="ArgumentException">Thrown if the child is not of an allowed type.</exception>
88
+ public void AddElement(ISchemaElement element)
89
+ {
90
+ foreach (object obj in this.items)
91
+ {
92
+ bool containerUsed;
93
+
94
+ CollectionItem collectionItem = obj as CollectionItem;
95
+ if (collectionItem != null)
96
+ {
97
+ containerUsed = collectionItem.Elements.Count != 0;
98
+ if (collectionItem.ElementType.IsAssignableFrom(element.GetType()))
99
+ {
100
+ collectionItem.AddElement(element);
101
+
102
+ if (!containerUsed)
103
+ {
104
+ this.containersUsed++;
105
+ }
106
+
107
+ this.totalContainedItems++;
108
+ return;
109
+ }
110
+
111
+ continue;
112
+ }
113
+
114
+ ElementCollection collection = obj as ElementCollection;
115
+ if (collection != null)
116
+ {
117
+ containerUsed = collection.Count != 0;
118
+
119
+ try
120
+ {
121
+ collection.AddElement(element);
122
+
123
+ if (!containerUsed)
124
+ {
125
+ this.containersUsed++;
126
+ }
127
+
128
+ this.totalContainedItems++;
129
+ return;
130
+ }
131
+ catch (ArgumentException)
132
+ {
133
+ // Eat the exception and keep looking. We'll throw our own if we can't find its home.
134
+ }
135
+
136
+ continue;
137
+ }
138
+ }
139
+
140
+ throw new ArgumentException(String.Format(
141
+ CultureInfo.InvariantCulture,
142
+ WixHarvesterStrings.EXP_ElementOfTypeIsNotValidForThisCollection,
143
+ element.GetType().Name));
144
+ }
145
+
146
+ /// <summary>
147
+ /// Removes a child element from this collection.
148
+ /// </summary>
149
+ /// <param name="element">The element to remove.</param>
150
+ /// <exception cref="ArgumentException">Thrown if the element is not of an allowed type.</exception>
151
+ public void RemoveElement(ISchemaElement element)
152
+ {
153
+ foreach (object obj in this.items)
154
+ {
155
+ CollectionItem collectionItem = obj as CollectionItem;
156
+ if (collectionItem != null)
157
+ {
158
+ if (collectionItem.ElementType.IsAssignableFrom(element.GetType()))
159
+ {
160
+ if (collectionItem.Elements.Count == 0)
161
+ {
162
+ return;
163
+ }
164
+
165
+ collectionItem.RemoveElement(element);
166
+
167
+ if (collectionItem.Elements.Count == 0)
168
+ {
169
+ this.containersUsed--;
170
+ }
171
+
172
+ this.totalContainedItems--;
173
+ return;
174
+ }
175
+
176
+ continue;
177
+ }
178
+
179
+ ElementCollection collection = obj as ElementCollection;
180
+ if (collection != null)
181
+ {
182
+ if (collection.Count == 0)
183
+ {
184
+ continue;
185
+ }
186
+
187
+ try
188
+ {
189
+ collection.RemoveElement(element);
190
+
191
+ if (collection.Count == 0)
192
+ {
193
+ this.containersUsed--;
194
+ }
195
+
196
+ this.totalContainedItems--;
197
+ return;
198
+ }
199
+ catch (ArgumentException)
200
+ {
201
+ // Eat the exception and keep looking. We'll throw our own if we can't find its home.
202
+ }
203
+
204
+ continue;
205
+ }
206
+ }
207
+
208
+ throw new ArgumentException(String.Format(
209
+ CultureInfo.InvariantCulture,
210
+ WixHarvesterStrings.EXP_ElementOfTypeIsNotValidForThisCollection,
211
+ element.GetType().Name));
212
+ }
213
+
214
+ /// <summary>
215
+ /// Copies this collection to an array.
216
+ /// </summary>
217
+ /// <param name="array">Array to copy to.</param>
218
+ /// <param name="index">Offset into the array.</param>
219
+ public void CopyTo(Array array, int index)
220
+ {
221
+ int item = 0;
222
+ foreach (ISchemaElement element in this)
223
+ {
224
+ array.SetValue(element, (long)(item + index));
225
+ item++;
226
+ }
227
+ }
228
+
229
+ /// <summary>
230
+ /// Creates an enumerator for walking the elements in this collection.
231
+ /// </summary>
232
+ /// <returns>A newly created enumerator.</returns>
233
+ public IEnumerator GetEnumerator()
234
+ {
235
+ return new ElementCollectionEnumerator(this);
236
+ }
237
+
238
+ /// <summary>
239
+ /// Gets an enumerable collection of children of a given type.
240
+ /// </summary>
241
+ /// <param name="childType">Type of children to get.</param>
242
+ /// <returns>A collection of children.</returns>
243
+ /// <exception cref="ArgumentException">Thrown if the type isn't a valid child type.</exception>
244
+ public IEnumerable Filter(Type childType)
245
+ {
246
+ foreach (object container in this.items)
247
+ {
248
+ CollectionItem collectionItem = container as CollectionItem;
249
+ if (collectionItem != null)
250
+ {
251
+ if (collectionItem.ElementType.IsAssignableFrom(childType))
252
+ {
253
+ return collectionItem.Elements;
254
+ }
255
+
256
+ continue;
257
+ }
258
+
259
+ ElementCollection elementCollection = container as ElementCollection;
260
+ if (elementCollection != null)
261
+ {
262
+ IEnumerable nestedFilter = elementCollection.Filter(childType);
263
+ if (nestedFilter != null)
264
+ {
265
+ return nestedFilter;
266
+ }
267
+
268
+ continue;
269
+ }
270
+ }
271
+
272
+ throw new ArgumentException(String.Format(
273
+ CultureInfo.InvariantCulture,
274
+ WixHarvesterStrings.EXP_TypeIsNotValidForThisCollection,
275
+ childType.Name));
276
+ }
277
+
278
+ /// <summary>
279
+ /// Adds a type to this collection.
280
+ /// </summary>
281
+ /// <param name="collectionItem">CollectionItem representing the type to add.</param>
282
+ public void AddItem(CollectionItem collectionItem)
283
+ {
284
+ this.items.Add(collectionItem);
285
+ }
286
+
287
+ /// <summary>
288
+ /// Adds a nested collection to this collection.
289
+ /// </summary>
290
+ /// <param name="collection">ElementCollection to add.</param>
291
+ public void AddCollection(ElementCollection collection)
292
+ {
293
+ this.items.Add(collection);
294
+ }
295
+
296
+ /// <summary>
297
+ /// Class used to represent a given type in the child collection of an element. Abstract,
298
+ /// has subclasses for choice and sequence (which can do cardinality checks).
299
+ /// </summary>
300
+ public abstract class CollectionItem
301
+ {
302
+ private Type elementType;
303
+ private ArrayList elements;
304
+
305
+ /// <summary>
306
+ /// Creates a new CollectionItem for the given element type.
307
+ /// </summary>
308
+ /// <param name="elementType">Type of the element for this collection item.</param>
309
+ protected CollectionItem(Type elementType)
310
+ {
311
+ this.elementType = elementType;
312
+ this.elements = new ArrayList();
313
+ }
314
+
315
+ /// <summary>
316
+ /// Gets the type of this collection's items.
317
+ /// </summary>
318
+ /// <value>The type of this collection's items.</value>
319
+ public Type ElementType
320
+ {
321
+ get { return this.elementType; }
322
+ }
323
+
324
+ /// <summary>
325
+ /// Gets the elements of this collection.
326
+ /// </summary>
327
+ /// <value>The elements of this collection.</value>
328
+ public ArrayList Elements
329
+ {
330
+ get { return this.elements; }
331
+ }
332
+
333
+ /// <summary>
334
+ /// Adds an element to this collection. Must be of an assignable type to the collection's
335
+ /// type.
336
+ /// </summary>
337
+ /// <param name="element">The element to add.</param>
338
+ /// <exception cref="ArgumentException">Thrown if the type isn't assignable to the collection's type.</exception>
339
+ public void AddElement(ISchemaElement element)
340
+ {
341
+ if (!this.elementType.IsAssignableFrom(element.GetType()))
342
+ {
343
+ throw new ArgumentException(
344
+ String.Format(
345
+ CultureInfo.InvariantCulture,
346
+ WixHarvesterStrings.EXP_ElementIsSubclassOfDifferentType,
347
+ this.elementType.Name,
348
+ element.GetType().Name),
349
+ "element");
350
+ }
351
+
352
+ this.elements.Add(element);
353
+ }
354
+
355
+ /// <summary>
356
+ /// Removes an element from this collection.
357
+ /// </summary>
358
+ /// <param name="element">The element to remove.</param>
359
+ /// <exception cref="ArgumentException">Thrown if the element's type isn't assignable to the collection's type.</exception>
360
+ public void RemoveElement(ISchemaElement element)
361
+ {
362
+ if (!this.elementType.IsAssignableFrom(element.GetType()))
363
+ {
364
+ throw new ArgumentException(
365
+ String.Format(
366
+ CultureInfo.InvariantCulture,
367
+ WixHarvesterStrings.EXP_ElementIsSubclassOfDifferentType,
368
+ this.elementType.Name,
369
+ element.GetType().Name),
370
+ "element");
371
+ }
372
+
373
+ this.elements.Remove(element);
374
+ }
375
+ }
376
+
377
+ /// <summary>
378
+ /// Class representing a choice item. Doesn't do cardinality checks.
379
+ /// </summary>
380
+ public class ChoiceItem : CollectionItem
381
+ {
382
+ /// <summary>
383
+ /// Creates a new choice item.
384
+ /// </summary>
385
+ /// <param name="elementType">Type of the created item.</param>
386
+ public ChoiceItem(Type elementType)
387
+ : base(elementType)
388
+ {
389
+ }
390
+ }
391
+
392
+ /// <summary>
393
+ /// Class representing a sequence item. Can do cardinality checks, if required.
394
+ /// </summary>
395
+ public class SequenceItem : CollectionItem
396
+ {
397
+ /// <summary>
398
+ /// Creates a new sequence item.
399
+ /// </summary>
400
+ /// <param name="elementType">Type of the created item.</param>
401
+ public SequenceItem(Type elementType)
402
+ : base(elementType)
403
+ {
404
+ }
405
+ }
406
+
407
+ /// <summary>
408
+ /// Enumerator for the ElementCollection.
409
+ /// </summary>
410
+ private class ElementCollectionEnumerator : IEnumerator
411
+ {
412
+ private ElementCollection collection;
413
+ private Stack collectionStack;
414
+
415
+ /// <summary>
416
+ /// Creates a new ElementCollectionEnumerator.
417
+ /// </summary>
418
+ /// <param name="collection">The collection to create an enumerator for.</param>
419
+ public ElementCollectionEnumerator(ElementCollection collection)
420
+ {
421
+ this.collection = collection;
422
+ }
423
+
424
+ /// <summary>
425
+ /// Gets the current object from the enumerator.
426
+ /// </summary>
427
+ public object Current
428
+ {
429
+ get
430
+ {
431
+ if (this.collectionStack != null && this.collectionStack.Count > 0)
432
+ {
433
+ CollectionSymbol symbol = (CollectionSymbol)this.collectionStack.Peek();
434
+ object container = symbol.Collection.items[symbol.ContainerIndex];
435
+
436
+ CollectionItem collectionItem = container as CollectionItem;
437
+ if (collectionItem != null)
438
+ {
439
+ return collectionItem.Elements[symbol.ItemIndex];
440
+ }
441
+
442
+ throw new InvalidOperationException(String.Format(
443
+ CultureInfo.InvariantCulture,
444
+ WixHarvesterStrings.EXP_ElementMustBeChoiceItemOrSequenceItem,
445
+ container.GetType().Name));
446
+ }
447
+
448
+ return null;
449
+ }
450
+ }
451
+
452
+ /// <summary>
453
+ /// Resets the enumerator to the beginning.
454
+ /// </summary>
455
+ public void Reset()
456
+ {
457
+ if (this.collectionStack != null)
458
+ {
459
+ this.collectionStack.Clear();
460
+ this.collectionStack = null;
461
+ }
462
+ }
463
+
464
+ /// <summary>
465
+ /// Moves the enumerator to the next item.
466
+ /// </summary>
467
+ /// <returns>True if there is a next item, false otherwise.</returns>
468
+ public bool MoveNext()
469
+ {
470
+ if (this.collectionStack == null)
471
+ {
472
+ if (this.collection.Count == 0)
473
+ {
474
+ return false;
475
+ }
476
+
477
+ this.collectionStack = new Stack();
478
+ this.collectionStack.Push(new CollectionSymbol(this.collection));
479
+ }
480
+
481
+ CollectionSymbol symbol = (CollectionSymbol)this.collectionStack.Peek();
482
+
483
+ if (this.FindNext(symbol))
484
+ {
485
+ return true;
486
+ }
487
+
488
+ this.collectionStack.Pop();
489
+ if (this.collectionStack.Count == 0)
490
+ {
491
+ return false;
492
+ }
493
+
494
+ return this.MoveNext();
495
+ }
496
+
497
+ /// <summary>
498
+ /// Pushes a collection onto the stack.
499
+ /// </summary>
500
+ /// <param name="elementCollection">The collection to push.</param>
501
+ private void PushCollection(ElementCollection elementCollection)
502
+ {
503
+ if (elementCollection.Count <= 0)
504
+ {
505
+ throw new ArgumentException(String.Format(
506
+ CultureInfo.InvariantCulture,
507
+ WixHarvesterStrings.EXP_CollectionMustHaveAtLeastOneElement,
508
+ elementCollection.Count));
509
+ }
510
+
511
+ CollectionSymbol symbol = new CollectionSymbol(elementCollection);
512
+ this.collectionStack.Push(symbol);
513
+ this.FindNext(symbol);
514
+ }
515
+
516
+ /// <summary>
517
+ /// Finds the next item from a given symbol.
518
+ /// </summary>
519
+ /// <param name="symbol">The symbol to start looking from.</param>
520
+ /// <returns>True if a next element is found, false otherwise.</returns>
521
+ private bool FindNext(CollectionSymbol symbol)
522
+ {
523
+ object container = symbol.Collection.items[symbol.ContainerIndex];
524
+
525
+ CollectionItem collectionItem = container as CollectionItem;
526
+ if (collectionItem != null)
527
+ {
528
+ if (symbol.ItemIndex + 1 < collectionItem.Elements.Count)
529
+ {
530
+ symbol.ItemIndex++;
531
+ return true;
532
+ }
533
+ }
534
+
535
+ ElementCollection elementCollection = container as ElementCollection;
536
+ if (elementCollection != null && elementCollection.Count > 0 && symbol.ItemIndex == -1)
537
+ {
538
+ symbol.ItemIndex++;
539
+ this.PushCollection(elementCollection);
540
+ return true;
541
+ }
542
+
543
+ symbol.ItemIndex = 0;
544
+
545
+ for (int i = symbol.ContainerIndex + 1; i < symbol.Collection.items.Count; ++i)
546
+ {
547
+ object nestedContainer = symbol.Collection.items[i];
548
+
549
+ CollectionItem nestedCollectionItem = nestedContainer as CollectionItem;
550
+ if (nestedCollectionItem != null)
551
+ {
552
+ if (nestedCollectionItem.Elements.Count > 0)
553
+ {
554
+ symbol.ContainerIndex = i;
555
+ return true;
556
+ }
557
+ }
558
+
559
+ ElementCollection nestedElementCollection = nestedContainer as ElementCollection;
560
+ if (nestedElementCollection != null && nestedElementCollection.Count > 0)
561
+ {
562
+ symbol.ContainerIndex = i;
563
+ this.PushCollection(nestedElementCollection);
564
+ return true;
565
+ }
566
+ }
567
+
568
+ return false;
569
+ }
570
+
571
+ /// <summary>
572
+ /// Class representing a single point in the collection. Consists of an ElementCollection,
573
+ /// a container index, and an index into the container.
574
+ /// </summary>
575
+ private class CollectionSymbol
576
+ {
577
+ private ElementCollection collection;
578
+ private int containerIndex;
579
+ private int itemIndex = -1;
580
+
581
+ /// <summary>
582
+ /// Creates a new CollectionSymbol.
583
+ /// </summary>
584
+ /// <param name="collection">The collection for the symbol.</param>
585
+ public CollectionSymbol(ElementCollection collection)
586
+ {
587
+ this.collection = collection;
588
+ }
589
+
590
+ /// <summary>
591
+ /// Gets the collection for the symbol.
592
+ /// </summary>
593
+ public ElementCollection Collection
594
+ {
595
+ get { return this.collection; }
596
+ }
597
+
598
+ /// <summary>
599
+ /// Gets and sets the index of the container in the collection.
600
+ /// </summary>
601
+ public int ContainerIndex
602
+ {
603
+ get { return this.containerIndex; }
604
+ set { this.containerIndex = value; }
605
+ }
606
+
607
+ /// <summary>
608
+ /// Gets and sets the index of the item in the container.
609
+ /// </summary>
610
+ public int ItemIndex
611
+ {
612
+ get { return this.itemIndex; }
613
+ set { this.itemIndex = value; }
614
+ }
615
+ }
616
+ }
617
+ }
618
+}
src/heat/Serialize/WixHarvesterStrings.Designer.cs
new
+153
@@ -0,0 +1,153 @@
1
+//------------------------------------------------------------------------------
2
+// <auto-generated>
3
+// This code was generated by a tool.
4
+// Runtime Version:4.0.30319.42000
5
+//
6
+// Changes to this file may cause incorrect behavior and will be lost if
7
+// the code is regenerated.
8
+// </auto-generated>
9
+//------------------------------------------------------------------------------
10
+
11
+namespace WixToolset.Harvesters.Extensibility.Serialize {
12
+ using System;
13
+
14
+
15
+ /// <summary>
16
+ /// A strongly-typed resource class, for looking up localized strings, etc.
17
+ /// </summary>
18
+ // This class was auto-generated by the StronglyTypedResourceBuilder
19
+ // class via a tool like ResGen or Visual Studio.
20
+ // To add or remove a member, edit your .ResX file then rerun ResGen
21
+ // with the /str option, or rebuild your VS project.
22
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
23
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25
+ internal class WixHarvesterStrings {
26
+
27
+ private static global::System.Resources.ResourceManager resourceMan;
28
+
29
+ private static global::System.Globalization.CultureInfo resourceCulture;
30
+
31
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32
+ internal WixHarvesterStrings() {
33
+ }
34
+
35
+ /// <summary>
36
+ /// Returns the cached ResourceManager instance used by this class.
37
+ /// </summary>
38
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39
+ internal static global::System.Resources.ResourceManager ResourceManager {
40
+ get {
41
+ if (object.ReferenceEquals(resourceMan, null)) {
42
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WixToolset.Harvesters.Extensibility.Serialize.WixHarvesterStrings", typeof(WixHarvesterStrings).Assembly);
43
+ resourceMan = temp;
44
+ }
45
+ return resourceMan;
46
+ }
47
+ }
48
+
49
+ /// <summary>
50
+ /// Overrides the current thread's CurrentUICulture property for all
51
+ /// resource lookups using this strongly typed resource class.
52
+ /// </summary>
53
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54
+ internal static global::System.Globalization.CultureInfo Culture {
55
+ get {
56
+ return resourceCulture;
57
+ }
58
+ set {
59
+ resourceCulture = value;
60
+ }
61
+ }
62
+
63
+ /// <summary>
64
+ /// Looks up a localized string similar to Collection has {0} elements. Must have at least one..
65
+ /// </summary>
66
+ internal static string EXP_CollectionMustHaveAtLeastOneElement {
67
+ get {
68
+ return ResourceManager.GetString("EXP_CollectionMustHaveAtLeastOneElement", resourceCulture);
69
+ }
70
+ }
71
+
72
+ /// <summary>
73
+ /// Looks up a localized string similar to Element must be a subclass of {0}, but was of type {1}..
74
+ /// </summary>
75
+ internal static string EXP_ElementIsSubclassOfDifferentType {
76
+ get {
77
+ return ResourceManager.GetString("EXP_ElementIsSubclassOfDifferentType", resourceCulture);
78
+ }
79
+ }
80
+
81
+ /// <summary>
82
+ /// Looks up a localized string similar to Element of type {0} found in enumerator. Must be ChoiceItem or SequenceItem..
83
+ /// </summary>
84
+ internal static string EXP_ElementMustBeChoiceItemOrSequenceItem {
85
+ get {
86
+ return ResourceManager.GetString("EXP_ElementMustBeChoiceItemOrSequenceItem", resourceCulture);
87
+ }
88
+ }
89
+
90
+ /// <summary>
91
+ /// Looks up a localized string similar to Element of type {0} is not valid for this collection..
92
+ /// </summary>
93
+ internal static string EXP_ElementOfTypeIsNotValidForThisCollection {
94
+ get {
95
+ return ResourceManager.GetString("EXP_ElementOfTypeIsNotValidForThisCollection", resourceCulture);
96
+ }
97
+ }
98
+
99
+ /// <summary>
100
+ /// Looks up a localized string similar to ISchemaElement with name {0} does not implement ICreateChildren..
101
+ /// </summary>
102
+ internal static string EXP_ISchemaElementDoesnotImplementICreateChildren {
103
+ get {
104
+ return ResourceManager.GetString("EXP_ISchemaElementDoesnotImplementICreateChildren", resourceCulture);
105
+ }
106
+ }
107
+
108
+ /// <summary>
109
+ /// Looks up a localized string similar to ISchemaElement with name {0} does not implement ISetAttributes..
110
+ /// </summary>
111
+ internal static string EXP_ISchemaElementDoesnotImplementISetAttribute {
112
+ get {
113
+ return ResourceManager.GetString("EXP_ISchemaElementDoesnotImplementISetAttribute", resourceCulture);
114
+ }
115
+ }
116
+
117
+ /// <summary>
118
+ /// Looks up a localized string similar to A Merge table FileCompression column contains an invalid value '{0}'..
119
+ /// </summary>
120
+ internal static string EXP_MergeTableFileCompressionColumnContainsInvalidValue {
121
+ get {
122
+ return ResourceManager.GetString("EXP_MergeTableFileCompressionColumnContainsInvalidValue", resourceCulture);
123
+ }
124
+ }
125
+
126
+ /// <summary>
127
+ /// Looks up a localized string similar to Multiple root elements found in file..
128
+ /// </summary>
129
+ internal static string EXP_MultipleRootElementsFoundInFile {
130
+ get {
131
+ return ResourceManager.GetString("EXP_MultipleRootElementsFoundInFile", resourceCulture);
132
+ }
133
+ }
134
+
135
+ /// <summary>
136
+ /// Looks up a localized string similar to Type {0} is not valid for this collection..
137
+ /// </summary>
138
+ internal static string EXP_TypeIsNotValidForThisCollection {
139
+ get {
140
+ return ResourceManager.GetString("EXP_TypeIsNotValidForThisCollection", resourceCulture);
141
+ }
142
+ }
143
+
144
+ /// <summary>
145
+ /// Looks up a localized string similar to XmlElement with name {0} does not have a corresponding ISchemaElement..
146
+ /// </summary>
147
+ internal static string EXP_XmlElementDoesnotHaveISchemaElement {
148
+ get {
149
+ return ResourceManager.GetString("EXP_XmlElementDoesnotHaveISchemaElement", resourceCulture);
150
+ }
151
+ }
152
+ }
153
+}
src/heat/Serialize/WixHarvesterStrings.resx
new
+150
@@ -0,0 +1,150 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<root>
3
+ <!--
4
+ Microsoft ResX Schema
5
+
6
+ Version 2.0
7
+
8
+ The primary goals of this format is to allow a simple XML format
9
+ that is mostly human readable. The generation and parsing of the
10
+ various data types are done through the TypeConverter classes
11
+ associated with the data types.
12
+
13
+ Example:
14
+
15
+ ... ado.net/XML headers & schema ...
16
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
17
+ <resheader name="version">2.0</resheader>
18
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
19
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
20
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
21
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
22
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
23
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
24
+ </data>
25
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
26
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
27
+ <comment>This is a comment</comment>
28
+ </data>
29
+
30
+ There are any number of "resheader" rows that contain simple
31
+ name/value pairs.
32
+
33
+ Each data row contains a name, and value. The row also contains a
34
+ type or mimetype. Type corresponds to a .NET class that support
35
+ text/value conversion through the TypeConverter architecture.
36
+ Classes that don't support this are serialized and stored with the
37
+ mimetype set.
38
+
39
+ The mimetype is used for serialized objects, and tells the
40
+ ResXResourceReader how to depersist the object. This is currently not
41
+ extensible. For a given mimetype the value must be set accordingly:
42
+
43
+ Note - application/x-microsoft.net.object.binary.base64 is the format
44
+ that the ResXResourceWriter will generate, however the reader can
45
+ read any of the formats listed below.
46
+
47
+ mimetype: application/x-microsoft.net.object.binary.base64
48
+ value : The object must be serialized with
49
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
50
+ : and then encoded with base64 encoding.
51
+
52
+ mimetype: application/x-microsoft.net.object.soap.base64
53
+ value : The object must be serialized with
54
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
55
+ : and then encoded with base64 encoding.
56
+
57
+ mimetype: application/x-microsoft.net.object.bytearray.base64
58
+ value : The object must be serialized into a byte array
59
+ : using a System.ComponentModel.TypeConverter
60
+ : and then encoded with base64 encoding.
61
+ -->
62
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
63
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
64
+ <xsd:element name="root" msdata:IsDataSet="true">
65
+ <xsd:complexType>
66
+ <xsd:choice maxOccurs="unbounded">
67
+ <xsd:element name="metadata">
68
+ <xsd:complexType>
69
+ <xsd:sequence>
70
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
71
+ </xsd:sequence>
72
+ <xsd:attribute name="name" use="required" type="xsd:string" />
73
+ <xsd:attribute name="type" type="xsd:string" />
74
+ <xsd:attribute name="mimetype" type="xsd:string" />
75
+ <xsd:attribute ref="xml:space" />
76
+ </xsd:complexType>
77
+ </xsd:element>
78
+ <xsd:element name="assembly">
79
+ <xsd:complexType>
80
+ <xsd:attribute name="alias" type="xsd:string" />
81
+ <xsd:attribute name="name" type="xsd:string" />
82
+ </xsd:complexType>
83
+ </xsd:element>
84
+ <xsd:element name="data">
85
+ <xsd:complexType>
86
+ <xsd:sequence>
87
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
88
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
89
+ </xsd:sequence>
90
+ <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
91
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
92
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
93
+ <xsd:attribute ref="xml:space" />
94
+ </xsd:complexType>
95
+ </xsd:element>
96
+ <xsd:element name="resheader">
97
+ <xsd:complexType>
98
+ <xsd:sequence>
99
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
100
+ </xsd:sequence>
101
+ <xsd:attribute name="name" type="xsd:string" use="required" />
102
+ </xsd:complexType>
103
+ </xsd:element>
104
+ </xsd:choice>
105
+ </xsd:complexType>
106
+ </xsd:element>
107
+ </xsd:schema>
108
+ <resheader name="resmimetype">
109
+ <value>text/microsoft-resx</value>
110
+ </resheader>
111
+ <resheader name="version">
112
+ <value>2.0</value>
113
+ </resheader>
114
+ <resheader name="reader">
115
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
116
+ </resheader>
117
+ <resheader name="writer">
118
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119
+ </resheader>
120
+ <data name="EXP_MergeTableFileCompressionColumnContainsInvalidValue" xml:space="preserve">
121
+ <value>A Merge table FileCompression column contains an invalid value '{0}'.</value>
122
+ </data>
123
+ <data name="EXP_MultipleRootElementsFoundInFile" xml:space="preserve">
124
+ <value>Multiple root elements found in file.</value>
125
+ </data>
126
+ <data name="EXP_ISchemaElementDoesnotImplementICreateChildren" xml:space="preserve">
127
+ <value>ISchemaElement with name {0} does not implement ICreateChildren.</value>
128
+ </data>
129
+ <data name="EXP_ISchemaElementDoesnotImplementISetAttribute" xml:space="preserve">
130
+ <value>ISchemaElement with name {0} does not implement ISetAttributes.</value>
131
+ </data>
132
+ <data name="EXP_XmlElementDoesnotHaveISchemaElement" xml:space="preserve">
133
+ <value>XmlElement with name {0} does not have a corresponding ISchemaElement.</value>
134
+ </data>
135
+ <data name="EXP_ElementOfTypeIsNotValidForThisCollection" xml:space="preserve">
136
+ <value>Element of type {0} is not valid for this collection.</value>
137
+ </data>
138
+ <data name="EXP_TypeIsNotValidForThisCollection" xml:space="preserve">
139
+ <value>Type {0} is not valid for this collection.</value>
140
+ </data>
141
+ <data name="EXP_CollectionMustHaveAtLeastOneElement" xml:space="preserve">
142
+ <value>Collection has {0} elements. Must have at least one.</value>
143
+ </data>
144
+ <data name="EXP_ElementIsSubclassOfDifferentType" xml:space="preserve">
145
+ <value>Element must be a subclass of {0}, but was of type {1}.</value>
146
+ </data>
147
+ <data name="EXP_ElementMustBeChoiceItemOrSequenceItem" xml:space="preserve">
148
+ <value>Element of type {0} found in enumerator. Must be ChoiceItem or SequenceItem.</value>
149
+ </data>
150
+</root>
\ No newline at end of file
src/heat/Serialize/iis.cs
new
+5915
@@ -0,0 +1,5915 @@
1
+//------------------------------------------------------------------------------
2
+// <auto-generated>
3
+// This code was generated by a tool.
4
+// Runtime Version:4.0.30319.42000
5
+//
6
+// Changes to this file may cause incorrect behavior and will be lost if
7
+// the code is regenerated.
8
+// </auto-generated>
9
+//------------------------------------------------------------------------------
10
+
11
+#pragma warning disable 1591
12
+namespace WixToolset.Harvesters.Serialize.IIs
13
+{
14
+ using System;
15
+ using System.CodeDom.Compiler;
16
+ using System.Collections;
17
+ using System.Diagnostics.CodeAnalysis;
18
+ using System.Globalization;
19
+ using System.Xml;
20
+ using WixToolset.Harvesters.Serialize;
21
+
22
+
23
+ /// <summary>
24
+ /// Values of this type will either be "yes" or "no".
25
+ /// </summary>
26
+ [GeneratedCode("XsdGen", "4.0.0.0")]
27
+ public enum YesNoType
28
+ {
29
+
30
+ IllegalValue = int.MaxValue,
31
+
32
+ NotSet = -1,
33
+
34
+ no,
35
+
36
+ yes,
37
+ }
38
+
39
+ [GeneratedCode("XsdGen", "4.0.0.0")]
40
+ public class Enums
41
+ {
42
+
43
+ /// <summary>
44
+ /// Parses a YesNoType from a string.
45
+ /// </summary>
46
+ public static YesNoType ParseYesNoType(string value)
47
+ {
48
+ YesNoType parsedValue;
49
+ Enums.TryParseYesNoType(value, out parsedValue);
50
+ return parsedValue;
51
+ }
52
+
53
+ /// <summary>
54
+ /// Tries to parse a YesNoType from a string.
55
+ /// </summary>
56
+ public static bool TryParseYesNoType(string value, out YesNoType parsedValue)
57
+ {
58
+ parsedValue = YesNoType.NotSet;
59
+ if (string.IsNullOrEmpty(value))
60
+ {
61
+ return false;
62
+ }
63
+ if (("no" == value))
64
+ {
65
+ parsedValue = YesNoType.no;
66
+ }
67
+ else
68
+ {
69
+ if (("yes" == value))
70
+ {
71
+ parsedValue = YesNoType.yes;
72
+ }
73
+ else
74
+ {
75
+ parsedValue = YesNoType.IllegalValue;
76
+ return false;
77
+ }
78
+ }
79
+ return true;
80
+ }
81
+
82
+ /// <summary>
83
+ /// Parses a YesNoDefaultType from a string.
84
+ /// </summary>
85
+ public static YesNoDefaultType ParseYesNoDefaultType(string value)
86
+ {
87
+ YesNoDefaultType parsedValue;
88
+ Enums.TryParseYesNoDefaultType(value, out parsedValue);
89
+ return parsedValue;
90
+ }
91
+
92
+ /// <summary>
93
+ /// Tries to parse a YesNoDefaultType from a string.
94
+ /// </summary>
95
+ public static bool TryParseYesNoDefaultType(string value, out YesNoDefaultType parsedValue)
96
+ {
97
+ parsedValue = YesNoDefaultType.NotSet;
98
+ if (string.IsNullOrEmpty(value))
99
+ {
100
+ return false;
101
+ }
102
+ if (("default" == value))
103
+ {
104
+ parsedValue = YesNoDefaultType.@default;
105
+ }
106
+ else
107
+ {
108
+ if (("no" == value))
109
+ {
110
+ parsedValue = YesNoDefaultType.no;
111
+ }
112
+ else
113
+ {
114
+ if (("yes" == value))
115
+ {
116
+ parsedValue = YesNoDefaultType.yes;
117
+ }
118
+ else
119
+ {
120
+ parsedValue = YesNoDefaultType.IllegalValue;
121
+ return false;
122
+ }
123
+ }
124
+ }
125
+ return true;
126
+ }
127
+ }
128
+
129
+ /// <summary>
130
+ /// Values of this type will either be "default", "yes", or "no".
131
+ /// </summary>
132
+ [GeneratedCode("XsdGen", "4.0.0.0")]
133
+ public enum YesNoDefaultType
134
+ {
135
+
136
+ IllegalValue = int.MaxValue,
137
+
138
+ NotSet = -1,
139
+
140
+ @default,
141
+
142
+ no,
143
+
144
+ yes,
145
+ }
146
+
147
+ /// <summary>
148
+ /// WebDirProperties used by one or more WebSites. Lists properties common to IIS web sites and vroots. Corresponding properties can be viewed through the IIS Manager snap-in. One property entry can be reused by multiple sites or vroots using the Id field as a reference, using WebVirtualDir.DirProperties, WebSite.DirProperties, or WebDir.DirProperties.
149
+ /// </summary>
150
+ [GeneratedCode("XsdGen", "4.0.0.0")]
151
+ public class WebDirProperties : ISchemaElement, ISetAttributes
152
+ {
153
+
154
+ private string idField;
155
+
156
+ private bool idFieldSet;
157
+
158
+ private YesNoType readField;
159
+
160
+ private bool readFieldSet;
161
+
162
+ private YesNoType writeField;
163
+
164
+ private bool writeFieldSet;
165
+
166
+ private YesNoType scriptField;
167
+
168
+ private bool scriptFieldSet;
169
+
170
+ private YesNoType executeField;
171
+
172
+ private bool executeFieldSet;
173
+
174
+ private YesNoType anonymousAccessField;
175
+
176
+ private bool anonymousAccessFieldSet;
177
+
178
+ private string anonymousUserField;
179
+
180
+ private bool anonymousUserFieldSet;
181
+
182
+ private YesNoType iIsControlledPasswordField;
183
+
184
+ private bool iIsControlledPasswordFieldSet;
185
+
186
+ private YesNoType windowsAuthenticationField;
187
+
188
+ private bool windowsAuthenticationFieldSet;
189
+
190
+ private YesNoType digestAuthenticationField;
191
+
192
+ private bool digestAuthenticationFieldSet;
193
+
194
+ private YesNoType basicAuthenticationField;
195
+
196
+ private bool basicAuthenticationFieldSet;
197
+
198
+ private YesNoType passportAuthenticationField;
199
+
200
+ private bool passportAuthenticationFieldSet;
201
+
202
+ private YesNoType logVisitsField;
203
+
204
+ private bool logVisitsFieldSet;
205
+
206
+ private YesNoType indexField;
207
+
208
+ private bool indexFieldSet;
209
+
210
+ private string defaultDocumentsField;
211
+
212
+ private bool defaultDocumentsFieldSet;
213
+
214
+ private YesNoType aspDetailedErrorField;
215
+
216
+ private bool aspDetailedErrorFieldSet;
217
+
218
+ private string httpExpiresField;
219
+
220
+ private bool httpExpiresFieldSet;
221
+
222
+ private long cacheControlMaxAgeField;
223
+
224
+ private bool cacheControlMaxAgeFieldSet;
225
+
226
+ private string cacheControlCustomField;
227
+
228
+ private bool cacheControlCustomFieldSet;
229
+
230
+ private YesNoType clearCustomErrorField;
231
+
232
+ private bool clearCustomErrorFieldSet;
233
+
234
+ private YesNoType accessSSLField;
235
+
236
+ private bool accessSSLFieldSet;
237
+
238
+ private YesNoType accessSSL128Field;
239
+
240
+ private bool accessSSL128FieldSet;
241
+
242
+ private YesNoType accessSSLMapCertField;
243
+
244
+ private bool accessSSLMapCertFieldSet;
245
+
246
+ private YesNoType accessSSLNegotiateCertField;
247
+
248
+ private bool accessSSLNegotiateCertFieldSet;
249
+
250
+ private YesNoType accessSSLRequireCertField;
251
+
252
+ private bool accessSSLRequireCertFieldSet;
253
+
254
+ private string authenticationProvidersField;
255
+
256
+ private bool authenticationProvidersFieldSet;
257
+
258
+ private ISchemaElement parentElement;
259
+
260
+ public string Id
261
+ {
262
+ get
263
+ {
264
+ return this.idField;
265
+ }
266
+ set
267
+ {
268
+ this.idFieldSet = true;
269
+ this.idField = value;
270
+ }
271
+ }
272
+
273
+ public YesNoType Read
274
+ {
275
+ get
276
+ {
277
+ return this.readField;
278
+ }
279
+ set
280
+ {
281
+ this.readFieldSet = true;
282
+ this.readField = value;
283
+ }
284
+ }
285
+
286
+ public YesNoType Write
287
+ {
288
+ get
289
+ {
290
+ return this.writeField;
291
+ }
292
+ set
293
+ {
294
+ this.writeFieldSet = true;
295
+ this.writeField = value;
296
+ }
297
+ }
298
+
299
+ public YesNoType Script
300
+ {
301
+ get
302
+ {
303
+ return this.scriptField;
304
+ }
305
+ set
306
+ {
307
+ this.scriptFieldSet = true;
308
+ this.scriptField = value;
309
+ }
310
+ }
311
+
312
+ public YesNoType Execute
313
+ {
314
+ get
315
+ {
316
+ return this.executeField;
317
+ }
318
+ set
319
+ {
320
+ this.executeFieldSet = true;
321
+ this.executeField = value;
322
+ }
323
+ }
324
+
325
+ /// <summary>
326
+ /// Sets the Enable Anonymous Access checkbox, which maps anonymous users to a Windows user account. When setting this to 'yes' you should also provide the user account using the AnonymousUser attribute, and determine what setting to use for the IIsControlledPassword attribute. Defaults to 'no.'
327
+ /// </summary>
328
+ public YesNoType AnonymousAccess
329
+ {
330
+ get
331
+ {
332
+ return this.anonymousAccessField;
333
+ }
334
+ set
335
+ {
336
+ this.anonymousAccessFieldSet = true;
337
+ this.anonymousAccessField = value;
338
+ }
339
+ }
340
+
341
+ /// <summary>
342
+ /// Reference to the Id attribute on the User element to be used as the anonymous user for the directory. See the User element for more information.
343
+ /// </summary>
344
+ public string AnonymousUser
345
+ {
346
+ get
347
+ {
348
+ return this.anonymousUserField;
349
+ }
350
+ set
351
+ {
352
+ this.anonymousUserFieldSet = true;
353
+ this.anonymousUserField = value;
354
+ }
355
+ }
356
+
357
+ /// <summary>
358
+ /// Sets whether IIS should control the password used for the Windows account specified in the AnonymousUser attribute. Defaults to 'no.'
359
+ /// </summary>
360
+ public YesNoType IIsControlledPassword
361
+ {
362
+ get
363
+ {
364
+ return this.iIsControlledPasswordField;
365
+ }
366
+ set
367
+ {
368
+ this.iIsControlledPasswordFieldSet = true;
369
+ this.iIsControlledPasswordField = value;
370
+ }
371
+ }
372
+
373
+ /// <summary>
374
+ /// Sets the Windows Authentication option, which enables integrated Windows authentication to be used on the site. Defaults to 'no.'
375
+ /// </summary>
376
+ public YesNoType WindowsAuthentication
377
+ {
378
+ get
379
+ {
380
+ return this.windowsAuthenticationField;
381
+ }
382
+ set
383
+ {
384
+ this.windowsAuthenticationFieldSet = true;
385
+ this.windowsAuthenticationField = value;
386
+ }
387
+ }
388
+
389
+ /// <summary>
390
+ /// Sets the Digest Authentication option, which allows using digest authentication with domain user accounts. Defaults to 'no.'
391
+ /// </summary>
392
+ public YesNoType DigestAuthentication
393
+ {
394
+ get
395
+ {
396
+ return this.digestAuthenticationField;
397
+ }
398
+ set
399
+ {
400
+ this.digestAuthenticationFieldSet = true;
401
+ this.digestAuthenticationField = value;
402
+ }
403
+ }
404
+
405
+ /// <summary>
406
+ /// Sets the Basic Authentication option, which allows clients to provide credentials in plaintext over the wire. Defaults to 'no.'
407
+ /// </summary>
408
+ public YesNoType BasicAuthentication
409
+ {
410
+ get
411
+ {
412
+ return this.basicAuthenticationField;
413
+ }
414
+ set
415
+ {
416
+ this.basicAuthenticationFieldSet = true;
417
+ this.basicAuthenticationField = value;
418
+ }
419
+ }
420
+
421
+ /// <summary>
422
+ /// Sets the Passport Authentication option, which allows clients to provide credentials via a .Net Passport account. Defaults to 'no.'
423
+ /// </summary>
424
+ public YesNoType PassportAuthentication
425
+ {
426
+ get
427
+ {
428
+ return this.passportAuthenticationField;
429
+ }
430
+ set
431
+ {
432
+ this.passportAuthenticationFieldSet = true;
433
+ this.passportAuthenticationField = value;
434
+ }
435
+ }
436
+
437
+ /// <summary>
438
+ /// Sets whether visits to this site should be logged. Defaults to 'no.'
439
+ /// </summary>
440
+ public YesNoType LogVisits
441
+ {
442
+ get
443
+ {
444
+ return this.logVisitsField;
445
+ }
446
+ set
447
+ {
448
+ this.logVisitsFieldSet = true;
449
+ this.logVisitsField = value;
450
+ }
451
+ }
452
+
453
+ /// <summary>
454
+ /// Sets the Index Resource option, which specifies whether this web directory should be indexed. Defaults to 'no.'
455
+ /// </summary>
456
+ public YesNoType Index
457
+ {
458
+ get
459
+ {
460
+ return this.indexField;
461
+ }
462
+ set
463
+ {
464
+ this.indexFieldSet = true;
465
+ this.indexField = value;
466
+ }
467
+ }
468
+
469
+ /// <summary>
470
+ /// The list of default documents to set for this web directory, in comma-delimited format.
471
+ /// </summary>
472
+ public string DefaultDocuments
473
+ {
474
+ get
475
+ {
476
+ return this.defaultDocumentsField;
477
+ }
478
+ set
479
+ {
480
+ this.defaultDocumentsFieldSet = true;
481
+ this.defaultDocumentsField = value;
482
+ }
483
+ }
484
+
485
+ /// <summary>
486
+ /// Sets the option for whether to send detailed ASP errors back to the client on script error. Default is 'no.'
487
+ /// </summary>
488
+ public YesNoType AspDetailedError
489
+ {
490
+ get
491
+ {
492
+ return this.aspDetailedErrorField;
493
+ }
494
+ set
495
+ {
496
+ this.aspDetailedErrorFieldSet = true;
497
+ this.aspDetailedErrorField = value;
498
+ }
499
+ }
500
+
501
+ /// <summary>
502
+ /// Value to set the HttpExpires attribute to for a Web Dir in the metabase.
503
+ /// </summary>
504
+ public string HttpExpires
505
+ {
506
+ get
507
+ {
508
+ return this.httpExpiresField;
509
+ }
510
+ set
511
+ {
512
+ this.httpExpiresFieldSet = true;
513
+ this.httpExpiresField = value;
514
+ }
515
+ }
516
+
517
+ /// <summary>
518
+ /// Integer value specifying the cache control maximum age value.
519
+ /// </summary>
520
+ public long CacheControlMaxAge
521
+ {
522
+ get
523
+ {
524
+ return this.cacheControlMaxAgeField;
525
+ }
526
+ set
527
+ {
528
+ this.cacheControlMaxAgeFieldSet = true;
529
+ this.cacheControlMaxAgeField = value;
530
+ }
531
+ }
532
+
533
+ /// <summary>
534
+ /// Custom HTTP 1.1 cache control directives.
535
+ /// </summary>
536
+ public string CacheControlCustom
537
+ {
538
+ get
539
+ {
540
+ return this.cacheControlCustomField;
541
+ }
542
+ set
543
+ {
544
+ this.cacheControlCustomFieldSet = true;
545
+ this.cacheControlCustomField = value;
546
+ }
547
+ }
548
+
549
+ /// <summary>
550
+ /// Specifies whether IIs will return custom errors for this directory.
551
+ /// </summary>
552
+ public YesNoType ClearCustomError
553
+ {
554
+ get
555
+ {
556
+ return this.clearCustomErrorField;
557
+ }
558
+ set
559
+ {
560
+ this.clearCustomErrorFieldSet = true;
561
+ this.clearCustomErrorField = value;
562
+ }
563
+ }
564
+
565
+ /// <summary>
566
+ /// A value of true indicates that file access requires SSL file permission processing, with or without a client certificate. This corresponds to AccessSSL flag for AccessSSLFlags IIS metabase property.
567
+ /// </summary>
568
+ [SuppressMessage("Microsoft.Naming", "CA1705:LongAcronymsShouldBePascalCased")]
569
+ public YesNoType AccessSSL
570
+ {
571
+ get
572
+ {
573
+ return this.accessSSLField;
574
+ }
575
+ set
576
+ {
577
+ this.accessSSLFieldSet = true;
578
+ this.accessSSLField = value;
579
+ }
580
+ }
581
+
582
+ /// <summary>
583
+ /// A value of true indicates that file access requires SSL file permission processing with a minimum key size of 128 bits, with or without a client certificate. This corresponds to AccessSSL128 flag for AccessSSLFlags IIS metabase property.
584
+ /// </summary>
585
+ [SuppressMessage("Microsoft.Naming", "CA1705:LongAcronymsShouldBePascalCased")]
586
+ public YesNoType AccessSSL128
587
+ {
588
+ get
589
+ {
590
+ return this.accessSSL128Field;
591
+ }
592
+ set
593
+ {
594
+ this.accessSSL128FieldSet = true;
595
+ this.accessSSL128Field = value;
596
+ }
597
+ }
598
+
599
+ /// <summary>
600
+ /// This corresponds to AccessSSLMapCert flag for AccessSSLFlags IIS metabase property.
601
+ /// </summary>
602
+ [SuppressMessage("Microsoft.Naming", "CA1705:LongAcronymsShouldBePascalCased")]
603
+ public YesNoType AccessSSLMapCert
604
+ {
605
+ get
606
+ {
607
+ return this.accessSSLMapCertField;
608
+ }
609
+ set
610
+ {
611
+ this.accessSSLMapCertFieldSet = true;
612
+ this.accessSSLMapCertField = value;
613
+ }
614
+ }
615
+
616
+ /// <summary>
617
+ /// This corresponds to AccessSSLNegotiateCert flag for AccessSSLFlags IIS metabase property.
618
+ /// </summary>
619
+ [SuppressMessage("Microsoft.Naming", "CA1705:LongAcronymsShouldBePascalCased")]
620
+ public YesNoType AccessSSLNegotiateCert
621
+ {
622
+ get
623
+ {
624
+ return this.accessSSLNegotiateCertField;
625
+ }
626
+ set
627
+ {
628
+ this.accessSSLNegotiateCertFieldSet = true;
629
+ this.accessSSLNegotiateCertField = value;
630
+ }
631
+ }
632
+
633
+ /// <summary>
634
+ /// This corresponds to AccessSSLRequireCert flag for AccessSSLFlags IIS metabase property.
635
+ /// </summary>
636
+ [SuppressMessage("Microsoft.Naming", "CA1705:LongAcronymsShouldBePascalCased")]
637
+ public YesNoType AccessSSLRequireCert
638
+ {
639
+ get
640
+ {
641
+ return this.accessSSLRequireCertField;
642
+ }
643
+ set
644
+ {
645
+ this.accessSSLRequireCertFieldSet = true;
646
+ this.accessSSLRequireCertField = value;
647
+ }
648
+ }
649
+
650
+ /// <summary>
651
+ /// Comma delimited list, in order of precedence, of Windows authentication providers that IIS will attempt to use: NTLM, Kerberos, Negotiate, and others.
652
+ /// </summary>
653
+ public string AuthenticationProviders
654
+ {
655
+ get
656
+ {
657
+ return this.authenticationProvidersField;
658
+ }
659
+ set
660
+ {
661
+ this.authenticationProvidersFieldSet = true;
662
+ this.authenticationProvidersField = value;
663
+ }
664
+ }
665
+
666
+ public virtual ISchemaElement ParentElement
667
+ {
668
+ get
669
+ {
670
+ return this.parentElement;
671
+ }
672
+ set
673
+ {
674
+ this.parentElement = value;
675
+ }
676
+ }
677
+
678
+ /// <summary>
679
+ /// Processes this element and all child elements into an XmlWriter.
680
+ /// </summary>
681
+ [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
682
+ public virtual void OutputXml(XmlWriter writer)
683
+ {
684
+ if ((null == writer))
685
+ {
686
+ throw new ArgumentNullException("writer");
687
+ }
688
+ writer.WriteStartElement("WebDirProperties", "http://wixtoolset.org/schemas/v4/wxs/iis");
689
+ if (this.idFieldSet)
690
+ {
691
+ writer.WriteAttributeString("Id", this.idField);
692
+ }
693
+ if (this.readFieldSet)
694
+ {
695
+ if ((this.readField == YesNoType.no))
696
+ {
697
+ writer.WriteAttributeString("Read", "no");
698
+ }
699
+ if ((this.readField == YesNoType.yes))
700
+ {
701
+ writer.WriteAttributeString("Read", "yes");
702
+ }
703
+ }
704
+ if (this.writeFieldSet)
705
+ {
706
+ if ((this.writeField == YesNoType.no))
707
+ {
708
+ writer.WriteAttributeString("Write", "no");
709
+ }
710
+ if ((this.writeField == YesNoType.yes))
711
+ {
712
+ writer.WriteAttributeString("Write", "yes");
713
+ }
714
+ }
715
+ if (this.scriptFieldSet)
716
+ {
717
+ if ((this.scriptField == YesNoType.no))
718
+ {
719
+ writer.WriteAttributeString("Script", "no");
720
+ }
721
+ if ((this.scriptField == YesNoType.yes))
722
+ {
723
+ writer.WriteAttributeString("Script", "yes");
724
+ }
725
+ }
726
+ if (this.executeFieldSet)
727
+ {
728
+ if ((this.executeField == YesNoType.no))
729
+ {
730
+ writer.WriteAttributeString("Execute", "no");
731
+ }
732
+ if ((this.executeField == YesNoType.yes))
733
+ {
734
+ writer.WriteAttributeString("Execute", "yes");
735
+ }
736
+ }
737
+ if (this.anonymousAccessFieldSet)
738
+ {
739
+ if ((this.anonymousAccessField == YesNoType.no))
740
+ {
741
+ writer.WriteAttributeString("AnonymousAccess", "no");
742
+ }
743
+ if ((this.anonymousAccessField == YesNoType.yes))
744
+ {
745
+ writer.WriteAttributeString("AnonymousAccess", "yes");
746
+ }
747
+ }
748
+ if (this.anonymousUserFieldSet)
749
+ {
750
+ writer.WriteAttributeString("AnonymousUser", this.anonymousUserField);
751
+ }
752
+ if (this.iIsControlledPasswordFieldSet)
753
+ {
754
+ if ((this.iIsControlledPasswordField == YesNoType.no))
755
+ {
756
+ writer.WriteAttributeString("IIsControlledPassword", "no");
757
+ }
758
+ if ((this.iIsControlledPasswordField == YesNoType.yes))
759
+ {
760
+ writer.WriteAttributeString("IIsControlledPassword", "yes");
761
+ }
762
+ }
763
+ if (this.windowsAuthenticationFieldSet)
764
+ {
765
+ if ((this.windowsAuthenticationField == YesNoType.no))
766
+ {
767
+ writer.WriteAttributeString("WindowsAuthentication", "no");
768
+ }
769
+ if ((this.windowsAuthenticationField == YesNoType.yes))
770
+ {
771
+ writer.WriteAttributeString("WindowsAuthentication", "yes");
772
+ }
773
+ }
774
+ if (this.digestAuthenticationFieldSet)
775
+ {
776
+ if ((this.digestAuthenticationField == YesNoType.no))
777
+ {
778
+ writer.WriteAttributeString("DigestAuthentication", "no");
779
+ }
780
+ if ((this.digestAuthenticationField == YesNoType.yes))
781
+ {
782
+ writer.WriteAttributeString("DigestAuthentication", "yes");
783
+ }
784
+ }
785
+ if (this.basicAuthenticationFieldSet)
786
+ {
787
+ if ((this.basicAuthenticationField == YesNoType.no))
788
+ {
789
+ writer.WriteAttributeString("BasicAuthentication", "no");
790
+ }
791
+ if ((this.basicAuthenticationField == YesNoType.yes))
792
+ {
793
+ writer.WriteAttributeString("BasicAuthentication", "yes");
794
+ }
795
+ }
796
+ if (this.passportAuthenticationFieldSet)
797
+ {
798
+ if ((this.passportAuthenticationField == YesNoType.no))
799
+ {
800
+ writer.WriteAttributeString("PassportAuthentication", "no");
801
+ }
802
+ if ((this.passportAuthenticationField == YesNoType.yes))
803
+ {
804
+ writer.WriteAttributeString("PassportAuthentication", "yes");
805
+ }
806
+ }
807
+ if (this.logVisitsFieldSet)
808
+ {
809
+ if ((this.logVisitsField == YesNoType.no))
810
+ {
811
+ writer.WriteAttributeString("LogVisits", "no");
812
+ }
813
+ if ((this.logVisitsField == YesNoType.yes))
814
+ {
815
+ writer.WriteAttributeString("LogVisits", "yes");
816
+ }
817
+ }
818
+ if (this.indexFieldSet)
819
+ {
820
+ if ((this.indexField == YesNoType.no))
821
+ {
822
+ writer.WriteAttributeString("Index", "no");
823
+ }
824
+ if ((this.indexField == YesNoType.yes))
825
+ {
826
+ writer.WriteAttributeString("Index", "yes");
827
+ }
828
+ }
829
+ if (this.defaultDocumentsFieldSet)
830
+ {
831
+ writer.WriteAttributeString("DefaultDocuments", this.defaultDocumentsField);
832
+ }
833
+ if (this.aspDetailedErrorFieldSet)
834
+ {
835
+ if ((this.aspDetailedErrorField == YesNoType.no))
836
+ {
837
+ writer.WriteAttributeString("AspDetailedError", "no");
838
+ }
839
+ if ((this.aspDetailedErrorField == YesNoType.yes))
840
+ {
841
+ writer.WriteAttributeString("AspDetailedError", "yes");
842
+ }
843
+ }
844
+ if (this.httpExpiresFieldSet)
845
+ {
846
+ writer.WriteAttributeString("HttpExpires", this.httpExpiresField);
847
+ }
848
+ if (this.cacheControlMaxAgeFieldSet)
849
+ {
850
+ writer.WriteAttributeString("CacheControlMaxAge", this.cacheControlMaxAgeField.ToString(CultureInfo.InvariantCulture));
851
+ }
852
+ if (this.cacheControlCustomFieldSet)
853
+ {
854
+ writer.WriteAttributeString("CacheControlCustom", this.cacheControlCustomField);
855
+ }
856
+ if (this.clearCustomErrorFieldSet)
857
+ {
858
+ if ((this.clearCustomErrorField == YesNoType.no))
859
+ {
860
+ writer.WriteAttributeString("ClearCustomError", "no");
861
+ }
862
+ if ((this.clearCustomErrorField == YesNoType.yes))
863
+ {
864
+ writer.WriteAttributeString("ClearCustomError", "yes");
865
+ }
866
+ }
867
+ if (this.accessSSLFieldSet)
868
+ {
869
+ if ((this.accessSSLField == YesNoType.no))
870
+ {
871
+ writer.WriteAttributeString("AccessSSL", "no");
872
+ }
873
+ if ((this.accessSSLField == YesNoType.yes))
874
+ {
875
+ writer.WriteAttributeString("AccessSSL", "yes");
876
+ }
877
+ }
878
+ if (this.accessSSL128FieldSet)
879
+ {
880
+ if ((this.accessSSL128Field == YesNoType.no))
881
+ {
882
+ writer.WriteAttributeString("AccessSSL128", "no");
883
+ }
884
+ if ((this.accessSSL128Field == YesNoType.yes))
885
+ {
886
+ writer.WriteAttributeString("AccessSSL128", "yes");
887
+ }
888
+ }
889
+ if (this.accessSSLMapCertFieldSet)
890
+ {
891
+ if ((this.accessSSLMapCertField == YesNoType.no))
892
+ {
893
+ writer.WriteAttributeString("AccessSSLMapCert", "no");
894
+ }
895
+ if ((this.accessSSLMapCertField == YesNoType.yes))
896
+ {
897
+ writer.WriteAttributeString("AccessSSLMapCert", "yes");
898
+ }
899
+ }
900
+ if (this.accessSSLNegotiateCertFieldSet)
901
+ {
902
+ if ((this.accessSSLNegotiateCertField == YesNoType.no))
903
+ {
904
+ writer.WriteAttributeString("AccessSSLNegotiateCert", "no");
905
+ }
906
+ if ((this.accessSSLNegotiateCertField == YesNoType.yes))
907
+ {
908
+ writer.WriteAttributeString("AccessSSLNegotiateCert", "yes");
909
+ }
910
+ }
911
+ if (this.accessSSLRequireCertFieldSet)
912
+ {
913
+ if ((this.accessSSLRequireCertField == YesNoType.no))
914
+ {
915
+ writer.WriteAttributeString("AccessSSLRequireCert", "no");
916
+ }
917
+ if ((this.accessSSLRequireCertField == YesNoType.yes))
918
+ {
919
+ writer.WriteAttributeString("AccessSSLRequireCert", "yes");
920
+ }
921
+ }
922
+ if (this.authenticationProvidersFieldSet)
923
+ {
924
+ writer.WriteAttributeString("AuthenticationProviders", this.authenticationProvidersField);
925
+ }
926
+ writer.WriteEndElement();
927
+ }
928
+
929
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
930
+ [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
931
+ void ISetAttributes.SetAttribute(string name, string value)
932
+ {
933
+ if (String.IsNullOrEmpty(name))
934
+ {
935
+ throw new ArgumentNullException("name");
936
+ }
937
+ if (("Id" == name))
938
+ {
939
+ this.idField = value;
940
+ this.idFieldSet = true;
941
+ }
942
+ if (("Read" == name))
943
+ {
944
+ this.readField = Enums.ParseYesNoType(value);
945
+ this.readFieldSet = true;
946
+ }
947
+ if (("Write" == name))
948
+ {
949
+ this.writeField = Enums.ParseYesNoType(value);
950
+ this.writeFieldSet = true;
951
+ }
952
+ if (("Script" == name))
953
+ {
954
+ this.scriptField = Enums.ParseYesNoType(value);
955
+ this.scriptFieldSet = true;
956
+ }
957
+ if (("Execute" == name))
958
+ {
959
+ this.executeField = Enums.ParseYesNoType(value);
960
+ this.executeFieldSet = true;
961
+ }
962
+ if (("AnonymousAccess" == name))
963
+ {
964
+ this.anonymousAccessField = Enums.ParseYesNoType(value);
965
+ this.anonymousAccessFieldSet = true;
966
+ }
967
+ if (("AnonymousUser" == name))
968
+ {
969
+ this.anonymousUserField = value;
970
+ this.anonymousUserFieldSet = true;
971
+ }
972
+ if (("IIsControlledPassword" == name))
973
+ {
974
+ this.iIsControlledPasswordField = Enums.ParseYesNoType(value);
975
+ this.iIsControlledPasswordFieldSet = true;
976
+ }
977
+ if (("WindowsAuthentication" == name))
978
+ {
979
+ this.windowsAuthenticationField = Enums.ParseYesNoType(value);
980
+ this.windowsAuthenticationFieldSet = true;
981
+ }
982
+ if (("DigestAuthentication" == name))
983
+ {
984
+ this.digestAuthenticationField = Enums.ParseYesNoType(value);
985
+ this.digestAuthenticationFieldSet = true;
986
+ }
987
+ if (("BasicAuthentication" == name))
988
+ {
989
+ this.basicAuthenticationField = Enums.ParseYesNoType(value);
990
+ this.basicAuthenticationFieldSet = true;
991
+ }
992
+ if (("PassportAuthentication" == name))
993
+ {
994
+ this.passportAuthenticationField = Enums.ParseYesNoType(value);
995
+ this.passportAuthenticationFieldSet = true;
996
+ }
997
+ if (("LogVisits" == name))
998
+ {
999
+ this.logVisitsField = Enums.ParseYesNoType(value);
1000
+ this.logVisitsFieldSet = true;
1001
+ }
1002
+ if (("Index" == name))
1003
+ {
1004
+ this.indexField = Enums.ParseYesNoType(value);
1005
+ this.indexFieldSet = true;
1006
+ }
1007
+ if (("DefaultDocuments" == name))
1008
+ {
1009
+ this.defaultDocumentsField = value;
1010
+ this.defaultDocumentsFieldSet = true;
1011
+ }
1012
+ if (("AspDetailedError" == name))
1013
+ {
1014
+ this.aspDetailedErrorField = Enums.ParseYesNoType(value);
1015
+ this.aspDetailedErrorFieldSet = true;
1016
+ }
1017
+ if (("HttpExpires" == name))
1018
+ {
1019
+ this.httpExpiresField = value;
1020
+ this.httpExpiresFieldSet = true;
1021
+ }
1022
+ if (("CacheControlMaxAge" == name))
1023
+ {
1024
+ this.cacheControlMaxAgeField = Convert.ToInt32(value, CultureInfo.InvariantCulture);
1025
+ this.cacheControlMaxAgeFieldSet = true;
1026
+ }
1027
+ if (("CacheControlCustom" == name))
1028
+ {
1029
+ this.cacheControlCustomField = value;
1030
+ this.cacheControlCustomFieldSet = true;
1031
+ }
1032
+ if (("ClearCustomError" == name))
1033
+ {
1034
+ this.clearCustomErrorField = Enums.ParseYesNoType(value);
1035
+ this.clearCustomErrorFieldSet = true;
1036
+ }
1037
+ if (("AccessSSL" == name))
1038
+ {
1039
+ this.accessSSLField = Enums.ParseYesNoType(value);
1040
+ this.accessSSLFieldSet = true;
1041
+ }
1042
+ if (("AccessSSL128" == name))
1043
+ {
1044
+ this.accessSSL128Field = Enums.ParseYesNoType(value);
1045
+ this.accessSSL128FieldSet = true;
1046
+ }
1047
+ if (("AccessSSLMapCert" == name))
1048
+ {
1049
+ this.accessSSLMapCertField = Enums.ParseYesNoType(value);
1050
+ this.accessSSLMapCertFieldSet = true;
1051
+ }
1052
+ if (("AccessSSLNegotiateCert" == name))
1053
+ {
1054
+ this.accessSSLNegotiateCertField = Enums.ParseYesNoType(value);
1055
+ this.accessSSLNegotiateCertFieldSet = true;
1056
+ }
1057
+ if (("AccessSSLRequireCert" == name))
1058
+ {
1059
+ this.accessSSLRequireCertField = Enums.ParseYesNoType(value);
1060
+ this.accessSSLRequireCertFieldSet = true;
1061
+ }
1062
+ if (("AuthenticationProviders" == name))
1063
+ {
1064
+ this.authenticationProvidersField = value;
1065
+ this.authenticationProvidersFieldSet = true;
1066
+ }
1067
+ }
1068
+ }
1069
+
1070
+ /// <summary>
1071
+ /// Custom Web Errors used by WebSites and Virtual Directories.
1072
+ /// </summary>
1073
+ [GeneratedCode("XsdGen", "4.0.0.0")]
1074
+ public class WebError : ISchemaElement, ISetAttributes
1075
+ {
1076
+
1077
+ private int errorCodeField;
1078
+
1079
+ private bool errorCodeFieldSet;
1080
+
1081
+ private int subCodeField;
1082
+
1083
+ private bool subCodeFieldSet;
1084
+
1085
+ private string fileField;
1086
+
1087
+ private bool fileFieldSet;
1088
+
1089
+ private string uRLField;
1090
+
1091
+ private bool uRLFieldSet;
1092
+
1093
+ private ISchemaElement parentElement;
1094
+
1095
+ /// <summary>
1096
+ /// HTTP 1.1 error code.
1097
+ /// </summary>
1098
+ public int ErrorCode
1099
+ {
1100
+ get
1101
+ {
1102
+ return this.errorCodeField;
1103
+ }
1104
+ set
1105
+ {
1106
+ this.errorCodeFieldSet = true;
1107
+ this.errorCodeField = value;
1108
+ }
1109
+ }
1110
+
1111
+ /// <summary>
1112
+ /// Error sub code. Set to 0 to get the wild card "*".
1113
+ /// </summary>
1114
+ public int SubCode
1115
+ {
1116
+ get
1117
+ {
1118
+ return this.subCodeField;
1119
+ }
1120
+ set
1121
+ {
1122
+ this.subCodeFieldSet = true;
1123
+ this.subCodeField = value;
1124
+ }
1125
+ }
1126
+
1127
+ /// <summary>
1128
+ /// File to be sent to the client for this error code and sub code. This can be formatted. For example: [#FileId].
1129
+ /// </summary>
1130
+ public string File
1131
+ {
1132
+ get
1133
+ {
1134
+ return this.fileField;
1135
+ }
1136
+ set
1137
+ {
1138
+ this.fileFieldSet = true;
1139
+ this.fileField = value;
1140
+ }
1141
+ }
1142
+
1143
+ /// <summary>
1144
+ /// URL to be sent to the client for this error code and sub code. This can be formatted.
1145
+ /// </summary>
1146
+ [SuppressMessage("Microsoft.Naming", "CA1705:LongAcronymsShouldBePascalCased")]
1147
+ public string URL
1148
+ {
1149
+ get
1150
+ {
1151
+ return this.uRLField;
1152
+ }
1153
+ set
1154
+ {
1155
+ this.uRLFieldSet = true;
1156
+ this.uRLField = value;
1157
+ }
1158
+ }
1159
+
1160
+ public virtual ISchemaElement ParentElement
1161
+ {
1162
+ get
1163
+ {
1164
+ return this.parentElement;
1165
+ }
1166
+ set
1167
+ {
1168
+ this.parentElement = value;
1169
+ }
1170
+ }
1171
+
1172
+ /// <summary>
1173
+ /// Processes this element and all child elements into an XmlWriter.
1174
+ /// </summary>
1175
+ public virtual void OutputXml(XmlWriter writer)
1176
+ {
1177
+ if ((null == writer))
1178
+ {
1179
+ throw new ArgumentNullException("writer");
1180
+ }
1181
+ writer.WriteStartElement("WebError", "http://wixtoolset.org/schemas/v4/wxs/iis");
1182
+ if (this.errorCodeFieldSet)
1183
+ {
1184
+ writer.WriteAttributeString("ErrorCode", this.errorCodeField.ToString(CultureInfo.InvariantCulture));
1185
+ }
1186
+ if (this.subCodeFieldSet)
1187
+ {
1188
+ writer.WriteAttributeString("SubCode", this.subCodeField.ToString(CultureInfo.InvariantCulture));
1189
+ }
1190
+ if (this.fileFieldSet)
1191
+ {
1192
+ writer.WriteAttributeString("File", this.fileField);
1193
+ }
1194
+ if (this.uRLFieldSet)
1195
+ {
1196
+ writer.WriteAttributeString("URL", this.uRLField);
1197
+ }
1198
+ writer.WriteEndElement();
1199
+ }
1200
+
1201
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
1202
+ void ISetAttributes.SetAttribute(string name, string value)
1203
+ {
1204
+ if (String.IsNullOrEmpty(name))
1205
+ {
1206
+ throw new ArgumentNullException("name");
1207
+ }
1208
+ if (("ErrorCode" == name))
1209
+ {
1210
+ this.errorCodeField = Convert.ToInt32(value, CultureInfo.InvariantCulture);
1211
+ this.errorCodeFieldSet = true;
1212
+ }
1213
+ if (("SubCode" == name))
1214
+ {
1215
+ this.subCodeField = Convert.ToInt32(value, CultureInfo.InvariantCulture);
1216
+ this.subCodeFieldSet = true;
1217
+ }
1218
+ if (("File" == name))
1219
+ {
1220
+ this.fileField = value;
1221
+ this.fileFieldSet = true;
1222
+ }
1223
+ if (("URL" == name))
1224
+ {
1225
+ this.uRLField = value;
1226
+ this.uRLFieldSet = true;
1227
+ }
1228
+ }
1229
+ }
1230
+
1231
+ /// <summary>
1232
+ /// Custom HTTP Header definition for IIS resources such as WebSite and WebVirtualDir.
1233
+ /// </summary>
1234
+ [GeneratedCode("XsdGen", "4.0.0.0")]
1235
+ public class HttpHeader : ISchemaElement, ISetAttributes
1236
+ {
1237
+
1238
+ private string idField;
1239
+
1240
+ private bool idFieldSet;
1241
+
1242
+ private string nameField;
1243
+
1244
+ private bool nameFieldSet;
1245
+
1246
+ private string valueField;
1247
+
1248
+ private bool valueFieldSet;
1249
+
1250
+ private ISchemaElement parentElement;
1251
+
1252
+ /// <summary>
1253
+ /// Primary key for custom HTTP Header entry. This will default to the Name attribute.
1254
+ /// </summary>
1255
+ public string Id
1256
+ {
1257
+ get
1258
+ {
1259
+ return this.idField;
1260
+ }
1261
+ set
1262
+ {
1263
+ this.idFieldSet = true;
1264
+ this.idField = value;
1265
+ }
1266
+ }
1267
+
1268
+ /// <summary>
1269
+ /// Name of the custom HTTP Header.
1270
+ /// </summary>
1271
+ public string Name
1272
+ {
1273
+ get
1274
+ {
1275
+ return this.nameField;
1276
+ }
1277
+ set
1278
+ {
1279
+ this.nameFieldSet = true;
1280
+ this.nameField = value;
1281
+ }
1282
+ }
1283
+
1284
+ /// <summary>
1285
+ /// Value for the custom HTTP Header. This attribute can contain a formatted string that is processed at install time to insert the values of properties using [PropertyName] syntax. Also supported are environment variables, file installation paths, and component installation directories; see
1286
+ /// </summary>
1287
+ public string Value
1288
+ {
1289
+ get
1290
+ {
1291
+ return this.valueField;
1292
+ }
1293
+ set
1294
+ {
1295
+ this.valueFieldSet = true;
1296
+ this.valueField = value;
1297
+ }
1298
+ }
1299
+
1300
+ public virtual ISchemaElement ParentElement
1301
+ {
1302
+ get
1303
+ {
1304
+ return this.parentElement;
1305
+ }
1306
+ set
1307
+ {
1308
+ this.parentElement = value;
1309
+ }
1310
+ }
1311
+
1312
+ /// <summary>
1313
+ /// Processes this element and all child elements into an XmlWriter.
1314
+ /// </summary>
1315
+ public virtual void OutputXml(XmlWriter writer)
1316
+ {
1317
+ if ((null == writer))
1318
+ {
1319
+ throw new ArgumentNullException("writer");
1320
+ }
1321
+ writer.WriteStartElement("HttpHeader", "http://wixtoolset.org/schemas/v4/wxs/iis");
1322
+ if (this.idFieldSet)
1323
+ {
1324
+ writer.WriteAttributeString("Id", this.idField);
1325
+ }
1326
+ if (this.nameFieldSet)
1327
+ {
1328
+ writer.WriteAttributeString("Name", this.nameField);
1329
+ }
1330
+ if (this.valueFieldSet)
1331
+ {
1332
+ writer.WriteAttributeString("Value", this.valueField);
1333
+ }
1334
+ writer.WriteEndElement();
1335
+ }
1336
+
1337
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
1338
+ void ISetAttributes.SetAttribute(string name, string value)
1339
+ {
1340
+ if (String.IsNullOrEmpty(name))
1341
+ {
1342
+ throw new ArgumentNullException("name");
1343
+ }
1344
+ if (("Id" == name))
1345
+ {
1346
+ this.idField = value;
1347
+ this.idFieldSet = true;
1348
+ }
1349
+ if (("Name" == name))
1350
+ {
1351
+ this.nameField = value;
1352
+ this.nameFieldSet = true;
1353
+ }
1354
+ if (("Value" == name))
1355
+ {
1356
+ this.valueField = value;
1357
+ this.valueFieldSet = true;
1358
+ }
1359
+ }
1360
+ }
1361
+
1362
+ /// <summary>
1363
+ /// MimeMap definition for IIS resources.
1364
+ /// </summary>
1365
+ [GeneratedCode("XsdGen", "4.0.0.0")]
1366
+ public class MimeMap : ISchemaElement, ISetAttributes
1367
+ {
1368
+
1369
+ private string idField;
1370
+
1371
+ private bool idFieldSet;
1372
+
1373
+ private string typeField;
1374
+
1375
+ private bool typeFieldSet;
1376
+
1377
+ private string extensionField;
1378
+
1379
+ private bool extensionFieldSet;
1380
+
1381
+ private ISchemaElement parentElement;
1382
+
1383
+ /// <summary>
1384
+ /// Id for the MimeMap.
1385
+ /// </summary>
1386
+ public string Id
1387
+ {
1388
+ get
1389
+ {
1390
+ return this.idField;
1391
+ }
1392
+ set
1393
+ {
1394
+ this.idFieldSet = true;
1395
+ this.idField = value;
1396
+ }
1397
+ }
1398
+
1399
+ /// <summary>
1400
+ /// Mime-type covered by the MimeMap.
1401
+ /// </summary>
1402
+ public string Type
1403
+ {
1404
+ get
1405
+ {
1406
+ return this.typeField;
1407
+ }
1408
+ set
1409
+ {
1410
+ this.typeFieldSet = true;
1411
+ this.typeField = value;
1412
+ }
1413
+ }
1414
+
1415
+ /// <summary>
1416
+ /// Extension covered by the MimeMap. Must begin with a dot.
1417
+ /// </summary>
1418
+ public string Extension
1419
+ {
1420
+ get
1421
+ {
1422
+ return this.extensionField;
1423
+ }
1424
+ set
1425
+ {
1426
+ this.extensionFieldSet = true;
1427
+ this.extensionField = value;
1428
+ }
1429
+ }
1430
+
1431
+ public virtual ISchemaElement ParentElement
1432
+ {
1433
+ get
1434
+ {
1435
+ return this.parentElement;
1436
+ }
1437
+ set
1438
+ {
1439
+ this.parentElement = value;
1440
+ }
1441
+ }
1442
+
1443
+ /// <summary>
1444
+ /// Processes this element and all child elements into an XmlWriter.
1445
+ /// </summary>
1446
+ public virtual void OutputXml(XmlWriter writer)
1447
+ {
1448
+ if ((null == writer))
1449
+ {
1450
+ throw new ArgumentNullException("writer");
1451
+ }
1452
+ writer.WriteStartElement("MimeMap", "http://wixtoolset.org/schemas/v4/wxs/iis");
1453
+ if (this.idFieldSet)
1454
+ {
1455
+ writer.WriteAttributeString("Id", this.idField);
1456
+ }
1457
+ if (this.typeFieldSet)
1458
+ {
1459
+ writer.WriteAttributeString("Type", this.typeField);
1460
+ }
1461
+ if (this.extensionFieldSet)
1462
+ {
1463
+ writer.WriteAttributeString("Extension", this.extensionField);
1464
+ }
1465
+ writer.WriteEndElement();
1466
+ }
1467
+
1468
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
1469
+ void ISetAttributes.SetAttribute(string name, string value)
1470
+ {
1471
+ if (String.IsNullOrEmpty(name))
1472
+ {
1473
+ throw new ArgumentNullException("name");
1474
+ }
1475
+ if (("Id" == name))
1476
+ {
1477
+ this.idField = value;
1478
+ this.idFieldSet = true;
1479
+ }
1480
+ if (("Type" == name))
1481
+ {
1482
+ this.typeField = value;
1483
+ this.typeFieldSet = true;
1484
+ }
1485
+ if (("Extension" == name))
1486
+ {
1487
+ this.extensionField = value;
1488
+ this.extensionFieldSet = true;
1489
+ }
1490
+ }
1491
+ }
1492
+
1493
+ /// <summary>
1494
+ /// IIs Filter for a Component
1495
+ /// </summary>
1496
+ [GeneratedCode("XsdGen", "4.0.0.0")]
1497
+ public class WebFilter : ISchemaElement, ISetAttributes
1498
+ {
1499
+
1500
+ private string idField;
1501
+
1502
+ private bool idFieldSet;
1503
+
1504
+ private string nameField;
1505
+
1506
+ private bool nameFieldSet;
1507
+
1508
+ private string pathField;
1509
+
1510
+ private bool pathFieldSet;
1511
+
1512
+ private string webSiteField;
1513
+
1514
+ private bool webSiteFieldSet;
1515
+
1516
+ private string descriptionField;
1517
+
1518
+ private bool descriptionFieldSet;
1519
+
1520
+ private int flagsField;
1521
+
1522
+ private bool flagsFieldSet;
1523
+
1524
+ private string loadOrderField;
1525
+
1526
+ private bool loadOrderFieldSet;
1527
+
1528
+ private ISchemaElement parentElement;
1529
+
1530
+ /// <summary>
1531
+ /// The unique Id for the web filter.
1532
+ /// </summary>
1533
+ public string Id
1534
+ {
1535
+ get
1536
+ {
1537
+ return this.idField;
1538
+ }
1539
+ set
1540
+ {
1541
+ this.idFieldSet = true;
1542
+ this.idField = value;
1543
+ }
1544
+ }
1545
+
1546
+ /// <summary>
1547
+ /// The name of the filter to be used in IIS.
1548
+ /// </summary>
1549
+ public string Name
1550
+ {
1551
+ get
1552
+ {
1553
+ return this.nameField;
1554
+ }
1555
+ set
1556
+ {
1557
+ this.nameFieldSet = true;
1558
+ this.nameField = value;
1559
+ }
1560
+ }
1561
+
1562
+ /// <summary>
1563
+ /// The path of the filter executable file.
1564
+ /// This should usually be a value like '[!FileId]', where 'FileId' is the file identifier
1565
+ /// of the filter executable file.
1566
+ /// </summary>
1567
+ public string Path
1568
+ {
1569
+ get
1570
+ {
1571
+ return this.pathField;
1572
+ }
1573
+ set
1574
+ {
1575
+ this.pathFieldSet = true;
1576
+ this.pathField = value;
1577
+ }
1578
+ }
1579
+
1580
+ /// <summary>
1581
+ /// Specifies the parent website for this filter (if there is one).
1582
+ /// If this is a global filter, then this attribute should not be specified.
1583
+ /// </summary>
1584
+ public string WebSite
1585
+ {
1586
+ get
1587
+ {
1588
+ return this.webSiteField;
1589
+ }
1590
+ set
1591
+ {
1592
+ this.webSiteFieldSet = true;
1593
+ this.webSiteField = value;
1594
+ }
1595
+ }
1596
+
1597
+ /// <summary>
1598
+ /// Description of the filter.
1599
+ /// </summary>
1600
+ public string Description
1601
+ {
1602
+ get
1603
+ {
1604
+ return this.descriptionField;
1605
+ }
1606
+ set
1607
+ {
1608
+ this.descriptionFieldSet = true;
1609
+ this.descriptionField = value;
1610
+ }
1611
+ }
1612
+
1613
+ /// <summary>
1614
+ /// Sets the MD_FILTER_FLAGS metabase key for the filter. This must be an integer. See MSDN 'FilterFlags' documentation for more details.
1615
+ /// </summary>
1616
+ public int Flags
1617
+ {
1618
+ get
1619
+ {
1620
+ return this.flagsField;
1621
+ }
1622
+ set
1623
+ {
1624
+ this.flagsFieldSet = true;
1625
+ this.flagsField = value;
1626
+ }
1627
+ }
1628
+
1629
+ /// <summary>
1630
+ /// The legal values are "first", "last", or a number.
1631
+ /// If a number is specified, it must be greater than 0.
1632
+ /// </summary>
1633
+ public string LoadOrder
1634
+ {
1635
+ get
1636
+ {
1637
+ return this.loadOrderField;
1638
+ }
1639
+ set
1640
+ {
1641
+ this.loadOrderFieldSet = true;
1642
+ this.loadOrderField = value;
1643
+ }
1644
+ }
1645
+
1646
+ public virtual ISchemaElement ParentElement
1647
+ {
1648
+ get
1649
+ {
1650
+ return this.parentElement;
1651
+ }
1652
+ set
1653
+ {
1654
+ this.parentElement = value;
1655
+ }
1656
+ }
1657
+
1658
+ /// <summary>
1659
+ /// Processes this element and all child elements into an XmlWriter.
1660
+ /// </summary>
1661
+ [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
1662
+ public virtual void OutputXml(XmlWriter writer)
1663
+ {
1664
+ if ((null == writer))
1665
+ {
1666
+ throw new ArgumentNullException("writer");
1667
+ }
1668
+ writer.WriteStartElement("WebFilter", "http://wixtoolset.org/schemas/v4/wxs/iis");
1669
+ if (this.idFieldSet)
1670
+ {
1671
+ writer.WriteAttributeString("Id", this.idField);
1672
+ }
1673
+ if (this.nameFieldSet)
1674
+ {
1675
+ writer.WriteAttributeString("Name", this.nameField);
1676
+ }
1677
+ if (this.pathFieldSet)
1678
+ {
1679
+ writer.WriteAttributeString("Path", this.pathField);
1680
+ }
1681
+ if (this.webSiteFieldSet)
1682
+ {
1683
+ writer.WriteAttributeString("WebSite", this.webSiteField);
1684
+ }
1685
+ if (this.descriptionFieldSet)
1686
+ {
1687
+ writer.WriteAttributeString("Description", this.descriptionField);
1688
+ }
1689
+ if (this.flagsFieldSet)
1690
+ {
1691
+ writer.WriteAttributeString("Flags", this.flagsField.ToString(CultureInfo.InvariantCulture));
1692
+ }
1693
+ if (this.loadOrderFieldSet)
1694
+ {
1695
+ writer.WriteAttributeString("LoadOrder", this.loadOrderField);
1696
+ }
1697
+ writer.WriteEndElement();
1698
+ }
1699
+
1700
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
1701
+ void ISetAttributes.SetAttribute(string name, string value)
1702
+ {
1703
+ if (String.IsNullOrEmpty(name))
1704
+ {
1705
+ throw new ArgumentNullException("name");
1706
+ }
1707
+ if (("Id" == name))
1708
+ {
1709
+ this.idField = value;
1710
+ this.idFieldSet = true;
1711
+ }
1712
+ if (("Name" == name))
1713
+ {
1714
+ this.nameField = value;
1715
+ this.nameFieldSet = true;
1716
+ }
1717
+ if (("Path" == name))
1718
+ {
1719
+ this.pathField = value;
1720
+ this.pathFieldSet = true;
1721
+ }
1722
+ if (("WebSite" == name))
1723
+ {
1724
+ this.webSiteField = value;
1725
+ this.webSiteFieldSet = true;
1726
+ }
1727
+ if (("Description" == name))
1728
+ {
1729
+ this.descriptionField = value;
1730
+ this.descriptionFieldSet = true;
1731
+ }
1732
+ if (("Flags" == name))
1733
+ {
1734
+ this.flagsField = Convert.ToInt32(value, CultureInfo.InvariantCulture);
1735
+ this.flagsFieldSet = true;
1736
+ }
1737
+ if (("LoadOrder" == name))
1738
+ {
1739
+ this.loadOrderField = value;
1740
+ this.loadOrderFieldSet = true;
1741
+ }
1742
+ }
1743
+ }
1744
+
1745
+ /// <summary>
1746
+ /// Extension for WebApplication
1747
+ /// </summary>
1748
+ [GeneratedCode("XsdGen", "4.0.0.0")]
1749
+ public class WebApplicationExtension : ISchemaElement, ISetAttributes
1750
+ {
1751
+
1752
+ private string executableField;
1753
+
1754
+ private bool executableFieldSet;
1755
+
1756
+ private string extensionField;
1757
+
1758
+ private bool extensionFieldSet;
1759
+
1760
+ private string verbsField;
1761
+
1762
+ private bool verbsFieldSet;
1763
+
1764
+ private YesNoType scriptField;
1765
+
1766
+ private bool scriptFieldSet;
1767
+
1768
+ private YesNoType checkPathField;
1769
+
1770
+ private bool checkPathFieldSet;
1771
+
1772
+ private ISchemaElement parentElement;
1773
+
1774
+ /// <summary>
1775
+ /// usually a Property that resolves to short file name path
1776
+ /// </summary>
1777
+ public string Executable
1778
+ {
1779
+ get
1780
+ {
1781
+ return this.executableField;
1782
+ }
1783
+ set
1784
+ {
1785
+ this.executableFieldSet = true;
1786
+ this.executableField = value;
1787
+ }
1788
+ }
1789
+
1790
+ /// <summary>
1791
+ /// Extension being registered. Do not prefix with a '.' (e.g. you should use "html", not ".html"). To register for all extensions, use Extension="*". To register a wildcard application map (which handles all requests, even those for directories or files with no extension) omit the Extension attribute completely.
1792
+ /// </summary>
1793
+ public string Extension
1794
+ {
1795
+ get
1796
+ {
1797
+ return this.extensionField;
1798
+ }
1799
+ set
1800
+ {
1801
+ this.extensionFieldSet = true;
1802
+ this.extensionField = value;
1803
+ }
1804
+ }
1805
+
1806
+ public string Verbs
1807
+ {
1808
+ get
1809
+ {
1810
+ return this.verbsField;
1811
+ }
1812
+ set
1813
+ {
1814
+ this.verbsFieldSet = true;
1815
+ this.verbsField = value;
1816
+ }
1817
+ }
1818
+
1819
+ public YesNoType Script
1820
+ {
1821
+ get
1822
+ {
1823
+ return this.scriptField;
1824
+ }
1825
+ set
1826
+ {
1827
+ this.scriptFieldSet = true;
1828
+ this.scriptField = value;
1829
+ }
1830
+ }
1831
+
1832
+ public YesNoType CheckPath
1833
+ {
1834
+ get
1835
+ {
1836
+ return this.checkPathField;
1837
+ }
1838
+ set
1839
+ {
1840
+ this.checkPathFieldSet = true;
1841
+ this.checkPathField = value;
1842
+ }
1843
+ }
1844
+
1845
+ public virtual ISchemaElement ParentElement
1846
+ {
1847
+ get
1848
+ {
1849
+ return this.parentElement;
1850
+ }
1851
+ set
1852
+ {
1853
+ this.parentElement = value;
1854
+ }
1855
+ }
1856
+
1857
+ /// <summary>
1858
+ /// Processes this element and all child elements into an XmlWriter.
1859
+ /// </summary>
1860
+ public virtual void OutputXml(XmlWriter writer)
1861
+ {
1862
+ if ((null == writer))
1863
+ {
1864
+ throw new ArgumentNullException("writer");
1865
+ }
1866
+ writer.WriteStartElement("WebApplicationExtension", "http://wixtoolset.org/schemas/v4/wxs/iis");
1867
+ if (this.executableFieldSet)
1868
+ {
1869
+ writer.WriteAttributeString("Executable", this.executableField);
1870
+ }
1871
+ if (this.extensionFieldSet)
1872
+ {
1873
+ writer.WriteAttributeString("Extension", this.extensionField);
1874
+ }
1875
+ if (this.verbsFieldSet)
1876
+ {
1877
+ writer.WriteAttributeString("Verbs", this.verbsField);
1878
+ }
1879
+ if (this.scriptFieldSet)
1880
+ {
1881
+ if ((this.scriptField == YesNoType.no))
1882
+ {
1883
+ writer.WriteAttributeString("Script", "no");
1884
+ }
1885
+ if ((this.scriptField == YesNoType.yes))
1886
+ {
1887
+ writer.WriteAttributeString("Script", "yes");
1888
+ }
1889
+ }
1890
+ if (this.checkPathFieldSet)
1891
+ {
1892
+ if ((this.checkPathField == YesNoType.no))
1893
+ {
1894
+ writer.WriteAttributeString("CheckPath", "no");
1895
+ }
1896
+ if ((this.checkPathField == YesNoType.yes))
1897
+ {
1898
+ writer.WriteAttributeString("CheckPath", "yes");
1899
+ }
1900
+ }
1901
+ writer.WriteEndElement();
1902
+ }
1903
+
1904
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
1905
+ void ISetAttributes.SetAttribute(string name, string value)
1906
+ {
1907
+ if (String.IsNullOrEmpty(name))
1908
+ {
1909
+ throw new ArgumentNullException("name");
1910
+ }
1911
+ if (("Executable" == name))
1912
+ {
1913
+ this.executableField = value;
1914
+ this.executableFieldSet = true;
1915
+ }
1916
+ if (("Extension" == name))
1917
+ {
1918
+ this.extensionField = value;
1919
+ this.extensionFieldSet = true;
1920
+ }
1921
+ if (("Verbs" == name))
1922
+ {
1923
+ this.verbsField = value;
1924
+ this.verbsFieldSet = true;
1925
+ }
1926
+ if (("Script" == name))
1927
+ {
1928
+ this.scriptField = Enums.ParseYesNoType(value);
1929
+ this.scriptFieldSet = true;
1930
+ }
1931
+ if (("CheckPath" == name))
1932
+ {
1933
+ this.checkPathField = Enums.ParseYesNoType(value);
1934
+ this.checkPathFieldSet = true;
1935
+ }
1936
+ }
1937
+ }
1938
+
1939
+ /// <summary>
1940
+ /// IIS6 Application Pool
1941
+ /// </summary>
1942
+ [GeneratedCode("XsdGen", "4.0.0.0")]
1943
+ public class WebAppPool : IParentElement, ICreateChildren, ISchemaElement, ISetAttributes
1944
+ {
1945
+
1946
+ private ElementCollection children;
1947
+
1948
+ private string idField;
1949
+
1950
+ private bool idFieldSet;
1951
+
1952
+ private string nameField;
1953
+
1954
+ private bool nameFieldSet;
1955
+
1956
+ private string userField;
1957
+
1958
+ private bool userFieldSet;
1959
+
1960
+ private int recycleMinutesField;
1961
+
1962
+ private bool recycleMinutesFieldSet;
1963
+
1964
+ private int recycleRequestsField;
1965
+
1966
+ private bool recycleRequestsFieldSet;
1967
+
1968
+ private int virtualMemoryField;
1969
+
1970
+ private bool virtualMemoryFieldSet;
1971
+
1972
+ private int privateMemoryField;
1973
+
1974
+ private bool privateMemoryFieldSet;
1975
+
1976
+ private int idleTimeoutField;
1977
+
1978
+ private bool idleTimeoutFieldSet;
1979
+
1980
+ private int queueLimitField;
1981
+
1982
+ private bool queueLimitFieldSet;
1983
+
1984
+ private long maxCpuUsageField;
1985
+
1986
+ private bool maxCpuUsageFieldSet;
1987
+
1988
+ private int refreshCpuField;
1989
+
1990
+ private bool refreshCpuFieldSet;
1991
+
1992
+ private CpuActionType cpuActionField;
1993
+
1994
+ private bool cpuActionFieldSet;
1995
+
1996
+ private int maxWorkerProcessesField;
1997
+
1998
+ private bool maxWorkerProcessesFieldSet;
1999
+
2000
+ private IdentityType identityField;
2001
+
2002
+ private bool identityFieldSet;
2003
+
2004
+ private string managedPipelineModeField;
2005
+
2006
+ private bool managedPipelineModeFieldSet;
2007
+
2008
+ private string managedRuntimeVersionField;
2009
+
2010
+ private bool managedRuntimeVersionFieldSet;
2011
+
2012
+ private ISchemaElement parentElement;
2013
+
2014
+ public WebAppPool()
2015
+ {
2016
+ ElementCollection childCollection0 = new ElementCollection(ElementCollection.CollectionType.Sequence);
2017
+ childCollection0.AddItem(new ElementCollection.SequenceItem(typeof(RecycleTime)));
2018
+ this.children = childCollection0;
2019
+ }
2020
+
2021
+ public virtual IEnumerable Children
2022
+ {
2023
+ get
2024
+ {
2025
+ return this.children;
2026
+ }
2027
+ }
2028
+
2029
+ [SuppressMessage("Microsoft.Design", "CA1043:UseIntegralOrStringArgumentForIndexers")]
2030
+ public virtual IEnumerable this[System.Type childType]
2031
+ {
2032
+ get
2033
+ {
2034
+ return this.children.Filter(childType);
2035
+ }
2036
+ }
2037
+
2038
+ /// <summary>
2039
+ /// Id of the AppPool.
2040
+ /// </summary>
2041
+ public string Id
2042
+ {
2043
+ get
2044
+ {
2045
+ return this.idField;
2046
+ }
2047
+ set
2048
+ {
2049
+ this.idFieldSet = true;
2050
+ this.idField = value;
2051
+ }
2052
+ }
2053
+
2054
+ /// <summary>
2055
+ /// Name of the AppPool to be shown in IIs.
2056
+ /// </summary>
2057
+ public string Name
2058
+ {
2059
+ get
2060
+ {
2061
+ return this.nameField;
2062
+ }
2063
+ set
2064
+ {
2065
+ this.nameFieldSet = true;
2066
+ this.nameField = value;
2067
+ }
2068
+ }
2069
+
2070
+ /// <summary>
2071
+ /// User account to run the AppPool as. To use this, you must set the Identity attribute to 'other'.
2072
+ /// </summary>
2073
+ public string User
2074
+ {
2075
+ get
2076
+ {
2077
+ return this.userField;
2078
+ }
2079
+ set
2080
+ {
2081
+ this.userFieldSet = true;
2082
+ this.userField = value;
2083
+ }
2084
+ }
2085
+
2086
+ /// <summary>
2087
+ /// How often, in minutes, you want the AppPool to be recycled.
2088
+ /// </summary>
2089
+ public int RecycleMinutes
2090
+ {
2091
+ get
2092
+ {
2093
+ return this.recycleMinutesField;
2094
+ }
2095
+ set
2096
+ {
2097
+ this.recycleMinutesFieldSet = true;
2098
+ this.recycleMinutesField = value;
2099
+ }
2100
+ }
2101
+
2102
+ /// <summary>
2103
+ /// How often, in requests, you want the AppPool to be recycled.
2104
+ /// </summary>
2105
+ public int RecycleRequests
2106
+ {
2107
+ get
2108
+ {
2109
+ return this.recycleRequestsField;
2110
+ }
2111
+ set
2112
+ {
2113
+ this.recycleRequestsFieldSet = true;
2114
+ this.recycleRequestsField = value;
2115
+ }
2116
+ }
2117
+
2118
+ /// <summary>
2119
+ /// Specifies the amount of virtual memory (in KB) that a worker process can use before the worker process recycles. The maximum value supported for this attribute is 4,294,967 KB.
2120
+ /// </summary>
2121
+ public int VirtualMemory
2122
+ {
2123
+ get
2124
+ {
2125
+ return this.virtualMemoryField;
2126
+ }
2127
+ set
2128
+ {
2129
+ this.virtualMemoryFieldSet = true;
2130
+ this.virtualMemoryField = value;
2131
+ }
2132
+ }
2133
+
2134
+ /// <summary>
2135
+ /// Specifies the amount of private memory (in KB) that a worker process can use before the worker process recycles. The maximum value supported for this attribute is 4,294,967 KB.
2136
+ /// </summary>
2137
+ public int PrivateMemory
2138
+ {
2139
+ get
2140
+ {
2141
+ return this.privateMemoryField;
2142
+ }
2143
+ set
2144
+ {
2145
+ this.privateMemoryFieldSet = true;
2146
+ this.privateMemoryField = value;
2147
+ }
2148
+ }
2149
+
2150
+ /// <summary>
2151
+ /// Shutdown worker process after being idle for (time in minutes).
2152
+ /// </summary>
2153
+ public int IdleTimeout
2154
+ {
2155
+ get
2156
+ {
2157
+ return this.idleTimeoutField;
2158
+ }
2159
+ set
2160
+ {
2161
+ this.idleTimeoutFieldSet = true;
2162
+ this.idleTimeoutField = value;
2163
+ }
2164
+ }
2165
+
2166
+ /// <summary>
2167
+ /// Limit the kernel request queue (number of requests).
2168
+ /// </summary>
2169
+ public int QueueLimit
2170
+ {
2171
+ get
2172
+ {
2173
+ return this.queueLimitField;
2174
+ }
2175
+ set
2176
+ {
2177
+ this.queueLimitFieldSet = true;
2178
+ this.queueLimitField = value;
2179
+ }
2180
+ }
2181
+
2182
+ /// <summary>
2183
+ /// Maximum CPU usage (percent).
2184
+ /// </summary>
2185
+ public long MaxCpuUsage
2186
+ {
2187
+ get
2188
+ {
2189
+ return this.maxCpuUsageField;
2190
+ }
2191
+ set
2192
+ {
2193
+ this.maxCpuUsageFieldSet = true;
2194
+ this.maxCpuUsageField = value;
2195
+ }
2196
+ }
2197
+
2198
+ /// <summary>
2199
+ /// Refresh CPU usage numbers (in minutes).
2200
+ /// </summary>
2201
+ public int RefreshCpu
2202
+ {
2203
+ get
2204
+ {
2205
+ return this.refreshCpuField;
2206
+ }
2207
+ set
2208
+ {
2209
+ this.refreshCpuFieldSet = true;
2210
+ this.refreshCpuField = value;
2211
+ }
2212
+ }
2213
+
2214
+ /// <summary>
2215
+ /// Action taken when CPU exceeds maximum CPU use (as defined with MaxCpuUsage and RefreshCpu).
2216
+ /// </summary>
2217
+ public CpuActionType CpuAction
2218
+ {
2219
+ get
2220
+ {
2221
+ return this.cpuActionField;
2222
+ }
2223
+ set
2224
+ {
2225
+ this.cpuActionFieldSet = true;
2226
+ this.cpuActionField = value;
2227
+ }
2228
+ }
2229
+
2230
+ /// <summary>
2231
+ /// Maximum number of worker processes.
2232
+ /// </summary>
2233
+ public int MaxWorkerProcesses
2234
+ {
2235
+ get
2236
+ {
2237
+ return this.maxWorkerProcessesField;
2238
+ }
2239
+ set
2240
+ {
2241
+ this.maxWorkerProcessesFieldSet = true;
2242
+ this.maxWorkerProcessesField = value;
2243
+ }
2244
+ }
2245
+
2246
+ /// <summary>
2247
+ /// Identity you want the AppPool to run under (applicationPoolIdentity is only available on IIS7). Use the 'other' value in conjunction with the User attribute to specify non-standard user.
2248
+ /// </summary>
2249
+ public IdentityType Identity
2250
+ {
2251
+ get
2252
+ {
2253
+ return this.identityField;
2254
+ }
2255
+ set
2256
+ {
2257
+ this.identityFieldSet = true;
2258
+ this.identityField = value;
2259
+ }
2260
+ }
2261
+
2262
+ /// <summary>
2263
+ /// Specifies the request-processing mode that is used to process requests for managed content. Only available on IIS7, ignored on IIS6.
2264
+ /// See
2265
+ /// </summary>
2266
+ public string ManagedPipelineMode
2267
+ {
2268
+ get
2269
+ {
2270
+ return this.managedPipelineModeField;
2271
+ }
2272
+ set
2273
+ {
2274
+ this.managedPipelineModeFieldSet = true;
2275
+ this.managedPipelineModeField = value;
2276
+ }
2277
+ }
2278
+
2279
+ /// <summary>
2280
+ /// Specifies the .NET Framework version to be used by the application pool. Only available on IIS7, ignored on IIS6.
2281
+ /// See
2282
+ /// </summary>
2283
+ public string ManagedRuntimeVersion
2284
+ {
2285
+ get
2286
+ {
2287
+ return this.managedRuntimeVersionField;
2288
+ }
2289
+ set
2290
+ {
2291
+ this.managedRuntimeVersionFieldSet = true;
2292
+ this.managedRuntimeVersionField = value;
2293
+ }
2294
+ }
2295
+
2296
+ public virtual ISchemaElement ParentElement
2297
+ {
2298
+ get
2299
+ {
2300
+ return this.parentElement;
2301
+ }
2302
+ set
2303
+ {
2304
+ this.parentElement = value;
2305
+ }
2306
+ }
2307
+
2308
+ public virtual void AddChild(ISchemaElement child)
2309
+ {
2310
+ if ((null == child))
2311
+ {
2312
+ throw new ArgumentNullException("child");
2313
+ }
2314
+ this.children.AddElement(child);
2315
+ child.ParentElement = this;
2316
+ }
2317
+
2318
+ public virtual void RemoveChild(ISchemaElement child)
2319
+ {
2320
+ if ((null == child))
2321
+ {
2322
+ throw new ArgumentNullException("child");
2323
+ }
2324
+ this.children.RemoveElement(child);
2325
+ child.ParentElement = null;
2326
+ }
2327
+
2328
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
2329
+ ISchemaElement ICreateChildren.CreateChild(string childName)
2330
+ {
2331
+ if (String.IsNullOrEmpty(childName))
2332
+ {
2333
+ throw new ArgumentNullException("childName");
2334
+ }
2335
+ ISchemaElement childValue = null;
2336
+ if (("RecycleTime" == childName))
2337
+ {
2338
+ childValue = new RecycleTime();
2339
+ }
2340
+ if ((null == childValue))
2341
+ {
2342
+ throw new InvalidOperationException(String.Concat(childName, " is not a valid child name."));
2343
+ }
2344
+ return childValue;
2345
+ }
2346
+
2347
+ /// <summary>
2348
+ /// Parses a CpuActionType from a string.
2349
+ /// </summary>
2350
+ public static CpuActionType ParseCpuActionType(string value)
2351
+ {
2352
+ CpuActionType parsedValue;
2353
+ WebAppPool.TryParseCpuActionType(value, out parsedValue);
2354
+ return parsedValue;
2355
+ }
2356
+
2357
+ /// <summary>
2358
+ /// Tries to parse a CpuActionType from a string.
2359
+ /// </summary>
2360
+ public static bool TryParseCpuActionType(string value, out CpuActionType parsedValue)
2361
+ {
2362
+ parsedValue = CpuActionType.NotSet;
2363
+ if (string.IsNullOrEmpty(value))
2364
+ {
2365
+ return false;
2366
+ }
2367
+ if (("none" == value))
2368
+ {
2369
+ parsedValue = CpuActionType.none;
2370
+ }
2371
+ else
2372
+ {
2373
+ if (("shutdown" == value))
2374
+ {
2375
+ parsedValue = CpuActionType.shutdown;
2376
+ }
2377
+ else
2378
+ {
2379
+ parsedValue = CpuActionType.IllegalValue;
2380
+ return false;
2381
+ }
2382
+ }
2383
+ return true;
2384
+ }
2385
+
2386
+ /// <summary>
2387
+ /// Parses a IdentityType from a string.
2388
+ /// </summary>
2389
+ public static IdentityType ParseIdentityType(string value)
2390
+ {
2391
+ IdentityType parsedValue;
2392
+ WebAppPool.TryParseIdentityType(value, out parsedValue);
2393
+ return parsedValue;
2394
+ }
2395
+
2396
+ /// <summary>
2397
+ /// Tries to parse a IdentityType from a string.
2398
+ /// </summary>
2399
+ public static bool TryParseIdentityType(string value, out IdentityType parsedValue)
2400
+ {
2401
+ parsedValue = IdentityType.NotSet;
2402
+ if (string.IsNullOrEmpty(value))
2403
+ {
2404
+ return false;
2405
+ }
2406
+ if (("networkService" == value))
2407
+ {
2408
+ parsedValue = IdentityType.networkService;
2409
+ }
2410
+ else
2411
+ {
2412
+ if (("localService" == value))
2413
+ {
2414
+ parsedValue = IdentityType.localService;
2415
+ }
2416
+ else
2417
+ {
2418
+ if (("localSystem" == value))
2419
+ {
2420
+ parsedValue = IdentityType.localSystem;
2421
+ }
2422
+ else
2423
+ {
2424
+ if (("other" == value))
2425
+ {
2426
+ parsedValue = IdentityType.other;
2427
+ }
2428
+ else
2429
+ {
2430
+ if (("applicationPoolIdentity" == value))
2431
+ {
2432
+ parsedValue = IdentityType.applicationPoolIdentity;
2433
+ }
2434
+ else
2435
+ {
2436
+ parsedValue = IdentityType.IllegalValue;
2437
+ return false;
2438
+ }
2439
+ }
2440
+ }
2441
+ }
2442
+ }
2443
+ return true;
2444
+ }
2445
+
2446
+ /// <summary>
2447
+ /// Processes this element and all child elements into an XmlWriter.
2448
+ /// </summary>
2449
+ [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
2450
+ public virtual void OutputXml(XmlWriter writer)
2451
+ {
2452
+ if ((null == writer))
2453
+ {
2454
+ throw new ArgumentNullException("writer");
2455
+ }
2456
+ writer.WriteStartElement("WebAppPool", "http://wixtoolset.org/schemas/v4/wxs/iis");
2457
+ if (this.idFieldSet)
2458
+ {
2459
+ writer.WriteAttributeString("Id", this.idField);
2460
+ }
2461
+ if (this.nameFieldSet)
2462
+ {
2463
+ writer.WriteAttributeString("Name", this.nameField);
2464
+ }
2465
+ if (this.userFieldSet)
2466
+ {
2467
+ writer.WriteAttributeString("User", this.userField);
2468
+ }
2469
+ if (this.recycleMinutesFieldSet)
2470
+ {
2471
+ writer.WriteAttributeString("RecycleMinutes", this.recycleMinutesField.ToString(CultureInfo.InvariantCulture));
2472
+ }
2473
+ if (this.recycleRequestsFieldSet)
2474
+ {
2475
+ writer.WriteAttributeString("RecycleRequests", this.recycleRequestsField.ToString(CultureInfo.InvariantCulture));
2476
+ }
2477
+ if (this.virtualMemoryFieldSet)
2478
+ {
2479
+ writer.WriteAttributeString("VirtualMemory", this.virtualMemoryField.ToString(CultureInfo.InvariantCulture));
2480
+ }
2481
+ if (this.privateMemoryFieldSet)
2482
+ {
2483
+ writer.WriteAttributeString("PrivateMemory", this.privateMemoryField.ToString(CultureInfo.InvariantCulture));
2484
+ }
2485
+ if (this.idleTimeoutFieldSet)
2486
+ {
2487
+ writer.WriteAttributeString("IdleTimeout", this.idleTimeoutField.ToString(CultureInfo.InvariantCulture));
2488
+ }
2489
+ if (this.queueLimitFieldSet)
2490
+ {
2491
+ writer.WriteAttributeString("QueueLimit", this.queueLimitField.ToString(CultureInfo.InvariantCulture));
2492
+ }
2493
+ if (this.maxCpuUsageFieldSet)
2494
+ {
2495
+ writer.WriteAttributeString("MaxCpuUsage", this.maxCpuUsageField.ToString(CultureInfo.InvariantCulture));
2496
+ }
2497
+ if (this.refreshCpuFieldSet)
2498
+ {
2499
+ writer.WriteAttributeString("RefreshCpu", this.refreshCpuField.ToString(CultureInfo.InvariantCulture));
2500
+ }
2501
+ if (this.cpuActionFieldSet)
2502
+ {
2503
+ if ((this.cpuActionField == CpuActionType.none))
2504
+ {
2505
+ writer.WriteAttributeString("CpuAction", "none");
2506
+ }
2507
+ if ((this.cpuActionField == CpuActionType.shutdown))
2508
+ {
2509
+ writer.WriteAttributeString("CpuAction", "shutdown");
2510
+ }
2511
+ }
2512
+ if (this.maxWorkerProcessesFieldSet)
2513
+ {
2514
+ writer.WriteAttributeString("MaxWorkerProcesses", this.maxWorkerProcessesField.ToString(CultureInfo.InvariantCulture));
2515
+ }
2516
+ if (this.identityFieldSet)
2517
+ {
2518
+ if ((this.identityField == IdentityType.networkService))
2519
+ {
2520
+ writer.WriteAttributeString("Identity", "networkService");
2521
+ }
2522
+ if ((this.identityField == IdentityType.localService))
2523
+ {
2524
+ writer.WriteAttributeString("Identity", "localService");
2525
+ }
2526
+ if ((this.identityField == IdentityType.localSystem))
2527
+ {
2528
+ writer.WriteAttributeString("Identity", "localSystem");
2529
+ }
2530
+ if ((this.identityField == IdentityType.other))
2531
+ {
2532
+ writer.WriteAttributeString("Identity", "other");
2533
+ }
2534
+ if ((this.identityField == IdentityType.applicationPoolIdentity))
2535
+ {
2536
+ writer.WriteAttributeString("Identity", "applicationPoolIdentity");
2537
+ }
2538
+ }
2539
+ if (this.managedPipelineModeFieldSet)
2540
+ {
2541
+ writer.WriteAttributeString("ManagedPipelineMode", this.managedPipelineModeField);
2542
+ }
2543
+ if (this.managedRuntimeVersionFieldSet)
2544
+ {
2545
+ writer.WriteAttributeString("ManagedRuntimeVersion", this.managedRuntimeVersionField);
2546
+ }
2547
+ for (IEnumerator enumerator = this.children.GetEnumerator(); enumerator.MoveNext(); )
2548
+ {
2549
+ ISchemaElement childElement = ((ISchemaElement)(enumerator.Current));
2550
+ childElement.OutputXml(writer);
2551
+ }
2552
+ writer.WriteEndElement();
2553
+ }
2554
+
2555
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
2556
+ [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
2557
+ void ISetAttributes.SetAttribute(string name, string value)
2558
+ {
2559
+ if (String.IsNullOrEmpty(name))
2560
+ {
2561
+ throw new ArgumentNullException("name");
2562
+ }
2563
+ if (("Id" == name))
2564
+ {
2565
+ this.idField = value;
2566
+ this.idFieldSet = true;
2567
+ }
2568
+ if (("Name" == name))
2569
+ {
2570
+ this.nameField = value;
2571
+ this.nameFieldSet = true;
2572
+ }
2573
+ if (("User" == name))
2574
+ {
2575
+ this.userField = value;
2576
+ this.userFieldSet = true;
2577
+ }
2578
+ if (("RecycleMinutes" == name))
2579
+ {
2580
+ this.recycleMinutesField = Convert.ToInt32(value, CultureInfo.InvariantCulture);
2581
+ this.recycleMinutesFieldSet = true;
2582
+ }
2583
+ if (("RecycleRequests" == name))
2584
+ {
2585
+ this.recycleRequestsField = Convert.ToInt32(value, CultureInfo.InvariantCulture);
2586
+ this.recycleRequestsFieldSet = true;
2587
+ }
2588
+ if (("VirtualMemory" == name))
2589
+ {
2590
+ this.virtualMemoryField = Convert.ToInt32(value, CultureInfo.InvariantCulture);
2591
+ this.virtualMemoryFieldSet = true;
2592
+ }
2593
+ if (("PrivateMemory" == name))
2594
+ {
2595
+ this.privateMemoryField = Convert.ToInt32(value, CultureInfo.InvariantCulture);
2596
+ this.privateMemoryFieldSet = true;
2597
+ }
2598
+ if (("IdleTimeout" == name))
2599
+ {
2600
+ this.idleTimeoutField = Convert.ToInt32(value, CultureInfo.InvariantCulture);
2601
+ this.idleTimeoutFieldSet = true;
2602
+ }
2603
+ if (("QueueLimit" == name))
2604
+ {
2605
+ this.queueLimitField = Convert.ToInt32(value, CultureInfo.InvariantCulture);
2606
+ this.queueLimitFieldSet = true;
2607
+ }
2608
+ if (("MaxCpuUsage" == name))
2609
+ {
2610
+ this.maxCpuUsageField = Convert.ToInt32(value, CultureInfo.InvariantCulture);
2611
+ this.maxCpuUsageFieldSet = true;
2612
+ }
2613
+ if (("RefreshCpu" == name))
2614
+ {
2615
+ this.refreshCpuField = Convert.ToInt32(value, CultureInfo.InvariantCulture);
2616
+ this.refreshCpuFieldSet = true;
2617
+ }
2618
+ if (("CpuAction" == name))
2619
+ {
2620
+ this.cpuActionField = WebAppPool.ParseCpuActionType(value);
2621
+ this.cpuActionFieldSet = true;
2622
+ }
2623
+ if (("MaxWorkerProcesses" == name))
2624
+ {
2625
+ this.maxWorkerProcessesField = Convert.ToInt32(value, CultureInfo.InvariantCulture);
2626
+ this.maxWorkerProcessesFieldSet = true;
2627
+ }
2628
+ if (("Identity" == name))
2629
+ {
2630
+ this.identityField = WebAppPool.ParseIdentityType(value);
2631
+ this.identityFieldSet = true;
2632
+ }
2633
+ if (("ManagedPipelineMode" == name))
2634
+ {
2635
+ this.managedPipelineModeField = value;
2636
+ this.managedPipelineModeFieldSet = true;
2637
+ }
2638
+ if (("ManagedRuntimeVersion" == name))
2639
+ {
2640
+ this.managedRuntimeVersionField = value;
2641
+ this.managedRuntimeVersionFieldSet = true;
2642
+ }
2643
+ }
2644
+
2645
+ [GeneratedCode("XsdGen", "4.0.0.0")]
2646
+ public enum CpuActionType
2647
+ {
2648
+
2649
+ IllegalValue = int.MaxValue,
2650
+
2651
+ NotSet = -1,
2652
+
2653
+ none,
2654
+
2655
+ shutdown,
2656
+ }
2657
+
2658
+ [GeneratedCode("XsdGen", "4.0.0.0")]
2659
+ public enum IdentityType
2660
+ {
2661
+
2662
+ IllegalValue = int.MaxValue,
2663
+
2664
+ NotSet = -1,
2665
+
2666
+ networkService,
2667
+
2668
+ localService,
2669
+
2670
+ localSystem,
2671
+
2672
+ other,
2673
+
2674
+ applicationPoolIdentity,
2675
+ }
2676
+ }
2677
+
2678
+ /// <summary>
2679
+ /// IIS6 Application Pool Recycle Times on 24 hour clock.
2680
+ /// </summary>
2681
+ [GeneratedCode("XsdGen", "4.0.0.0")]
2682
+ public class RecycleTime : ISchemaElement, ISetAttributes
2683
+ {
2684
+
2685
+ private string valueField;
2686
+
2687
+ private bool valueFieldSet;
2688
+
2689
+ private ISchemaElement parentElement;
2690
+
2691
+ public string Value
2692
+ {
2693
+ get
2694
+ {
2695
+ return this.valueField;
2696
+ }
2697
+ set
2698
+ {
2699
+ this.valueFieldSet = true;
2700
+ this.valueField = value;
2701
+ }
2702
+ }
2703
+
2704
+ public virtual ISchemaElement ParentElement
2705
+ {
2706
+ get
2707
+ {
2708
+ return this.parentElement;
2709
+ }
2710
+ set
2711
+ {
2712
+ this.parentElement = value;
2713
+ }
2714
+ }
2715
+
2716
+ /// <summary>
2717
+ /// Processes this element and all child elements into an XmlWriter.
2718
+ /// </summary>
2719
+ public virtual void OutputXml(XmlWriter writer)
2720
+ {
2721
+ if ((null == writer))
2722
+ {
2723
+ throw new ArgumentNullException("writer");
2724
+ }
2725
+ writer.WriteStartElement("RecycleTime", "http://wixtoolset.org/schemas/v4/wxs/iis");
2726
+ if (this.valueFieldSet)
2727
+ {
2728
+ writer.WriteAttributeString("Value", this.valueField);
2729
+ }
2730
+ writer.WriteEndElement();
2731
+ }
2732
+
2733
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
2734
+ void ISetAttributes.SetAttribute(string name, string value)
2735
+ {
2736
+ if (String.IsNullOrEmpty(name))
2737
+ {
2738
+ throw new ArgumentNullException("name");
2739
+ }
2740
+ if (("Value" == name))
2741
+ {
2742
+ this.valueField = value;
2743
+ this.valueFieldSet = true;
2744
+ }
2745
+ }
2746
+ }
2747
+
2748
+ /// <summary>
2749
+ /// Used to install and uninstall certificates.
2750
+ /// </summary>
2751
+ [GeneratedCode("XsdGen", "4.0.0.0")]
2752
+ public class Certificate : ISchemaElement, ISetAttributes
2753
+ {
2754
+
2755
+ private string idField;
2756
+
2757
+ private bool idFieldSet;
2758
+
2759
+ private string nameField;
2760
+
2761
+ private bool nameFieldSet;
2762
+
2763
+ private StoreNameType storeNameField;
2764
+
2765
+ private bool storeNameFieldSet;
2766
+
2767
+ private StoreLocationType storeLocationField;
2768
+
2769
+ private bool storeLocationFieldSet;
2770
+
2771
+ private YesNoType overwriteField;
2772
+
2773
+ private bool overwriteFieldSet;
2774
+
2775
+ private YesNoType requestField;
2776
+
2777
+ private bool requestFieldSet;
2778
+
2779
+ private string binaryKeyField;
2780
+
2781
+ private bool binaryKeyFieldSet;
2782
+
2783
+ private string certificatePathField;
2784
+
2785
+ private bool certificatePathFieldSet;
2786
+
2787
+ private string pFXPasswordField;
2788
+
2789
+ private bool pFXPasswordFieldSet;
2790
+
2791
+ private ISchemaElement parentElement;
2792
+
2793
+ /// <summary>
2794
+ /// Unique identifier for this certificate in the installation package.
2795
+ /// </summary>
2796
+ public string Id
2797
+ {
2798
+ get
2799
+ {
2800
+ return this.idField;
2801
+ }
2802
+ set
2803
+ {
2804
+ this.idFieldSet = true;
2805
+ this.idField = value;
2806
+ }
2807
+ }
2808
+
2809
+ /// <summary>
2810
+ /// Name of the certificate that will be installed or uninstalled in the specified store.
2811
+ /// This attribute may be set via a formatted Property (e.g. [MyProperty]).
2812
+ /// </summary>
2813
+ public string Name
2814
+ {
2815
+ get
2816
+ {
2817
+ return this.nameField;
2818
+ }
2819
+ set
2820
+ {
2821
+ this.nameFieldSet = true;
2822
+ this.nameField = value;
2823
+ }
2824
+ }
2825
+
2826
+ public StoreNameType StoreName
2827
+ {
2828
+ get
2829
+ {
2830
+ return this.storeNameField;
2831
+ }
2832
+ set
2833
+ {
2834
+ this.storeNameFieldSet = true;
2835
+ this.storeNameField = value;
2836
+ }
2837
+ }
2838
+
2839
+ public StoreLocationType StoreLocation
2840
+ {
2841
+ get
2842
+ {
2843
+ return this.storeLocationField;
2844
+ }
2845
+ set
2846
+ {
2847
+ this.storeLocationFieldSet = true;
2848
+ this.storeLocationField = value;
2849
+ }
2850
+ }
2851
+
2852
+ public YesNoType Overwrite
2853
+ {
2854
+ get
2855
+ {
2856
+ return this.overwriteField;
2857
+ }
2858
+ set
2859
+ {
2860
+ this.overwriteFieldSet = true;
2861
+ this.overwriteField = value;
2862
+ }
2863
+ }
2864
+
2865
+ /// <summary>
2866
+ /// This attribute controls whether the CertificatePath attribute is a path to a certificate file (Request='no') or the
2867
+ /// certificate authority to request the certificate from (Request='yes').
2868
+ /// </summary>
2869
+ public YesNoType Request
2870
+ {
2871
+ get
2872
+ {
2873
+ return this.requestField;
2874
+ }
2875
+ set
2876
+ {
2877
+ this.requestFieldSet = true;
2878
+ this.requestField = value;
2879
+ }
2880
+ }
2881
+
2882
+ /// <summary>
2883
+ /// Reference to a Binary element that will store the certificate as a stream inside the package. This attribute cannot be specified with
2884
+ /// the CertificatePath attribute.
2885
+ /// </summary>
2886
+ public string BinaryKey
2887
+ {
2888
+ get
2889
+ {
2890
+ return this.binaryKeyField;
2891
+ }
2892
+ set
2893
+ {
2894
+ this.binaryKeyFieldSet = true;
2895
+ this.binaryKeyField = value;
2896
+ }
2897
+ }
2898
+
2899
+ /// <summary>
2900
+ /// If the Request attribute is "no" then this attribute is the path to the certificate file outside of the package.
2901
+ /// If the Request attribute is "yes" then this atribute is the certificate authority to request the certificate from.
2902
+ /// This attribute may be set via a formatted Property (e.g. [MyProperty]).
2903
+ /// </summary>
2904
+ public string CertificatePath
2905
+ {
2906
+ get
2907
+ {
2908
+ return this.certificatePathField;
2909
+ }
2910
+ set
2911
+ {
2912
+ this.certificatePathFieldSet = true;
2913
+ this.certificatePathField = value;
2914
+ }
2915
+ }
2916
+
2917
+ /// <summary>
2918
+ /// If the Binary stream or path to the file outside of the package is a password protected PFX file, the password for that
2919
+ /// PFX must be specified here. This attribute may be set via a formatted Property (e.g. [MyProperty]).
2920
+ /// </summary>
2921
+ [SuppressMessage("Microsoft.Naming", "CA1705:LongAcronymsShouldBePascalCased")]
2922
+ public string PFXPassword
2923
+ {
2924
+ get
2925
+ {
2926
+ return this.pFXPasswordField;
2927
+ }
2928
+ set
2929
+ {
2930
+ this.pFXPasswordFieldSet = true;
2931
+ this.pFXPasswordField = value;
2932
+ }
2933
+ }
2934
+
2935
+ public virtual ISchemaElement ParentElement
2936
+ {
2937
+ get
2938
+ {
2939
+ return this.parentElement;
2940
+ }
2941
+ set
2942
+ {
2943
+ this.parentElement = value;
2944
+ }
2945
+ }
2946
+
2947
+ /// <summary>
2948
+ /// Parses a StoreNameType from a string.
2949
+ /// </summary>
2950
+ public static StoreNameType ParseStoreNameType(string value)
2951
+ {
2952
+ StoreNameType parsedValue;
2953
+ Certificate.TryParseStoreNameType(value, out parsedValue);
2954
+ return parsedValue;
2955
+ }
2956
+
2957
+ /// <summary>
2958
+ /// Tries to parse a StoreNameType from a string.
2959
+ /// </summary>
2960
+ public static bool TryParseStoreNameType(string value, out StoreNameType parsedValue)
2961
+ {
2962
+ parsedValue = StoreNameType.NotSet;
2963
+ if (string.IsNullOrEmpty(value))
2964
+ {
2965
+ return false;
2966
+ }
2967
+ if (("ca" == value))
2968
+ {
2969
+ parsedValue = StoreNameType.ca;
2970
+ }
2971
+ else
2972
+ {
2973
+ if (("my" == value))
2974
+ {
2975
+ parsedValue = StoreNameType.my;
2976
+ }
2977
+ else
2978
+ {
2979
+ if (("personal" == value))
2980
+ {
2981
+ parsedValue = StoreNameType.personal;
2982
+ }
2983
+ else
2984
+ {
2985
+ if (("request" == value))
2986
+ {
2987
+ parsedValue = StoreNameType.request;
2988
+ }
2989
+ else
2990
+ {
2991
+ if (("root" == value))
2992
+ {
2993
+ parsedValue = StoreNameType.root;
2994
+ }
2995
+ else
2996
+ {
2997
+ if (("otherPeople" == value))
2998
+ {
2999
+ parsedValue = StoreNameType.otherPeople;
3000
+ }
3001
+ else
3002
+ {
3003
+ if (("trustedPeople" == value))
3004
+ {
3005
+ parsedValue = StoreNameType.trustedPeople;
3006
+ }
3007
+ else
3008
+ {
3009
+ if (("trustedPublisher" == value))
3010
+ {
3011
+ parsedValue = StoreNameType.trustedPublisher;
3012
+ }
3013
+ else
3014
+ {
3015
+ parsedValue = StoreNameType.IllegalValue;
3016
+ return false;
3017
+ }
3018
+ }
3019
+ }
3020
+ }
3021
+ }
3022
+ }
3023
+ }
3024
+ }
3025
+ return true;
3026
+ }
3027
+
3028
+ /// <summary>
3029
+ /// Parses a StoreLocationType from a string.
3030
+ /// </summary>
3031
+ public static StoreLocationType ParseStoreLocationType(string value)
3032
+ {
3033
+ StoreLocationType parsedValue;
3034
+ Certificate.TryParseStoreLocationType(value, out parsedValue);
3035
+ return parsedValue;
3036
+ }
3037
+
3038
+ /// <summary>
3039
+ /// Tries to parse a StoreLocationType from a string.
3040
+ /// </summary>
3041
+ public static bool TryParseStoreLocationType(string value, out StoreLocationType parsedValue)
3042
+ {
3043
+ parsedValue = StoreLocationType.NotSet;
3044
+ if (string.IsNullOrEmpty(value))
3045
+ {
3046
+ return false;
3047
+ }
3048
+ if (("currentUser" == value))
3049
+ {
3050
+ parsedValue = StoreLocationType.currentUser;
3051
+ }
3052
+ else
3053
+ {
3054
+ if (("localMachine" == value))
3055
+ {
3056
+ parsedValue = StoreLocationType.localMachine;
3057
+ }
3058
+ else
3059
+ {
3060
+ parsedValue = StoreLocationType.IllegalValue;
3061
+ return false;
3062
+ }
3063
+ }
3064
+ return true;
3065
+ }
3066
+
3067
+ /// <summary>
3068
+ /// Processes this element and all child elements into an XmlWriter.
3069
+ /// </summary>
3070
+ [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
3071
+ public virtual void OutputXml(XmlWriter writer)
3072
+ {
3073
+ if ((null == writer))
3074
+ {
3075
+ throw new ArgumentNullException("writer");
3076
+ }
3077
+ writer.WriteStartElement("Certificate", "http://wixtoolset.org/schemas/v4/wxs/iis");
3078
+ if (this.idFieldSet)
3079
+ {
3080
+ writer.WriteAttributeString("Id", this.idField);
3081
+ }
3082
+ if (this.nameFieldSet)
3083
+ {
3084
+ writer.WriteAttributeString("Name", this.nameField);
3085
+ }
3086
+ if (this.storeNameFieldSet)
3087
+ {
3088
+ if ((this.storeNameField == StoreNameType.ca))
3089
+ {
3090
+ writer.WriteAttributeString("StoreName", "ca");
3091
+ }
3092
+ if ((this.storeNameField == StoreNameType.my))
3093
+ {
3094
+ writer.WriteAttributeString("StoreName", "my");
3095
+ }
3096
+ if ((this.storeNameField == StoreNameType.personal))
3097
+ {
3098
+ writer.WriteAttributeString("StoreName", "personal");
3099
+ }
3100
+ if ((this.storeNameField == StoreNameType.request))
3101
+ {
3102
+ writer.WriteAttributeString("StoreName", "request");
3103
+ }
3104
+ if ((this.storeNameField == StoreNameType.root))
3105
+ {
3106
+ writer.WriteAttributeString("StoreName", "root");
3107
+ }
3108
+ if ((this.storeNameField == StoreNameType.otherPeople))
3109
+ {
3110
+ writer.WriteAttributeString("StoreName", "otherPeople");
3111
+ }
3112
+ if ((this.storeNameField == StoreNameType.trustedPeople))
3113
+ {
3114
+ writer.WriteAttributeString("StoreName", "trustedPeople");
3115
+ }
3116
+ if ((this.storeNameField == StoreNameType.trustedPublisher))
3117
+ {
3118
+ writer.WriteAttributeString("StoreName", "trustedPublisher");
3119
+ }
3120
+ }
3121
+ if (this.storeLocationFieldSet)
3122
+ {
3123
+ if ((this.storeLocationField == StoreLocationType.currentUser))
3124
+ {
3125
+ writer.WriteAttributeString("StoreLocation", "currentUser");
3126
+ }
3127
+ if ((this.storeLocationField == StoreLocationType.localMachine))
3128
+ {
3129
+ writer.WriteAttributeString("StoreLocation", "localMachine");
3130
+ }
3131
+ }
3132
+ if (this.overwriteFieldSet)
3133
+ {
3134
+ if ((this.overwriteField == YesNoType.no))
3135
+ {
3136
+ writer.WriteAttributeString("Overwrite", "no");
3137
+ }
3138
+ if ((this.overwriteField == YesNoType.yes))
3139
+ {
3140
+ writer.WriteAttributeString("Overwrite", "yes");
3141
+ }
3142
+ }
3143
+ if (this.requestFieldSet)
3144
+ {
3145
+ if ((this.requestField == YesNoType.no))
3146
+ {
3147
+ writer.WriteAttributeString("Request", "no");
3148
+ }
3149
+ if ((this.requestField == YesNoType.yes))
3150
+ {
3151
+ writer.WriteAttributeString("Request", "yes");
3152
+ }
3153
+ }
3154
+ if (this.binaryKeyFieldSet)
3155
+ {
3156
+ writer.WriteAttributeString("BinaryKey", this.binaryKeyField);
3157
+ }
3158
+ if (this.certificatePathFieldSet)
3159
+ {
3160
+ writer.WriteAttributeString("CertificatePath", this.certificatePathField);
3161
+ }
3162
+ if (this.pFXPasswordFieldSet)
3163
+ {
3164
+ writer.WriteAttributeString("PFXPassword", this.pFXPasswordField);
3165
+ }
3166
+ writer.WriteEndElement();
3167
+ }
3168
+
3169
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
3170
+ [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
3171
+ void ISetAttributes.SetAttribute(string name, string value)
3172
+ {
3173
+ if (String.IsNullOrEmpty(name))
3174
+ {
3175
+ throw new ArgumentNullException("name");
3176
+ }
3177
+ if (("Id" == name))
3178
+ {
3179
+ this.idField = value;
3180
+ this.idFieldSet = true;
3181
+ }
3182
+ if (("Name" == name))
3183
+ {
3184
+ this.nameField = value;
3185
+ this.nameFieldSet = true;
3186
+ }
3187
+ if (("StoreName" == name))
3188
+ {
3189
+ this.storeNameField = Certificate.ParseStoreNameType(value);
3190
+ this.storeNameFieldSet = true;
3191
+ }
3192
+ if (("StoreLocation" == name))
3193
+ {
3194
+ this.storeLocationField = Certificate.ParseStoreLocationType(value);
3195
+ this.storeLocationFieldSet = true;
3196
+ }
3197
+ if (("Overwrite" == name))
3198
+ {
3199
+ this.overwriteField = Enums.ParseYesNoType(value);
3200
+ this.overwriteFieldSet = true;
3201
+ }
3202
+ if (("Request" == name))
3203
+ {
3204
+ this.requestField = Enums.ParseYesNoType(value);
3205
+ this.requestFieldSet = true;
3206
+ }
3207
+ if (("BinaryKey" == name))
3208
+ {
3209
+ this.binaryKeyField = value;
3210
+ this.binaryKeyFieldSet = true;
3211
+ }
3212
+ if (("CertificatePath" == name))
3213
+ {
3214
+ this.certificatePathField = value;
3215
+ this.certificatePathFieldSet = true;
3216
+ }
3217
+ if (("PFXPassword" == name))
3218
+ {
3219
+ this.pFXPasswordField = value;
3220
+ this.pFXPasswordFieldSet = true;
3221
+ }
3222
+ }
3223
+
3224
+ [GeneratedCode("XsdGen", "4.0.0.0")]
3225
+ public enum StoreNameType
3226
+ {
3227
+
3228
+ IllegalValue = int.MaxValue,
3229
+
3230
+ NotSet = -1,
3231
+
3232
+ /// <summary>
3233
+ /// Contains the certificates of certificate authorities that the user trusts to issue certificates to others. Certificates in these stores are normally supplied with the operating system or by the user's network administrator.
3234
+ /// </summary>
3235
+ ca,
3236
+
3237
+ /// <summary>
3238
+ /// Use the "personal" value instead.
3239
+ /// </summary>
3240
+ my,
3241
+
3242
+ /// <summary>
3243
+ /// Contains personal certificates. These certificates will usually have an associated private key. This store is often
3244
+ /// referred to as the "MY" certificate store.
3245
+ /// </summary>
3246
+ personal,
3247
+
3248
+ request,
3249
+
3250
+ /// <summary>
3251
+ /// Contains the certificates of certificate authorities that the user trusts to issue certificates to others. Certificates in these stores are normally supplied with the operating system or by the user's network administrator. Certificates in this store are typically self-signed.
3252
+ /// </summary>
3253
+ root,
3254
+
3255
+ /// <summary>
3256
+ /// Contains the certificates of those that the user normally sends enveloped messages to or receives signed messages from.
3257
+ /// See
3258
+ /// </summary>
3259
+ otherPeople,
3260
+
3261
+ /// <summary>
3262
+ /// Contains the certificates of those directly trusted people and resources.
3263
+ /// See
3264
+ /// </summary>
3265
+ trustedPeople,
3266
+
3267
+ /// <summary>
3268
+ /// Contains the certificates of those publishers who are trusted.
3269
+ /// See
3270
+ /// </summary>
3271
+ trustedPublisher,
3272
+ }
3273
+
3274
+ [GeneratedCode("XsdGen", "4.0.0.0")]
3275
+ public enum StoreLocationType
3276
+ {
3277
+
3278
+ IllegalValue = int.MaxValue,
3279
+
3280
+ NotSet = -1,
3281
+
3282
+ currentUser,
3283
+
3284
+ localMachine,
3285
+ }
3286
+ }
3287
+
3288
+ /// <summary>
3289
+ /// Associates a certificate with the parent WebSite. The Certificate element should be
3290
+ /// in the same Component as the parent WebSite.
3291
+ /// </summary>
3292
+ [GeneratedCode("XsdGen", "4.0.0.0")]
3293
+ public class CertificateRef : ISchemaElement, ISetAttributes
3294
+ {
3295
+
3296
+ private string idField;
3297
+
3298
+ private bool idFieldSet;
3299
+
3300
+ private ISchemaElement parentElement;
3301
+
3302
+ /// <summary>
3303
+ /// The identifier of the referenced Certificate.
3304
+ /// </summary>
3305
+ public string Id
3306
+ {
3307
+ get
3308
+ {
3309
+ return this.idField;
3310
+ }
3311
+ set
3312
+ {
3313
+ this.idFieldSet = true;
3314
+ this.idField = value;
3315
+ }
3316
+ }
3317
+
3318
+ public virtual ISchemaElement ParentElement
3319
+ {
3320
+ get
3321
+ {
3322
+ return this.parentElement;
3323
+ }
3324
+ set
3325
+ {
3326
+ this.parentElement = value;
3327
+ }
3328
+ }
3329
+
3330
+ /// <summary>
3331
+ /// Processes this element and all child elements into an XmlWriter.
3332
+ /// </summary>
3333
+ public virtual void OutputXml(XmlWriter writer)
3334
+ {
3335
+ if ((null == writer))
3336
+ {
3337
+ throw new ArgumentNullException("writer");
3338
+ }
3339
+ writer.WriteStartElement("CertificateRef", "http://wixtoolset.org/schemas/v4/wxs/iis");
3340
+ if (this.idFieldSet)
3341
+ {
3342
+ writer.WriteAttributeString("Id", this.idField);
3343
+ }
3344
+ writer.WriteEndElement();
3345
+ }
3346
+
3347
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
3348
+ void ISetAttributes.SetAttribute(string name, string value)
3349
+ {
3350
+ if (String.IsNullOrEmpty(name))
3351
+ {
3352
+ throw new ArgumentNullException("name");
3353
+ }
3354
+ if (("Id" == name))
3355
+ {
3356
+ this.idField = value;
3357
+ this.idFieldSet = true;
3358
+ }
3359
+ }
3360
+ }
3361
+
3362
+ /// <summary>
3363
+ /// IIS Properties
3364
+ /// </summary>
3365
+ [GeneratedCode("XsdGen", "4.0.0.0")]
3366
+ public class WebProperty : ISchemaElement, ISetAttributes
3367
+ {
3368
+
3369
+ private IdType idField;
3370
+
3371
+ private bool idFieldSet;
3372
+
3373
+ private string valueField;
3374
+
3375
+ private bool valueFieldSet;
3376
+
3377
+ private ISchemaElement parentElement;
3378
+
3379
+ public IdType Id
3380
+ {
3381
+ get
3382
+ {
3383
+ return this.idField;
3384
+ }
3385
+ set
3386
+ {
3387
+ this.idFieldSet = true;
3388
+ this.idField = value;
3389
+ }
3390
+ }
3391
+
3392
+ /// <summary>
3393
+ /// The value to be used for the WebProperty specified in the Id attribute. See
3394
+ /// the remarks section for information on acceptable values for each Id.
3395
+ /// </summary>
3396
+ public string Value
3397
+ {
3398
+ get
3399
+ {
3400
+ return this.valueField;
3401
+ }
3402
+ set
3403
+ {
3404
+ this.valueFieldSet = true;
3405
+ this.valueField = value;
3406
+ }
3407
+ }
3408
+
3409
+ public virtual ISchemaElement ParentElement
3410
+ {
3411
+ get
3412
+ {
3413
+ return this.parentElement;
3414
+ }
3415
+ set
3416
+ {
3417
+ this.parentElement = value;
3418
+ }
3419
+ }
3420
+
3421
+ /// <summary>
3422
+ /// Parses a IdType from a string.
3423
+ /// </summary>
3424
+ public static IdType ParseIdType(string value)
3425
+ {
3426
+ IdType parsedValue;
3427
+ WebProperty.TryParseIdType(value, out parsedValue);
3428
+ return parsedValue;
3429
+ }
3430
+
3431
+ /// <summary>
3432
+ /// Tries to parse a IdType from a string.
3433
+ /// </summary>
3434
+ public static bool TryParseIdType(string value, out IdType parsedValue)
3435
+ {
3436
+ parsedValue = IdType.NotSet;
3437
+ if (string.IsNullOrEmpty(value))
3438
+ {
3439
+ return false;
3440
+ }
3441
+ if (("ETagChangeNumber" == value))
3442
+ {
3443
+ parsedValue = IdType.ETagChangeNumber;
3444
+ }
3445
+ else
3446
+ {
3447
+ if (("IIs5IsolationMode" == value))
3448
+ {
3449
+ parsedValue = IdType.IIs5IsolationMode;
3450
+ }
3451
+ else
3452
+ {
3453
+ if (("MaxGlobalBandwidth" == value))
3454
+ {
3455
+ parsedValue = IdType.MaxGlobalBandwidth;
3456
+ }
3457
+ else
3458
+ {
3459
+ if (("LogInUTF8" == value))
3460
+ {
3461
+ parsedValue = IdType.LogInUTF8;
3462
+ }
3463
+ else
3464
+ {
3465
+ parsedValue = IdType.IllegalValue;
3466
+ return false;
3467
+ }
3468
+ }
3469
+ }
3470
+ }
3471
+ return true;
3472
+ }
3473
+
3474
+ /// <summary>
3475
+ /// Processes this element and all child elements into an XmlWriter.
3476
+ /// </summary>
3477
+ public virtual void OutputXml(XmlWriter writer)
3478
+ {
3479
+ if ((null == writer))
3480
+ {
3481
+ throw new ArgumentNullException("writer");
3482
+ }
3483
+ writer.WriteStartElement("WebProperty", "http://wixtoolset.org/schemas/v4/wxs/iis");
3484
+ if (this.idFieldSet)
3485
+ {
3486
+ if ((this.idField == IdType.ETagChangeNumber))
3487
+ {
3488
+ writer.WriteAttributeString("Id", "ETagChangeNumber");
3489
+ }
3490
+ if ((this.idField == IdType.IIs5IsolationMode))
3491
+ {
3492
+ writer.WriteAttributeString("Id", "IIs5IsolationMode");
3493
+ }
3494
+ if ((this.idField == IdType.MaxGlobalBandwidth))
3495
+ {
3496
+ writer.WriteAttributeString("Id", "MaxGlobalBandwidth");
3497
+ }
3498
+ if ((this.idField == IdType.LogInUTF8))
3499
+ {
3500
+ writer.WriteAttributeString("Id", "LogInUTF8");
3501
+ }
3502
+ }
3503
+ if (this.valueFieldSet)
3504
+ {
3505
+ writer.WriteAttributeString("Value", this.valueField);
3506
+ }
3507
+ writer.WriteEndElement();
3508
+ }
3509
+
3510
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
3511
+ void ISetAttributes.SetAttribute(string name, string value)
3512
+ {
3513
+ if (String.IsNullOrEmpty(name))
3514
+ {
3515
+ throw new ArgumentNullException("name");
3516
+ }
3517
+ if (("Id" == name))
3518
+ {
3519
+ this.idField = WebProperty.ParseIdType(value);
3520
+ this.idFieldSet = true;
3521
+ }
3522
+ if (("Value" == name))
3523
+ {
3524
+ this.valueField = value;
3525
+ this.valueFieldSet = true;
3526
+ }
3527
+ }
3528
+
3529
+ [GeneratedCode("XsdGen", "4.0.0.0")]
3530
+ public enum IdType
3531
+ {
3532
+
3533
+ IllegalValue = int.MaxValue,
3534
+
3535
+ NotSet = -1,
3536
+
3537
+ ETagChangeNumber,
3538
+
3539
+ IIs5IsolationMode,
3540
+
3541
+ MaxGlobalBandwidth,
3542
+
3543
+ LogInUTF8,
3544
+ }
3545
+ }
3546
+
3547
+ /// <summary>
3548
+ /// Defines properties for a web application. These properties can be used for more than one application defined in a web site or vroot, by defining this element in a common location and referring to it by setting the WebApplication attribute of the WebSite and WebVirtualDir elements.
3549
+ /// </summary>
3550
+ [GeneratedCode("XsdGen", "4.0.0.0")]
3551
+ public class WebApplication : IParentElement, ICreateChildren, ISchemaElement, ISetAttributes
3552
+ {
3553
+
3554
+ private ElementCollection children;
3555
+
3556
+ private string idField;
3557
+
3558
+ private bool idFieldSet;
3559
+
3560
+ private string nameField;
3561
+
3562
+ private bool nameFieldSet;
3563
+
3564
+ private IsolationType isolationField;
3565
+
3566
+ private bool isolationFieldSet;
3567
+
3568
+ private YesNoDefaultType allowSessionsField;
3569
+
3570
+ private bool allowSessionsFieldSet;
3571
+
3572
+ private int sessionTimeoutField;
3573
+
3574
+ private bool sessionTimeoutFieldSet;
3575
+
3576
+ private YesNoDefaultType bufferField;
3577
+
3578
+ private bool bufferFieldSet;
3579
+
3580
+ private YesNoDefaultType parentPathsField;
3581
+
3582
+ private bool parentPathsFieldSet;
3583
+
3584
+ private DefaultScriptType defaultScriptField;
3585
+
3586
+ private bool defaultScriptFieldSet;
3587
+
3588
+ private int scriptTimeoutField;
3589
+
3590
+ private bool scriptTimeoutFieldSet;
3591
+
3592
+ private YesNoDefaultType serverDebuggingField;
3593
+
3594
+ private bool serverDebuggingFieldSet;
3595
+
3596
+ private YesNoDefaultType clientDebuggingField;
3597
+
3598
+ private bool clientDebuggingFieldSet;
3599
+
3600
+ private string webAppPoolField;
3601
+
3602
+ private bool webAppPoolFieldSet;
3603
+
3604
+ private ISchemaElement parentElement;
3605
+
3606
+ public WebApplication()
3607
+ {
3608
+ ElementCollection childCollection0 = new ElementCollection(ElementCollection.CollectionType.Sequence);
3609
+ childCollection0.AddItem(new ElementCollection.SequenceItem(typeof(WebApplicationExtension)));
3610
+ this.children = childCollection0;
3611
+ }
3612
+
3613
+ public virtual IEnumerable Children
3614
+ {
3615
+ get
3616
+ {
3617
+ return this.children;
3618
+ }
3619
+ }
3620
+
3621
+ [SuppressMessage("Microsoft.Design", "CA1043:UseIntegralOrStringArgumentForIndexers")]
3622
+ public virtual IEnumerable this[System.Type childType]
3623
+ {
3624
+ get
3625
+ {
3626
+ return this.children.Filter(childType);
3627
+ }
3628
+ }
3629
+
3630
+ public string Id
3631
+ {
3632
+ get
3633
+ {
3634
+ return this.idField;
3635
+ }
3636
+ set
3637
+ {
3638
+ this.idFieldSet = true;
3639
+ this.idField = value;
3640
+ }
3641
+ }
3642
+
3643
+ /// <summary>
3644
+ /// Sets the name of this application.
3645
+ /// </summary>
3646
+ public string Name
3647
+ {
3648
+ get
3649
+ {
3650
+ return this.nameField;
3651
+ }
3652
+ set
3653
+ {
3654
+ this.nameFieldSet = true;
3655
+ this.nameField = value;
3656
+ }
3657
+ }
3658
+
3659
+ /// <summary>
3660
+ /// Sets the application isolation level for this application for pre-IIS 6 applications.
3661
+ /// </summary>
3662
+ public IsolationType Isolation
3663
+ {
3664
+ get
3665
+ {
3666
+ return this.isolationField;
3667
+ }
3668
+ set
3669
+ {
3670
+ this.isolationFieldSet = true;
3671
+ this.isolationField = value;
3672
+ }
3673
+ }
3674
+
3675
+ /// <summary>
3676
+ /// Sets the Enable Session State option. When enabled, you can set the session timeout using the SessionTimeout attribute.
3677
+ /// </summary>
3678
+ public YesNoDefaultType AllowSessions
3679
+ {
3680
+ get
3681
+ {
3682
+ return this.allowSessionsField;
3683
+ }
3684
+ set
3685
+ {
3686
+ this.allowSessionsFieldSet = true;
3687
+ this.allowSessionsField = value;
3688
+ }
3689
+ }
3690
+
3691
+ /// <summary>
3692
+ /// Sets the timeout value for sessions in minutes.
3693
+ /// </summary>
3694
+ public int SessionTimeout
3695
+ {
3696
+ get
3697
+ {
3698
+ return this.sessionTimeoutField;
3699
+ }
3700
+ set
3701
+ {
3702
+ this.sessionTimeoutFieldSet = true;
3703
+ this.sessionTimeoutField = value;
3704
+ }
3705
+ }
3706
+
3707
+ /// <summary>
3708
+ /// Sets the option that enables response buffering in the application, which allows ASP script to set response headers anywhere in the script.
3709
+ /// </summary>
3710
+ public YesNoDefaultType Buffer
3711
+ {
3712
+ get
3713
+ {
3714
+ return this.bufferField;
3715
+ }
3716
+ set
3717
+ {
3718
+ this.bufferFieldSet = true;
3719
+ this.bufferField = value;
3720
+ }
3721
+ }
3722
+
3723
+ /// <summary>
3724
+ /// Sets the parent paths option, which allows a client to use relative paths to reach parent directories from this application.
3725
+ /// </summary>
3726
+ public YesNoDefaultType ParentPaths
3727
+ {
3728
+ get
3729
+ {
3730
+ return this.parentPathsField;
3731
+ }
3732
+ set
3733
+ {
3734
+ this.parentPathsFieldSet = true;
3735
+ this.parentPathsField = value;
3736
+ }
3737
+ }
3738
+
3739
+ /// <summary>
3740
+ /// Sets the default script language for the site.
3741
+ /// </summary>
3742
+ public DefaultScriptType DefaultScript
3743
+ {
3744
+ get
3745
+ {
3746
+ return this.defaultScriptField;
3747
+ }
3748
+ set
3749
+ {
3750
+ this.defaultScriptFieldSet = true;
3751
+ this.defaultScriptField = value;
3752
+ }
3753
+ }
3754
+
3755
+ /// <summary>
3756
+ /// Sets the timeout value in seconds for executing ASP scripts.
3757
+ /// </summary>
3758
+ public int ScriptTimeout
3759
+ {
3760
+ get
3761
+ {
3762
+ return this.scriptTimeoutField;
3763
+ }
3764
+ set
3765
+ {
3766
+ this.scriptTimeoutFieldSet = true;
3767
+ this.scriptTimeoutField = value;
3768
+ }
3769
+ }
3770
+
3771
+ /// <summary>
3772
+ /// Enable ASP server-side script debugging.
3773
+ /// </summary>
3774
+ public YesNoDefaultType ServerDebugging
3775
+ {
3776
+ get
3777
+ {
3778
+ return this.serverDebuggingField;
3779
+ }
3780
+ set
3781
+ {
3782
+ this.serverDebuggingFieldSet = true;
3783
+ this.serverDebuggingField = value;
3784
+ }
3785
+ }
3786
+
3787
+ /// <summary>
3788
+ /// Enable ASP client-side script debugging.
3789
+ /// </summary>
3790
+ public YesNoDefaultType ClientDebugging
3791
+ {
3792
+ get
3793
+ {
3794
+ return this.clientDebuggingField;
3795
+ }
3796
+ set
3797
+ {
3798
+ this.clientDebuggingFieldSet = true;
3799
+ this.clientDebuggingField = value;
3800
+ }
3801
+ }
3802
+
3803
+ /// <summary>
3804
+ /// References the Id attribute of a WebAppPool element to use as the application pool for this application in IIS 6 applications.
3805
+ /// </summary>
3806
+ public string WebAppPool
3807
+ {
3808
+ get
3809
+ {
3810
+ return this.webAppPoolField;
3811
+ }
3812
+ set
3813
+ {
3814
+ this.webAppPoolFieldSet = true;
3815
+ this.webAppPoolField = value;
3816
+ }
3817
+ }
3818
+
3819
+ public virtual ISchemaElement ParentElement
3820
+ {
3821
+ get
3822
+ {
3823
+ return this.parentElement;
3824
+ }
3825
+ set
3826
+ {
3827
+ this.parentElement = value;
3828
+ }
3829
+ }
3830
+
3831
+ public virtual void AddChild(ISchemaElement child)
3832
+ {
3833
+ if ((null == child))
3834
+ {
3835
+ throw new ArgumentNullException("child");
3836
+ }
3837
+ this.children.AddElement(child);
3838
+ child.ParentElement = this;
3839
+ }
3840
+
3841
+ public virtual void RemoveChild(ISchemaElement child)
3842
+ {
3843
+ if ((null == child))
3844
+ {
3845
+ throw new ArgumentNullException("child");
3846
+ }
3847
+ this.children.RemoveElement(child);
3848
+ child.ParentElement = null;
3849
+ }
3850
+
3851
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
3852
+ ISchemaElement ICreateChildren.CreateChild(string childName)
3853
+ {
3854
+ if (String.IsNullOrEmpty(childName))
3855
+ {
3856
+ throw new ArgumentNullException("childName");
3857
+ }
3858
+ ISchemaElement childValue = null;
3859
+ if (("WebApplicationExtension" == childName))
3860
+ {
3861
+ childValue = new WebApplicationExtension();
3862
+ }
3863
+ if ((null == childValue))
3864
+ {
3865
+ throw new InvalidOperationException(String.Concat(childName, " is not a valid child name."));
3866
+ }
3867
+ return childValue;
3868
+ }
3869
+
3870
+ /// <summary>
3871
+ /// Parses a IsolationType from a string.
3872
+ /// </summary>
3873
+ public static IsolationType ParseIsolationType(string value)
3874
+ {
3875
+ IsolationType parsedValue;
3876
+ WebApplication.TryParseIsolationType(value, out parsedValue);
3877
+ return parsedValue;
3878
+ }
3879
+
3880
+ /// <summary>
3881
+ /// Tries to parse a IsolationType from a string.
3882
+ /// </summary>
3883
+ public static bool TryParseIsolationType(string value, out IsolationType parsedValue)
3884
+ {
3885
+ parsedValue = IsolationType.NotSet;
3886
+ if (string.IsNullOrEmpty(value))
3887
+ {
3888
+ return false;
3889
+ }
3890
+ if (("low" == value))
3891
+ {
3892
+ parsedValue = IsolationType.low;
3893
+ }
3894
+ else
3895
+ {
3896
+ if (("medium" == value))
3897
+ {
3898
+ parsedValue = IsolationType.medium;
3899
+ }
3900
+ else
3901
+ {
3902
+ if (("high" == value))
3903
+ {
3904
+ parsedValue = IsolationType.high;
3905
+ }
3906
+ else
3907
+ {
3908
+ parsedValue = IsolationType.IllegalValue;
3909
+ return false;
3910
+ }
3911
+ }
3912
+ }
3913
+ return true;
3914
+ }
3915
+
3916
+ /// <summary>
3917
+ /// Parses a DefaultScriptType from a string.
3918
+ /// </summary>
3919
+ public static DefaultScriptType ParseDefaultScriptType(string value)
3920
+ {
3921
+ DefaultScriptType parsedValue;
3922
+ WebApplication.TryParseDefaultScriptType(value, out parsedValue);
3923
+ return parsedValue;
3924
+ }
3925
+
3926
+ /// <summary>
3927
+ /// Tries to parse a DefaultScriptType from a string.
3928
+ /// </summary>
3929
+ public static bool TryParseDefaultScriptType(string value, out DefaultScriptType parsedValue)
3930
+ {
3931
+ parsedValue = DefaultScriptType.NotSet;
3932
+ if (string.IsNullOrEmpty(value))
3933
+ {
3934
+ return false;
3935
+ }
3936
+ if (("VBScript" == value))
3937
+ {
3938
+ parsedValue = DefaultScriptType.VBScript;
3939
+ }
3940
+ else
3941
+ {
3942
+ if (("JScript" == value))
3943
+ {
3944
+ parsedValue = DefaultScriptType.JScript;
3945
+ }
3946
+ else
3947
+ {
3948
+ parsedValue = DefaultScriptType.IllegalValue;
3949
+ return false;
3950
+ }
3951
+ }
3952
+ return true;
3953
+ }
3954
+
3955
+ /// <summary>
3956
+ /// Processes this element and all child elements into an XmlWriter.
3957
+ /// </summary>
3958
+ [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
3959
+ public virtual void OutputXml(XmlWriter writer)
3960
+ {
3961
+ if ((null == writer))
3962
+ {
3963
+ throw new ArgumentNullException("writer");
3964
+ }
3965
+ writer.WriteStartElement("WebApplication", "http://wixtoolset.org/schemas/v4/wxs/iis");
3966
+ if (this.idFieldSet)
3967
+ {
3968
+ writer.WriteAttributeString("Id", this.idField);
3969
+ }
3970
+ if (this.nameFieldSet)
3971
+ {
3972
+ writer.WriteAttributeString("Name", this.nameField);
3973
+ }
3974
+ if (this.isolationFieldSet)
3975
+ {
3976
+ if ((this.isolationField == IsolationType.low))
3977
+ {
3978
+ writer.WriteAttributeString("Isolation", "low");
3979
+ }
3980
+ if ((this.isolationField == IsolationType.medium))
3981
+ {
3982
+ writer.WriteAttributeString("Isolation", "medium");
3983
+ }
3984
+ if ((this.isolationField == IsolationType.high))
3985
+ {
3986
+ writer.WriteAttributeString("Isolation", "high");
3987
+ }
3988
+ }
3989
+ if (this.allowSessionsFieldSet)
3990
+ {
3991
+ if ((this.allowSessionsField == YesNoDefaultType.@default))
3992
+ {
3993
+ writer.WriteAttributeString("AllowSessions", "default");
3994
+ }
3995
+ if ((this.allowSessionsField == YesNoDefaultType.no))
3996
+ {
3997
+ writer.WriteAttributeString("AllowSessions", "no");
3998
+ }
3999
+ if ((this.allowSessionsField == YesNoDefaultType.yes))
4000
+ {
4001
+ writer.WriteAttributeString("AllowSessions", "yes");
4002
+ }
4003
+ }
4004
+ if (this.sessionTimeoutFieldSet)
4005
+ {
4006
+ writer.WriteAttributeString("SessionTimeout", this.sessionTimeoutField.ToString(CultureInfo.InvariantCulture));
4007
+ }
4008
+ if (this.bufferFieldSet)
4009
+ {
4010
+ if ((this.bufferField == YesNoDefaultType.@default))
4011
+ {
4012
+ writer.WriteAttributeString("Buffer", "default");
4013
+ }
4014
+ if ((this.bufferField == YesNoDefaultType.no))
4015
+ {
4016
+ writer.WriteAttributeString("Buffer", "no");
4017
+ }
4018
+ if ((this.bufferField == YesNoDefaultType.yes))
4019
+ {
4020
+ writer.WriteAttributeString("Buffer", "yes");
4021
+ }
4022
+ }
4023
+ if (this.parentPathsFieldSet)
4024
+ {
4025
+ if ((this.parentPathsField == YesNoDefaultType.@default))
4026
+ {
4027
+ writer.WriteAttributeString("ParentPaths", "default");
4028
+ }
4029
+ if ((this.parentPathsField == YesNoDefaultType.no))
4030
+ {
4031
+ writer.WriteAttributeString("ParentPaths", "no");
4032
+ }
4033
+ if ((this.parentPathsField == YesNoDefaultType.yes))
4034
+ {
4035
+ writer.WriteAttributeString("ParentPaths", "yes");
4036
+ }
4037
+ }
4038
+ if (this.defaultScriptFieldSet)
4039
+ {
4040
+ if ((this.defaultScriptField == DefaultScriptType.VBScript))
4041
+ {
4042
+ writer.WriteAttributeString("DefaultScript", "VBScript");
4043
+ }
4044
+ if ((this.defaultScriptField == DefaultScriptType.JScript))
4045
+ {
4046
+ writer.WriteAttributeString("DefaultScript", "JScript");
4047
+ }
4048
+ }
4049
+ if (this.scriptTimeoutFieldSet)
4050
+ {
4051
+ writer.WriteAttributeString("ScriptTimeout", this.scriptTimeoutField.ToString(CultureInfo.InvariantCulture));
4052
+ }
4053
+ if (this.serverDebuggingFieldSet)
4054
+ {
4055
+ if ((this.serverDebuggingField == YesNoDefaultType.@default))
4056
+ {
4057
+ writer.WriteAttributeString("ServerDebugging", "default");
4058
+ }
4059
+ if ((this.serverDebuggingField == YesNoDefaultType.no))
4060
+ {
4061
+ writer.WriteAttributeString("ServerDebugging", "no");
4062
+ }
4063
+ if ((this.serverDebuggingField == YesNoDefaultType.yes))
4064
+ {
4065
+ writer.WriteAttributeString("ServerDebugging", "yes");
4066
+ }
4067
+ }
4068
+ if (this.clientDebuggingFieldSet)
4069
+ {
4070
+ if ((this.clientDebuggingField == YesNoDefaultType.@default))
4071
+ {
4072
+ writer.WriteAttributeString("ClientDebugging", "default");
4073
+ }
4074
+ if ((this.clientDebuggingField == YesNoDefaultType.no))
4075
+ {
4076
+ writer.WriteAttributeString("ClientDebugging", "no");
4077
+ }
4078
+ if ((this.clientDebuggingField == YesNoDefaultType.yes))
4079
+ {
4080
+ writer.WriteAttributeString("ClientDebugging", "yes");
4081
+ }
4082
+ }
4083
+ if (this.webAppPoolFieldSet)
4084
+ {
4085
+ writer.WriteAttributeString("WebAppPool", this.webAppPoolField);
4086
+ }
4087
+ for (IEnumerator enumerator = this.children.GetEnumerator(); enumerator.MoveNext(); )
4088
+ {
4089
+ ISchemaElement childElement = ((ISchemaElement)(enumerator.Current));
4090
+ childElement.OutputXml(writer);
4091
+ }
4092
+ writer.WriteEndElement();
4093
+ }
4094
+
4095
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
4096
+ [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
4097
+ void ISetAttributes.SetAttribute(string name, string value)
4098
+ {
4099
+ if (String.IsNullOrEmpty(name))
4100
+ {
4101
+ throw new ArgumentNullException("name");
4102
+ }
4103
+ if (("Id" == name))
4104
+ {
4105
+ this.idField = value;
4106
+ this.idFieldSet = true;
4107
+ }
4108
+ if (("Name" == name))
4109
+ {
4110
+ this.nameField = value;
4111
+ this.nameFieldSet = true;
4112
+ }
4113
+ if (("Isolation" == name))
4114
+ {
4115
+ this.isolationField = WebApplication.ParseIsolationType(value);
4116
+ this.isolationFieldSet = true;
4117
+ }
4118
+ if (("AllowSessions" == name))
4119
+ {
4120
+ this.allowSessionsField = Enums.ParseYesNoDefaultType(value);
4121
+ this.allowSessionsFieldSet = true;
4122
+ }
4123
+ if (("SessionTimeout" == name))
4124
+ {
4125
+ this.sessionTimeoutField = Convert.ToInt32(value, CultureInfo.InvariantCulture);
4126
+ this.sessionTimeoutFieldSet = true;
4127
+ }
4128
+ if (("Buffer" == name))
4129
+ {
4130
+ this.bufferField = Enums.ParseYesNoDefaultType(value);
4131
+ this.bufferFieldSet = true;
4132
+ }
4133
+ if (("ParentPaths" == name))
4134
+ {
4135
+ this.parentPathsField = Enums.ParseYesNoDefaultType(value);
4136
+ this.parentPathsFieldSet = true;
4137
+ }
4138
+ if (("DefaultScript" == name))
4139
+ {
4140
+ this.defaultScriptField = WebApplication.ParseDefaultScriptType(value);
4141
+ this.defaultScriptFieldSet = true;
4142
+ }
4143
+ if (("ScriptTimeout" == name))
4144
+ {
4145
+ this.scriptTimeoutField = Convert.ToInt32(value, CultureInfo.InvariantCulture);
4146
+ this.scriptTimeoutFieldSet = true;
4147
+ }
4148
+ if (("ServerDebugging" == name))
4149
+ {
4150
+ this.serverDebuggingField = Enums.ParseYesNoDefaultType(value);
4151
+ this.serverDebuggingFieldSet = true;
4152
+ }
4153
+ if (("ClientDebugging" == name))
4154
+ {
4155
+ this.clientDebuggingField = Enums.ParseYesNoDefaultType(value);
4156
+ this.clientDebuggingFieldSet = true;
4157
+ }
4158
+ if (("WebAppPool" == name))
4159
+ {
4160
+ this.webAppPoolField = value;
4161
+ this.webAppPoolFieldSet = true;
4162
+ }
4163
+ }
4164
+
4165
+ [GeneratedCode("XsdGen", "4.0.0.0")]
4166
+ public enum IsolationType
4167
+ {
4168
+
4169
+ IllegalValue = int.MaxValue,
4170
+
4171
+ NotSet = -1,
4172
+
4173
+ /// <summary>
4174
+ /// Means the application executes within the IIS process.
4175
+ /// </summary>
4176
+ low,
4177
+
4178
+ /// <summary>
4179
+ /// Executes pooled in a separate process.
4180
+ /// </summary>
4181
+ medium,
4182
+
4183
+ /// <summary>
4184
+ /// Means execution alone in a separate process.
4185
+ /// </summary>
4186
+ high,
4187
+ }
4188
+
4189
+ [GeneratedCode("XsdGen", "4.0.0.0")]
4190
+ public enum DefaultScriptType
4191
+ {
4192
+
4193
+ IllegalValue = int.MaxValue,
4194
+
4195
+ NotSet = -1,
4196
+
4197
+ VBScript,
4198
+
4199
+ JScript,
4200
+ }
4201
+ }
4202
+
4203
+ /// <summary>
4204
+ /// WebAddress for WebSite
4205
+ /// </summary>
4206
+ [GeneratedCode("XsdGen", "4.0.0.0")]
4207
+ public class WebAddress : ISchemaElement, ISetAttributes
4208
+ {
4209
+
4210
+ private string idField;
4211
+
4212
+ private bool idFieldSet;
4213
+
4214
+ private string iPField;
4215
+
4216
+ private bool iPFieldSet;
4217
+
4218
+ private string portField;
4219
+
4220
+ private bool portFieldSet;
4221
+
4222
+ private string headerField;
4223
+
4224
+ private bool headerFieldSet;
4225
+
4226
+ private YesNoType secureField;
4227
+
4228
+ private bool secureFieldSet;
4229
+
4230
+ private ISchemaElement parentElement;
4231
+
4232
+ public string Id
4233
+ {
4234
+ get
4235
+ {
4236
+ return this.idField;
4237
+ }
4238
+ set
4239
+ {
4240
+ this.idFieldSet = true;
4241
+ this.idField = value;
4242
+ }
4243
+ }
4244
+
4245
+ /// <summary>
4246
+ /// The IP address to locate an existing WebSite or create a new WebSite. When the WebAddress is part of a WebSite element
4247
+ /// used to locate an existing web site the following rules are used:
4248
+ /// </summary>
4249
+ public string IP
4250
+ {
4251
+ get
4252
+ {
4253
+ return this.iPField;
4254
+ }
4255
+ set
4256
+ {
4257
+ this.iPFieldSet = true;
4258
+ this.iPField = value;
4259
+ }
4260
+ }
4261
+
4262
+ public string Port
4263
+ {
4264
+ get
4265
+ {
4266
+ return this.portField;
4267
+ }
4268
+ set
4269
+ {
4270
+ this.portFieldSet = true;
4271
+ this.portField = value;
4272
+ }
4273
+ }
4274
+
4275
+ public string Header
4276
+ {
4277
+ get
4278
+ {
4279
+ return this.headerField;
4280
+ }
4281
+ set
4282
+ {
4283
+ this.headerFieldSet = true;
4284
+ this.headerField = value;
4285
+ }
4286
+ }
4287
+
4288
+ /// <summary>
4289
+ /// Determines if this address represents a secure binding. The default is 'no'.
4290
+ /// </summary>
4291
+ public YesNoType Secure
4292
+ {
4293
+ get
4294
+ {
4295
+ return this.secureField;
4296
+ }
4297
+ set
4298
+ {
4299
+ this.secureFieldSet = true;
4300
+ this.secureField = value;
4301
+ }
4302
+ }
4303
+
4304
+ public virtual ISchemaElement ParentElement
4305
+ {
4306
+ get
4307
+ {
4308
+ return this.parentElement;
4309
+ }
4310
+ set
4311
+ {
4312
+ this.parentElement = value;
4313
+ }
4314
+ }
4315
+
4316
+ /// <summary>
4317
+ /// Processes this element and all child elements into an XmlWriter.
4318
+ /// </summary>
4319
+ public virtual void OutputXml(XmlWriter writer)
4320
+ {
4321
+ if ((null == writer))
4322
+ {
4323
+ throw new ArgumentNullException("writer");
4324
+ }
4325
+ writer.WriteStartElement("WebAddress", "http://wixtoolset.org/schemas/v4/wxs/iis");
4326
+ if (this.idFieldSet)
4327
+ {
4328
+ writer.WriteAttributeString("Id", this.idField);
4329
+ }
4330
+ if (this.iPFieldSet)
4331
+ {
4332
+ writer.WriteAttributeString("IP", this.iPField);
4333
+ }
4334
+ if (this.portFieldSet)
4335
+ {
4336
+ writer.WriteAttributeString("Port", this.portField);
4337
+ }
4338
+ if (this.headerFieldSet)
4339
+ {
4340
+ writer.WriteAttributeString("Header", this.headerField);
4341
+ }
4342
+ if (this.secureFieldSet)
4343
+ {
4344
+ if ((this.secureField == YesNoType.no))
4345
+ {
4346
+ writer.WriteAttributeString("Secure", "no");
4347
+ }
4348
+ if ((this.secureField == YesNoType.yes))
4349
+ {
4350
+ writer.WriteAttributeString("Secure", "yes");
4351
+ }
4352
+ }
4353
+ writer.WriteEndElement();
4354
+ }
4355
+
4356
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
4357
+ void ISetAttributes.SetAttribute(string name, string value)
4358
+ {
4359
+ if (String.IsNullOrEmpty(name))
4360
+ {
4361
+ throw new ArgumentNullException("name");
4362
+ }
4363
+ if (("Id" == name))
4364
+ {
4365
+ this.idField = value;
4366
+ this.idFieldSet = true;
4367
+ }
4368
+ if (("IP" == name))
4369
+ {
4370
+ this.iPField = value;
4371
+ this.iPFieldSet = true;
4372
+ }
4373
+ if (("Port" == name))
4374
+ {
4375
+ this.portField = value;
4376
+ this.portFieldSet = true;
4377
+ }
4378
+ if (("Header" == name))
4379
+ {
4380
+ this.headerField = value;
4381
+ this.headerFieldSet = true;
4382
+ }
4383
+ if (("Secure" == name))
4384
+ {
4385
+ this.secureField = Enums.ParseYesNoType(value);
4386
+ this.secureFieldSet = true;
4387
+ }
4388
+ }
4389
+ }
4390
+
4391
+ /// <summary>
4392
+ /// Defines an IIS virtual directory. When this element is a child of WebSite element, the virtual directory is defined within that web site. Otherwise this virtual directory must reference a WebSite element via the WebSite attribute
4393
+ /// </summary>
4394
+ [GeneratedCode("XsdGen", "4.0.0.0")]
4395
+ public class WebVirtualDir : IParentElement, ICreateChildren, ISchemaElement, ISetAttributes
4396
+ {
4397
+
4398
+ private ElementCollection children;
4399
+
4400
+ private string idField;
4401
+
4402
+ private bool idFieldSet;
4403
+
4404
+ private string webSiteField;
4405
+
4406
+ private bool webSiteFieldSet;
4407
+
4408
+ private string aliasField;
4409
+
4410
+ private bool aliasFieldSet;
4411
+
4412
+ private string directoryField;
4413
+
4414
+ private bool directoryFieldSet;
4415
+
4416
+ private string dirPropertiesField;
4417
+
4418
+ private bool dirPropertiesFieldSet;
4419
+
4420
+ private string webApplicationField;
4421
+
4422
+ private bool webApplicationFieldSet;
4423
+
4424
+ private ISchemaElement parentElement;
4425
+
4426
+ public WebVirtualDir()
4427
+ {
4428
+ ElementCollection childCollection0 = new ElementCollection(ElementCollection.CollectionType.Choice);
4429
+ childCollection0.AddItem(new ElementCollection.ChoiceItem(typeof(WebApplication)));
4430
+ childCollection0.AddItem(new ElementCollection.ChoiceItem(typeof(WebDirProperties)));
4431
+ childCollection0.AddItem(new ElementCollection.ChoiceItem(typeof(WebError)));
4432
+ childCollection0.AddItem(new ElementCollection.ChoiceItem(typeof(WebVirtualDir)));
4433
+ childCollection0.AddItem(new ElementCollection.ChoiceItem(typeof(HttpHeader)));
4434
+ childCollection0.AddItem(new ElementCollection.ChoiceItem(typeof(MimeMap)));
4435
+ this.children = childCollection0;
4436
+ }
4437
+
4438
+ public virtual IEnumerable Children
4439
+ {
4440
+ get
4441
+ {
4442
+ return this.children;
4443
+ }
4444
+ }
4445
+
4446
+ [SuppressMessage("Microsoft.Design", "CA1043:UseIntegralOrStringArgumentForIndexers")]
4447
+ public virtual IEnumerable this[System.Type childType]
4448
+ {
4449
+ get
4450
+ {
4451
+ return this.children.Filter(childType);
4452
+ }
4453
+ }
4454
+
4455
+ public string Id
4456
+ {
4457
+ get
4458
+ {
4459
+ return this.idField;
4460
+ }
4461
+ set
4462
+ {
4463
+ this.idFieldSet = true;
4464
+ this.idField = value;
4465
+ }
4466
+ }
4467
+
4468
+ /// <summary>
4469
+ /// References the Id attribute for a WebSite in which this virtual directory belongs. Required when this element is not a child of WebSite element.
4470
+ /// </summary>
4471
+ public string WebSite
4472
+ {
4473
+ get
4474
+ {
4475
+ return this.webSiteField;
4476
+ }
4477
+ set
4478
+ {
4479
+ this.webSiteFieldSet = true;
4480
+ this.webSiteField = value;
4481
+ }
4482
+ }
4483
+
4484
+ /// <summary>
4485
+ /// Sets the application name, which is the URL relative path used to access this virtual directory
4486
+ /// </summary>
4487
+ public string Alias
4488
+ {
4489
+ get
4490
+ {
4491
+ return this.aliasField;
4492
+ }
4493
+ set
4494
+ {
4495
+ this.aliasFieldSet = true;
4496
+ this.aliasField = value;
4497
+ }
4498
+ }
4499
+
4500
+ /// <summary>
4501
+ /// References the Id attribute for a Directory element that points to the content for this virtual directory.
4502
+ /// </summary>
4503
+ public string Directory
4504
+ {
4505
+ get
4506
+ {
4507
+ return this.directoryField;
4508
+ }
4509
+ set
4510
+ {
4511
+ this.directoryFieldSet = true;
4512
+ this.directoryField = value;
4513
+ }
4514
+ }
4515
+
4516
+ /// <summary>
4517
+ /// References the Id attribute for a WebDirProperties element that specifies the security and access properties for this virtual directory.
4518
+ /// This attribute may not be specified if a WebDirProperties element is directly nested in this element.
4519
+ /// </summary>
4520
+ public string DirProperties
4521
+ {
4522
+ get
4523
+ {
4524
+ return this.dirPropertiesField;
4525
+ }
4526
+ set
4527
+ {
4528
+ this.dirPropertiesFieldSet = true;
4529
+ this.dirPropertiesField = value;
4530
+ }
4531
+ }
4532
+
4533
+ /// <summary>
4534
+ /// References the Id attribute for a WebApplication element that specifies web application settings for this virtual directory. If a WebApplication child is not specified, the virtual directory does not host web applications.
4535
+ /// </summary>
4536
+ public string WebApplication
4537
+ {
4538
+ get
4539
+ {
4540
+ return this.webApplicationField;
4541
+ }
4542
+ set
4543
+ {
4544
+ this.webApplicationFieldSet = true;
4545
+ this.webApplicationField = value;
4546
+ }
4547
+ }
4548
+
4549
+ public virtual ISchemaElement ParentElement
4550
+ {
4551
+ get
4552
+ {
4553
+ return this.parentElement;
4554
+ }
4555
+ set
4556
+ {
4557
+ this.parentElement = value;
4558
+ }
4559
+ }
4560
+
4561
+ public virtual void AddChild(ISchemaElement child)
4562
+ {
4563
+ if ((null == child))
4564
+ {
4565
+ throw new ArgumentNullException("child");
4566
+ }
4567
+ this.children.AddElement(child);
4568
+ child.ParentElement = this;
4569
+ }
4570
+
4571
+ public virtual void RemoveChild(ISchemaElement child)
4572
+ {
4573
+ if ((null == child))
4574
+ {
4575
+ throw new ArgumentNullException("child");
4576
+ }
4577
+ this.children.RemoveElement(child);
4578
+ child.ParentElement = null;
4579
+ }
4580
+
4581
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
4582
+ [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
4583
+ ISchemaElement ICreateChildren.CreateChild(string childName)
4584
+ {
4585
+ if (String.IsNullOrEmpty(childName))
4586
+ {
4587
+ throw new ArgumentNullException("childName");
4588
+ }
4589
+ ISchemaElement childValue = null;
4590
+ if (("WebApplication" == childName))
4591
+ {
4592
+ childValue = new WebApplication();
4593
+ }
4594
+ if (("WebDirProperties" == childName))
4595
+ {
4596
+ childValue = new WebDirProperties();
4597
+ }
4598
+ if (("WebError" == childName))
4599
+ {
4600
+ childValue = new WebError();
4601
+ }
4602
+ if (("WebVirtualDir" == childName))
4603
+ {
4604
+ childValue = new WebVirtualDir();
4605
+ }
4606
+ if (("HttpHeader" == childName))
4607
+ {
4608
+ childValue = new HttpHeader();
4609
+ }
4610
+ if (("MimeMap" == childName))
4611
+ {
4612
+ childValue = new MimeMap();
4613
+ }
4614
+ if ((null == childValue))
4615
+ {
4616
+ throw new InvalidOperationException(String.Concat(childName, " is not a valid child name."));
4617
+ }
4618
+ return childValue;
4619
+ }
4620
+
4621
+ /// <summary>
4622
+ /// Processes this element and all child elements into an XmlWriter.
4623
+ /// </summary>
4624
+ [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
4625
+ public virtual void OutputXml(XmlWriter writer)
4626
+ {
4627
+ if ((null == writer))
4628
+ {
4629
+ throw new ArgumentNullException("writer");
4630
+ }
4631
+ writer.WriteStartElement("WebVirtualDir", "http://wixtoolset.org/schemas/v4/wxs/iis");
4632
+ if (this.idFieldSet)
4633
+ {
4634
+ writer.WriteAttributeString("Id", this.idField);
4635
+ }
4636
+ if (this.webSiteFieldSet)
4637
+ {
4638
+ writer.WriteAttributeString("WebSite", this.webSiteField);
4639
+ }
4640
+ if (this.aliasFieldSet)
4641
+ {
4642
+ writer.WriteAttributeString("Alias", this.aliasField);
4643
+ }
4644
+ if (this.directoryFieldSet)
4645
+ {
4646
+ writer.WriteAttributeString("Directory", this.directoryField);
4647
+ }
4648
+ if (this.dirPropertiesFieldSet)
4649
+ {
4650
+ writer.WriteAttributeString("DirProperties", this.dirPropertiesField);
4651
+ }
4652
+ if (this.webApplicationFieldSet)
4653
+ {
4654
+ writer.WriteAttributeString("WebApplication", this.webApplicationField);
4655
+ }
4656
+ for (IEnumerator enumerator = this.children.GetEnumerator(); enumerator.MoveNext(); )
4657
+ {
4658
+ ISchemaElement childElement = ((ISchemaElement)(enumerator.Current));
4659
+ childElement.OutputXml(writer);
4660
+ }
4661
+ writer.WriteEndElement();
4662
+ }
4663
+
4664
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
4665
+ void ISetAttributes.SetAttribute(string name, string value)
4666
+ {
4667
+ if (String.IsNullOrEmpty(name))
4668
+ {
4669
+ throw new ArgumentNullException("name");
4670
+ }
4671
+ if (("Id" == name))
4672
+ {
4673
+ this.idField = value;
4674
+ this.idFieldSet = true;
4675
+ }
4676
+ if (("WebSite" == name))
4677
+ {
4678
+ this.webSiteField = value;
4679
+ this.webSiteFieldSet = true;
4680
+ }
4681
+ if (("Alias" == name))
4682
+ {
4683
+ this.aliasField = value;
4684
+ this.aliasFieldSet = true;
4685
+ }
4686
+ if (("Directory" == name))
4687
+ {
4688
+ this.directoryField = value;
4689
+ this.directoryFieldSet = true;
4690
+ }
4691
+ if (("DirProperties" == name))
4692
+ {
4693
+ this.dirPropertiesField = value;
4694
+ this.dirPropertiesFieldSet = true;
4695
+ }
4696
+ if (("WebApplication" == name))
4697
+ {
4698
+ this.webApplicationField = value;
4699
+ this.webApplicationFieldSet = true;
4700
+ }
4701
+ }
4702
+ }
4703
+
4704
+ /// <summary>
4705
+ /// Defines a subdirectory within an IIS web site. When this element is a child of WebSite, the web directory is defined within that web site. Otherwise the web directory must reference a WebSite element via the WebSite attribute.
4706
+ /// </summary>
4707
+ [GeneratedCode("XsdGen", "4.0.0.0")]
4708
+ public class WebDir : IParentElement, ICreateChildren, ISchemaElement, ISetAttributes
4709
+ {
4710
+
4711
+ private ElementCollection children;
4712
+
4713
+ private string idField;
4714
+
4715
+ private bool idFieldSet;
4716
+
4717
+ private string webSiteField;
4718
+
4719
+ private bool webSiteFieldSet;
4720
+
4721
+ private string pathField;
4722
+
4723
+ private bool pathFieldSet;
4724
+
4725
+ private string dirPropertiesField;
4726
+
4727
+ private bool dirPropertiesFieldSet;
4728
+
4729
+ private ISchemaElement parentElement;
4730
+
4731
+ public WebDir()
4732
+ {
4733
+ ElementCollection childCollection0 = new ElementCollection(ElementCollection.CollectionType.Choice);
4734
+ childCollection0.AddItem(new ElementCollection.ChoiceItem(typeof(WebApplication)));
4735
+ childCollection0.AddItem(new ElementCollection.ChoiceItem(typeof(WebDirProperties)));
4736
+ this.children = childCollection0;
4737
+ }
4738
+
4739
+ public virtual IEnumerable Children
4740
+ {
4741
+ get
4742
+ {
4743
+ return this.children;
4744
+ }
4745
+ }
4746
+
4747
+ [SuppressMessage("Microsoft.Design", "CA1043:UseIntegralOrStringArgumentForIndexers")]
4748
+ public virtual IEnumerable this[System.Type childType]
4749
+ {
4750
+ get
4751
+ {
4752
+ return this.children.Filter(childType);
4753
+ }
4754
+ }
4755
+
4756
+ public string Id
4757
+ {
4758
+ get
4759
+ {
4760
+ return this.idField;
4761
+ }
4762
+ set
4763
+ {
4764
+ this.idFieldSet = true;
4765
+ this.idField = value;
4766
+ }
4767
+ }
4768
+
4769
+ /// <summary>
4770
+ /// References the Id attribute for a WebSite element in which this directory belongs. Required when this element is not a child of a WebSite element.
4771
+ /// </summary>
4772
+ public string WebSite
4773
+ {
4774
+ get
4775
+ {
4776
+ return this.webSiteField;
4777
+ }
4778
+ set
4779
+ {
4780
+ this.webSiteFieldSet = true;
4781
+ this.webSiteField = value;
4782
+ }
4783
+ }
4784
+
4785
+ /// <summary>
4786
+ /// Specifies the name of this web directory.
4787
+ /// </summary>
4788
+ public string Path
4789
+ {
4790
+ get
4791
+ {
4792
+ return this.pathField;
4793
+ }
4794
+ set
4795
+ {
4796
+ this.pathFieldSet = true;
4797
+ this.pathField = value;
4798
+ }
4799
+ }
4800
+
4801
+ /// <summary>
4802
+ /// References the Id attribute for a WebDirProperties element that specifies the security and access properties for this web directory.
4803
+ /// This attribute may not be specified if a WebDirProperties element is directly nested in this element.
4804
+ /// </summary>
4805
+ public string DirProperties
4806
+ {
4807
+ get
4808
+ {
4809
+ return this.dirPropertiesField;
4810
+ }
4811
+ set
4812
+ {
4813
+ this.dirPropertiesFieldSet = true;
4814
+ this.dirPropertiesField = value;
4815
+ }
4816
+ }
4817
+
4818
+ public virtual ISchemaElement ParentElement
4819
+ {
4820
+ get
4821
+ {
4822
+ return this.parentElement;
4823
+ }
4824
+ set
4825
+ {
4826
+ this.parentElement = value;
4827
+ }
4828
+ }
4829
+
4830
+ public virtual void AddChild(ISchemaElement child)
4831
+ {
4832
+ if ((null == child))
4833
+ {
4834
+ throw new ArgumentNullException("child");
4835
+ }
4836
+ this.children.AddElement(child);
4837
+ child.ParentElement = this;
4838
+ }
4839
+
4840
+ public virtual void RemoveChild(ISchemaElement child)
4841
+ {
4842
+ if ((null == child))
4843
+ {
4844
+ throw new ArgumentNullException("child");
4845
+ }
4846
+ this.children.RemoveElement(child);
4847
+ child.ParentElement = null;
4848
+ }
4849
+
4850
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
4851
+ ISchemaElement ICreateChildren.CreateChild(string childName)
4852
+ {
4853
+ if (String.IsNullOrEmpty(childName))
4854
+ {
4855
+ throw new ArgumentNullException("childName");
4856
+ }
4857
+ ISchemaElement childValue = null;
4858
+ if (("WebApplication" == childName))
4859
+ {
4860
+ childValue = new WebApplication();
4861
+ }
4862
+ if (("WebDirProperties" == childName))
4863
+ {
4864
+ childValue = new WebDirProperties();
4865
+ }
4866
+ if ((null == childValue))
4867
+ {
4868
+ throw new InvalidOperationException(String.Concat(childName, " is not a valid child name."));
4869
+ }
4870
+ return childValue;
4871
+ }
4872
+
4873
+ /// <summary>
4874
+ /// Processes this element and all child elements into an XmlWriter.
4875
+ /// </summary>
4876
+ public virtual void OutputXml(XmlWriter writer)
4877
+ {
4878
+ if ((null == writer))
4879
+ {
4880
+ throw new ArgumentNullException("writer");
4881
+ }
4882
+ writer.WriteStartElement("WebDir", "http://wixtoolset.org/schemas/v4/wxs/iis");
4883
+ if (this.idFieldSet)
4884
+ {
4885
+ writer.WriteAttributeString("Id", this.idField);
4886
+ }
4887
+ if (this.webSiteFieldSet)
4888
+ {
4889
+ writer.WriteAttributeString("WebSite", this.webSiteField);
4890
+ }
4891
+ if (this.pathFieldSet)
4892
+ {
4893
+ writer.WriteAttributeString("Path", this.pathField);
4894
+ }
4895
+ if (this.dirPropertiesFieldSet)
4896
+ {
4897
+ writer.WriteAttributeString("DirProperties", this.dirPropertiesField);
4898
+ }
4899
+ for (IEnumerator enumerator = this.children.GetEnumerator(); enumerator.MoveNext(); )
4900
+ {
4901
+ ISchemaElement childElement = ((ISchemaElement)(enumerator.Current));
4902
+ childElement.OutputXml(writer);
4903
+ }
4904
+ writer.WriteEndElement();
4905
+ }
4906
+
4907
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
4908
+ void ISetAttributes.SetAttribute(string name, string value)
4909
+ {
4910
+ if (String.IsNullOrEmpty(name))
4911
+ {
4912
+ throw new ArgumentNullException("name");
4913
+ }
4914
+ if (("Id" == name))
4915
+ {
4916
+ this.idField = value;
4917
+ this.idFieldSet = true;
4918
+ }
4919
+ if (("WebSite" == name))
4920
+ {
4921
+ this.webSiteField = value;
4922
+ this.webSiteFieldSet = true;
4923
+ }
4924
+ if (("Path" == name))
4925
+ {
4926
+ this.pathField = value;
4927
+ this.pathFieldSet = true;
4928
+ }
4929
+ if (("DirProperties" == name))
4930
+ {
4931
+ this.dirPropertiesField = value;
4932
+ this.dirPropertiesFieldSet = true;
4933
+ }
4934
+ }
4935
+ }
4936
+
4937
+ /// <summary>
4938
+ /// IIs Web Site
4939
+ /// </summary>
4940
+ [GeneratedCode("XsdGen", "4.0.0.0")]
4941
+ public class WebSite : IParentElement, ICreateChildren, ISchemaElement, ISetAttributes
4942
+ {
4943
+
4944
+ private ElementCollection children;
4945
+
4946
+ private string idField;
4947
+
4948
+ private bool idFieldSet;
4949
+
4950
+ private YesNoType autoStartField;
4951
+
4952
+ private bool autoStartFieldSet;
4953
+
4954
+ private YesNoType configureIfExistsField;
4955
+
4956
+ private bool configureIfExistsFieldSet;
4957
+
4958
+ private long connectionTimeoutField;
4959
+
4960
+ private bool connectionTimeoutFieldSet;
4961
+
4962
+ private string descriptionField;
4963
+
4964
+ private bool descriptionFieldSet;
4965
+
4966
+ private string directoryField;
4967
+
4968
+ private bool directoryFieldSet;
4969
+
4970
+ private string dirPropertiesField;
4971
+
4972
+ private bool dirPropertiesFieldSet;
4973
+
4974
+ private int sequenceField;
4975
+
4976
+ private bool sequenceFieldSet;
4977
+
4978
+ private string siteIdField;
4979
+
4980
+ private bool siteIdFieldSet;
4981
+
4982
+ private YesNoType startOnInstallField;
4983
+
4984
+ private bool startOnInstallFieldSet;
4985
+
4986
+ private string webApplicationField;
4987
+
4988
+ private bool webApplicationFieldSet;
4989
+
4990
+ private string webLogField;
4991
+
4992
+ private bool webLogFieldSet;
4993
+
4994
+ private ISchemaElement parentElement;
4995
+
4996
+ public WebSite()
4997
+ {
4998
+ ElementCollection childCollection0 = new ElementCollection(ElementCollection.CollectionType.Choice);
4999
+ childCollection0.AddItem(new ElementCollection.ChoiceItem(typeof(WebAddress)));
This file is too large to show in full.
src/heat/Serialize/util.cs
new
+11462
@@ -0,0 +1,11462 @@
1
+//------------------------------------------------------------------------------
2
+// <auto-generated>
3
+// This code was generated by a tool.
4
+// Runtime Version:4.0.30319.42000
5
+//
6
+// Changes to this file may cause incorrect behavior and will be lost if
7
+// the code is regenerated.
8
+// </auto-generated>
9
+//------------------------------------------------------------------------------
10
+
11
+#pragma warning disable 1591
12
+namespace WixToolset.Harvesters.Serialize.Util
13
+{
14
+ using System;
15
+ using System.CodeDom.Compiler;
16
+ using System.Collections;
17
+ using System.Diagnostics.CodeAnalysis;
18
+ using System.Globalization;
19
+ using System.Xml;
20
+ using WixToolset.Harvesters.Serialize;
21
+
22
+
23
+ /// <summary>
24
+ /// Values of this type will either be "yes" or "no".
25
+ /// </summary>
26
+ [GeneratedCode("XsdGen", "4.0.0.0")]
27
+ public enum YesNoType
28
+ {
29
+
30
+ IllegalValue = int.MaxValue,
31
+
32
+ NotSet = -1,
33
+
34
+ no,
35
+
36
+ yes,
37
+ }
38
+
39
+ [GeneratedCode("XsdGen", "4.0.0.0")]
40
+ public class Enums
41
+ {
42
+
43
+ /// <summary>
44
+ /// Parses a YesNoType from a string.
45
+ /// </summary>
46
+ public static YesNoType ParseYesNoType(string value)
47
+ {
48
+ YesNoType parsedValue;
49
+ Enums.TryParseYesNoType(value, out parsedValue);
50
+ return parsedValue;
51
+ }
52
+
53
+ /// <summary>
54
+ /// Tries to parse a YesNoType from a string.
55
+ /// </summary>
56
+ public static bool TryParseYesNoType(string value, out YesNoType parsedValue)
57
+ {
58
+ parsedValue = YesNoType.NotSet;
59
+ if (string.IsNullOrEmpty(value))
60
+ {
61
+ return false;
62
+ }
63
+ if (("no" == value))
64
+ {
65
+ parsedValue = YesNoType.no;
66
+ }
67
+ else
68
+ {
69
+ if (("yes" == value))
70
+ {
71
+ parsedValue = YesNoType.yes;
72
+ }
73
+ else
74
+ {
75
+ parsedValue = YesNoType.IllegalValue;
76
+ return false;
77
+ }
78
+ }
79
+ return true;
80
+ }
81
+
82
+ /// <summary>
83
+ /// Parses a PerformanceCounterLanguageType from a string.
84
+ /// </summary>
85
+ public static PerformanceCounterLanguageType ParsePerformanceCounterLanguageType(string value)
86
+ {
87
+ PerformanceCounterLanguageType parsedValue;
88
+ Enums.TryParsePerformanceCounterLanguageType(value, out parsedValue);
89
+ return parsedValue;
90
+ }
91
+
92
+ /// <summary>
93
+ /// Tries to parse a PerformanceCounterLanguageType from a string.
94
+ /// </summary>
95
+ public static bool TryParsePerformanceCounterLanguageType(string value, out PerformanceCounterLanguageType parsedValue)
96
+ {
97
+ parsedValue = PerformanceCounterLanguageType.NotSet;
98
+ if (string.IsNullOrEmpty(value))
99
+ {
100
+ return false;
101
+ }
102
+ if (("afrikaans" == value))
103
+ {
104
+ parsedValue = PerformanceCounterLanguageType.afrikaans;
105
+ }
106
+ else
107
+ {
108
+ if (("albanian" == value))
109
+ {
110
+ parsedValue = PerformanceCounterLanguageType.albanian;
111
+ }
112
+ else
113
+ {
114
+ if (("arabic" == value))
115
+ {
116
+ parsedValue = PerformanceCounterLanguageType.arabic;
117
+ }
118
+ else
119
+ {
120
+ if (("armenian" == value))
121
+ {
122
+ parsedValue = PerformanceCounterLanguageType.armenian;
123
+ }
124
+ else
125
+ {
126
+ if (("assamese" == value))
127
+ {
128
+ parsedValue = PerformanceCounterLanguageType.assamese;
129
+ }
130
+ else
131
+ {
132
+ if (("azeri" == value))
133
+ {
134
+ parsedValue = PerformanceCounterLanguageType.azeri;
135
+ }
136
+ else
137
+ {
138
+ if (("basque" == value))
139
+ {
140
+ parsedValue = PerformanceCounterLanguageType.basque;
141
+ }
142
+ else
143
+ {
144
+ if (("belarusian" == value))
145
+ {
146
+ parsedValue = PerformanceCounterLanguageType.belarusian;
147
+ }
148
+ else
149
+ {
150
+ if (("bengali" == value))
151
+ {
152
+ parsedValue = PerformanceCounterLanguageType.bengali;
153
+ }
154
+ else
155
+ {
156
+ if (("bulgarian" == value))
157
+ {
158
+ parsedValue = PerformanceCounterLanguageType.bulgarian;
159
+ }
160
+ else
161
+ {
162
+ if (("catalan" == value))
163
+ {
164
+ parsedValue = PerformanceCounterLanguageType.catalan;
165
+ }
166
+ else
167
+ {
168
+ if (("chinese" == value))
169
+ {
170
+ parsedValue = PerformanceCounterLanguageType.chinese;
171
+ }
172
+ else
173
+ {
174
+ if (("croatian" == value))
175
+ {
176
+ parsedValue = PerformanceCounterLanguageType.croatian;
177
+ }
178
+ else
179
+ {
180
+ if (("czech" == value))
181
+ {
182
+ parsedValue = PerformanceCounterLanguageType.czech;
183
+ }
184
+ else
185
+ {
186
+ if (("danish" == value))
187
+ {
188
+ parsedValue = PerformanceCounterLanguageType.danish;
189
+ }
190
+ else
191
+ {
192
+ if (("divehi" == value))
193
+ {
194
+ parsedValue = PerformanceCounterLanguageType.divehi;
195
+ }
196
+ else
197
+ {
198
+ if (("dutch" == value))
199
+ {
200
+ parsedValue = PerformanceCounterLanguageType.dutch;
201
+ }
202
+ else
203
+ {
204
+ if (("english" == value))
205
+ {
206
+ parsedValue = PerformanceCounterLanguageType.english;
207
+ }
208
+ else
209
+ {
210
+ if (("estonian" == value))
211
+ {
212
+ parsedValue = PerformanceCounterLanguageType.estonian;
213
+ }
214
+ else
215
+ {
216
+ if (("faeroese" == value))
217
+ {
218
+ parsedValue = PerformanceCounterLanguageType.faeroese;
219
+ }
220
+ else
221
+ {
222
+ if (("farsi" == value))
223
+ {
224
+ parsedValue = PerformanceCounterLanguageType.farsi;
225
+ }
226
+ else
227
+ {
228
+ if (("finnish" == value))
229
+ {
230
+ parsedValue = PerformanceCounterLanguageType.finnish;
231
+ }
232
+ else
233
+ {
234
+ if (("french" == value))
235
+ {
236
+ parsedValue = PerformanceCounterLanguageType.french;
237
+ }
238
+ else
239
+ {
240
+ if (("galician" == value))
241
+ {
242
+ parsedValue = PerformanceCounterLanguageType.galician;
243
+ }
244
+ else
245
+ {
246
+ if (("georgian" == value))
247
+ {
248
+ parsedValue = PerformanceCounterLanguageType.georgian;
249
+ }
250
+ else
251
+ {
252
+ if (("german" == value))
253
+ {
254
+ parsedValue = PerformanceCounterLanguageType.german;
255
+ }
256
+ else
257
+ {
258
+ if (("greek" == value))
259
+ {
260
+ parsedValue = PerformanceCounterLanguageType.greek;
261
+ }
262
+ else
263
+ {
264
+ if (("gujarati" == value))
265
+ {
266
+ parsedValue = PerformanceCounterLanguageType.gujarati;
267
+ }
268
+ else
269
+ {
270
+ if (("hebrew" == value))
271
+ {
272
+ parsedValue = PerformanceCounterLanguageType.hebrew;
273
+ }
274
+ else
275
+ {
276
+ if (("hindi" == value))
277
+ {
278
+ parsedValue = PerformanceCounterLanguageType.hindi;
279
+ }
280
+ else
281
+ {
282
+ if (("hungarian" == value))
283
+ {
284
+ parsedValue = PerformanceCounterLanguageType.hungarian;
285
+ }
286
+ else
287
+ {
288
+ if (("icelandic" == value))
289
+ {
290
+ parsedValue = PerformanceCounterLanguageType.icelandic;
291
+ }
292
+ else
293
+ {
294
+ if (("indonesian" == value))
295
+ {
296
+ parsedValue = PerformanceCounterLanguageType.indonesian;
297
+ }
298
+ else
299
+ {
300
+ if (("italian" == value))
301
+ {
302
+ parsedValue = PerformanceCounterLanguageType.italian;
303
+ }
304
+ else
305
+ {
306
+ if (("japanese" == value))
307
+ {
308
+ parsedValue = PerformanceCounterLanguageType.japanese;
309
+ }
310
+ else
311
+ {
312
+ if (("kannada" == value))
313
+ {
314
+ parsedValue = PerformanceCounterLanguageType.kannada;
315
+ }
316
+ else
317
+ {
318
+ if (("kashmiri" == value))
319
+ {
320
+ parsedValue = PerformanceCounterLanguageType.kashmiri;
321
+ }
322
+ else
323
+ {
324
+ if (("kazak" == value))
325
+ {
326
+ parsedValue = PerformanceCounterLanguageType.kazak;
327
+ }
328
+ else
329
+ {
330
+ if (("konkani" == value))
331
+ {
332
+ parsedValue = PerformanceCounterLanguageType.konkani;
333
+ }
334
+ else
335
+ {
336
+ if (("korean" == value))
337
+ {
338
+ parsedValue = PerformanceCounterLanguageType.korean;
339
+ }
340
+ else
341
+ {
342
+ if (("kyrgyz" == value))
343
+ {
344
+ parsedValue = PerformanceCounterLanguageType.kyrgyz;
345
+ }
346
+ else
347
+ {
348
+ if (("latvian" == value))
349
+ {
350
+ parsedValue = PerformanceCounterLanguageType.latvian;
351
+ }
352
+ else
353
+ {
354
+ if (("lithuanian" == value))
355
+ {
356
+ parsedValue = PerformanceCounterLanguageType.lithuanian;
357
+ }
358
+ else
359
+ {
360
+ if (("macedonian" == value))
361
+ {
362
+ parsedValue = PerformanceCounterLanguageType.macedonian;
363
+ }
364
+ else
365
+ {
366
+ if (("malay" == value))
367
+ {
368
+ parsedValue = PerformanceCounterLanguageType.malay;
369
+ }
370
+ else
371
+ {
372
+ if (("malayalam" == value))
373
+ {
374
+ parsedValue = PerformanceCounterLanguageType.malayalam;
375
+ }
376
+ else
377
+ {
378
+ if (("manipuri" == value))
379
+ {
380
+ parsedValue = PerformanceCounterLanguageType.manipuri;
381
+ }
382
+ else
383
+ {
384
+ if (("marathi" == value))
385
+ {
386
+ parsedValue = PerformanceCounterLanguageType.marathi;
387
+ }
388
+ else
389
+ {
390
+ if (("mongolian" == value))
391
+ {
392
+ parsedValue = PerformanceCounterLanguageType.mongolian;
393
+ }
394
+ else
395
+ {
396
+ if (("nepali" == value))
397
+ {
398
+ parsedValue = PerformanceCounterLanguageType.nepali;
399
+ }
400
+ else
401
+ {
402
+ if (("norwegian" == value))
403
+ {
404
+ parsedValue = PerformanceCounterLanguageType.norwegian;
405
+ }
406
+ else
407
+ {
408
+ if (("oriya" == value))
409
+ {
410
+ parsedValue = PerformanceCounterLanguageType.oriya;
411
+ }
412
+ else
413
+ {
414
+ if (("polish" == value))
415
+ {
416
+ parsedValue = PerformanceCounterLanguageType.polish;
417
+ }
418
+ else
419
+ {
420
+ if (("portuguese" == value))
421
+ {
422
+ parsedValue = PerformanceCounterLanguageType.portuguese;
423
+ }
424
+ else
425
+ {
426
+ if (("punjabi" == value))
427
+ {
428
+ parsedValue = PerformanceCounterLanguageType.punjabi;
429
+ }
430
+ else
431
+ {
432
+ if (("romanian" == value))
433
+ {
434
+ parsedValue = PerformanceCounterLanguageType.romanian;
435
+ }
436
+ else
437
+ {
438
+ if (("russian" == value))
439
+ {
440
+ parsedValue = PerformanceCounterLanguageType.russian;
441
+ }
442
+ else
443
+ {
444
+ if (("sanskrit" == value))
445
+ {
446
+ parsedValue = PerformanceCounterLanguageType.sanskrit;
447
+ }
448
+ else
449
+ {
450
+ if (("serbian" == value))
451
+ {
452
+ parsedValue = PerformanceCounterLanguageType.serbian;
453
+ }
454
+ else
455
+ {
456
+ if (("sindhi" == value))
457
+ {
458
+ parsedValue = PerformanceCounterLanguageType.sindhi;
459
+ }
460
+ else
461
+ {
462
+ if (("slovak" == value))
463
+ {
464
+ parsedValue = PerformanceCounterLanguageType.slovak;
465
+ }
466
+ else
467
+ {
468
+ if (("slovenian" == value))
469
+ {
470
+ parsedValue = PerformanceCounterLanguageType.slovenian;
471
+ }
472
+ else
473
+ {
474
+ if (("spanish" == value))
475
+ {
476
+ parsedValue = PerformanceCounterLanguageType.spanish;
477
+ }
478
+ else
479
+ {
480
+ if (("swahili" == value))
481
+ {
482
+ parsedValue = PerformanceCounterLanguageType.swahili;
483
+ }
484
+ else
485
+ {
486
+ if (("swedish" == value))
487
+ {
488
+ parsedValue = PerformanceCounterLanguageType.swedish;
489
+ }
490
+ else
491
+ {
492
+ if (("syriac" == value))
493
+ {
494
+ parsedValue = PerformanceCounterLanguageType.syriac;
495
+ }
496
+ else
497
+ {
498
+ if (("tamil" == value))
499
+ {
500
+ parsedValue = PerformanceCounterLanguageType.tamil;
501
+ }
502
+ else
503
+ {
504
+ if (("tatar" == value))
505
+ {
506
+ parsedValue = PerformanceCounterLanguageType.tatar;
507
+ }
508
+ else
509
+ {
510
+ if (("telugu" == value))
511
+ {
512
+ parsedValue = PerformanceCounterLanguageType.telugu;
513
+ }
514
+ else
515
+ {
516
+ if (("thai" == value))
517
+ {
518
+ parsedValue = PerformanceCounterLanguageType.thai;
519
+ }
520
+ else
521
+ {
522
+ if (("turkish" == value))
523
+ {
524
+ parsedValue = PerformanceCounterLanguageType.turkish;
525
+ }
526
+ else
527
+ {
528
+ if (("ukrainian" == value))
529
+ {
530
+ parsedValue = PerformanceCounterLanguageType.ukrainian;
531
+ }
532
+ else
533
+ {
534
+ if (("urdu" == value))
535
+ {
536
+ parsedValue = PerformanceCounterLanguageType.urdu;
537
+ }
538
+ else
539
+ {
540
+ if (("uzbek" == value))
541
+ {
542
+ parsedValue = PerformanceCounterLanguageType.uzbek;
543
+ }
544
+ else
545
+ {
546
+ if (("vietnamese" == value))
547
+ {
548
+ parsedValue = PerformanceCounterLanguageType.vietnamese;
549
+ }
550
+ else
551
+ {
552
+ parsedValue = PerformanceCounterLanguageType.IllegalValue;
553
+ return false;
554
+ }
555
+ }
556
+ }
557
+ }
558
+ }
559
+ }
560
+ }
561
+ }
562
+ }
563
+ }
564
+ }
565
+ }
566
+ }
567
+ }
568
+ }
569
+ }
570
+ }
571
+ }
572
+ }
573
+ }
574
+ }
575
+ }
576
+ }
577
+ }
578
+ }
579
+ }
580
+ }
581
+ }
582
+ }
583
+ }
584
+ }
585
+ }
586
+ }
587
+ }
588
+ }
589
+ }
590
+ }
591
+ }
592
+ }
593
+ }
594
+ }
595
+ }
596
+ }
597
+ }
598
+ }
599
+ }
600
+ }
601
+ }
602
+ }
603
+ }
604
+ }
605
+ }
606
+ }
607
+ }
608
+ }
609
+ }
610
+ }
611
+ }
612
+ }
613
+ }
614
+ }
615
+ }
616
+ }
617
+ }
618
+ }
619
+ }
620
+ }
621
+ }
622
+ }
623
+ }
624
+ }
625
+ }
626
+ }
627
+ }
628
+ }
629
+ return true;
630
+ }
631
+
632
+ /// <summary>
633
+ /// Parses a PerformanceCounterTypesType from a string.
634
+ /// </summary>
635
+ public static PerformanceCounterTypesType ParsePerformanceCounterTypesType(string value)
636
+ {
637
+ PerformanceCounterTypesType parsedValue;
638
+ Enums.TryParsePerformanceCounterTypesType(value, out parsedValue);
639
+ return parsedValue;
640
+ }
641
+
642
+ /// <summary>
643
+ /// Tries to parse a PerformanceCounterTypesType from a string.
644
+ /// </summary>
645
+ public static bool TryParsePerformanceCounterTypesType(string value, out PerformanceCounterTypesType parsedValue)
646
+ {
647
+ parsedValue = PerformanceCounterTypesType.NotSet;
648
+ if (string.IsNullOrEmpty(value))
649
+ {
650
+ return false;
651
+ }
652
+ if (("averageBase" == value))
653
+ {
654
+ parsedValue = PerformanceCounterTypesType.averageBase;
655
+ }
656
+ else
657
+ {
658
+ if (("averageCount64" == value))
659
+ {
660
+ parsedValue = PerformanceCounterTypesType.averageCount64;
661
+ }
662
+ else
663
+ {
664
+ if (("averageTimer32" == value))
665
+ {
666
+ parsedValue = PerformanceCounterTypesType.averageTimer32;
667
+ }
668
+ else
669
+ {
670
+ if (("counterDelta32" == value))
671
+ {
672
+ parsedValue = PerformanceCounterTypesType.counterDelta32;
673
+ }
674
+ else
675
+ {
676
+ if (("counterTimerInverse" == value))
677
+ {
678
+ parsedValue = PerformanceCounterTypesType.counterTimerInverse;
679
+ }
680
+ else
681
+ {
682
+ if (("sampleFraction" == value))
683
+ {
684
+ parsedValue = PerformanceCounterTypesType.sampleFraction;
685
+ }
686
+ else
687
+ {
688
+ if (("timer100Ns" == value))
689
+ {
690
+ parsedValue = PerformanceCounterTypesType.timer100Ns;
691
+ }
692
+ else
693
+ {
694
+ if (("counterTimer" == value))
695
+ {
696
+ parsedValue = PerformanceCounterTypesType.counterTimer;
697
+ }
698
+ else
699
+ {
700
+ if (("rawFraction" == value))
701
+ {
702
+ parsedValue = PerformanceCounterTypesType.rawFraction;
703
+ }
704
+ else
705
+ {
706
+ if (("timer100NsInverse" == value))
707
+ {
708
+ parsedValue = PerformanceCounterTypesType.timer100NsInverse;
709
+ }
710
+ else
711
+ {
712
+ if (("counterMultiTimer" == value))
713
+ {
714
+ parsedValue = PerformanceCounterTypesType.counterMultiTimer;
715
+ }
716
+ else
717
+ {
718
+ if (("counterMultiTimer100Ns" == value))
719
+ {
720
+ parsedValue = PerformanceCounterTypesType.counterMultiTimer100Ns;
721
+ }
722
+ else
723
+ {
724
+ if (("counterMultiTimerInverse" == value))
725
+ {
726
+ parsedValue = PerformanceCounterTypesType.counterMultiTimerInverse;
727
+ }
728
+ else
729
+ {
730
+ if (("counterMultiTimer100NsInverse" == value))
731
+ {
732
+ parsedValue = PerformanceCounterTypesType.counterMultiTimer100NsInverse;
733
+ }
734
+ else
735
+ {
736
+ if (("elapsedTime" == value))
737
+ {
738
+ parsedValue = PerformanceCounterTypesType.elapsedTime;
739
+ }
740
+ else
741
+ {
742
+ if (("sampleBase" == value))
743
+ {
744
+ parsedValue = PerformanceCounterTypesType.sampleBase;
745
+ }
746
+ else
747
+ {
748
+ if (("rawBase" == value))
749
+ {
750
+ parsedValue = PerformanceCounterTypesType.rawBase;
751
+ }
752
+ else
753
+ {
754
+ if (("counterMultiBase" == value))
755
+ {
756
+ parsedValue = PerformanceCounterTypesType.counterMultiBase;
757
+ }
758
+ else
759
+ {
760
+ if (("rateOfCountsPerSecond64" == value))
761
+ {
762
+ parsedValue = PerformanceCounterTypesType.rateOfCountsPerSecond64;
763
+ }
764
+ else
765
+ {
766
+ if (("rateOfCountsPerSecond32" == value))
767
+ {
768
+ parsedValue = PerformanceCounterTypesType.rateOfCountsPerSecond32;
769
+ }
770
+ else
771
+ {
772
+ if (("countPerTimeInterval64" == value))
773
+ {
774
+ parsedValue = PerformanceCounterTypesType.countPerTimeInterval64;
775
+ }
776
+ else
777
+ {
778
+ if (("countPerTimeInterval32" == value))
779
+ {
780
+ parsedValue = PerformanceCounterTypesType.countPerTimeInterval32;
781
+ }
782
+ else
783
+ {
784
+ if (("sampleCounter" == value))
785
+ {
786
+ parsedValue = PerformanceCounterTypesType.sampleCounter;
787
+ }
788
+ else
789
+ {
790
+ if (("counterDelta64" == value))
791
+ {
792
+ parsedValue = PerformanceCounterTypesType.counterDelta64;
793
+ }
794
+ else
795
+ {
796
+ if (("numberOfItems64" == value))
797
+ {
798
+ parsedValue = PerformanceCounterTypesType.numberOfItems64;
799
+ }
800
+ else
801
+ {
802
+ if (("numberOfItems32" == value))
803
+ {
804
+ parsedValue = PerformanceCounterTypesType.numberOfItems32;
805
+ }
806
+ else
807
+ {
808
+ if (("numberOfItemsHEX64" == value))
809
+ {
810
+ parsedValue = PerformanceCounterTypesType.numberOfItemsHEX64;
811
+ }
812
+ else
813
+ {
814
+ if (("numberOfItemsHEX32" == value))
815
+ {
816
+ parsedValue = PerformanceCounterTypesType.numberOfItemsHEX32;
817
+ }
818
+ else
819
+ {
820
+ parsedValue = PerformanceCounterTypesType.IllegalValue;
821
+ return false;
822
+ }
823
+ }
824
+ }
825
+ }
826
+ }
827
+ }
828
+ }
829
+ }
830
+ }
831
+ }
832
+ }
833
+ }
834
+ }
835
+ }
836
+ }
837
+ }
838
+ }
839
+ }
840
+ }
841
+ }
842
+ }
843
+ }
844
+ }
845
+ }
846
+ }
847
+ }
848
+ }
849
+ }
850
+ return true;
851
+ }
852
+ }
853
+
854
+ /// <summary>
855
+ /// Enumeration of valid languages for performance counters.
856
+ /// </summary>
857
+ [GeneratedCode("XsdGen", "4.0.0.0")]
858
+ public enum PerformanceCounterLanguageType
859
+ {
860
+
861
+ IllegalValue = int.MaxValue,
862
+
863
+ NotSet = -1,
864
+
865
+ afrikaans,
866
+
867
+ albanian,
868
+
869
+ arabic,
870
+
871
+ armenian,
872
+
873
+ assamese,
874
+
875
+ azeri,
876
+
877
+ basque,
878
+
879
+ belarusian,
880
+
881
+ bengali,
882
+
883
+ bulgarian,
884
+
885
+ catalan,
886
+
887
+ chinese,
888
+
889
+ croatian,
890
+
891
+ czech,
892
+
893
+ danish,
894
+
895
+ divehi,
896
+
897
+ dutch,
898
+
899
+ english,
900
+
901
+ estonian,
902
+
903
+ faeroese,
904
+
905
+ farsi,
906
+
907
+ finnish,
908
+
909
+ french,
910
+
911
+ galician,
912
+
913
+ georgian,
914
+
915
+ german,
916
+
917
+ greek,
918
+
919
+ gujarati,
920
+
921
+ hebrew,
922
+
923
+ hindi,
924
+
925
+ hungarian,
926
+
927
+ icelandic,
928
+
929
+ indonesian,
930
+
931
+ italian,
932
+
933
+ japanese,
934
+
935
+ kannada,
936
+
937
+ kashmiri,
938
+
939
+ kazak,
940
+
941
+ konkani,
942
+
943
+ korean,
944
+
945
+ kyrgyz,
946
+
947
+ latvian,
948
+
949
+ lithuanian,
950
+
951
+ macedonian,
952
+
953
+ malay,
954
+
955
+ malayalam,
956
+
957
+ manipuri,
958
+
959
+ marathi,
960
+
961
+ mongolian,
962
+
963
+ nepali,
964
+
965
+ norwegian,
966
+
967
+ oriya,
968
+
969
+ polish,
970
+
971
+ portuguese,
972
+
973
+ punjabi,
974
+
975
+ romanian,
976
+
977
+ russian,
978
+
979
+ sanskrit,
980
+
981
+ serbian,
982
+
983
+ sindhi,
984
+
985
+ slovak,
986
+
987
+ slovenian,
988
+
989
+ spanish,
990
+
991
+ swahili,
992
+
993
+ swedish,
994
+
995
+ syriac,
996
+
997
+ tamil,
998
+
999
+ tatar,
1000
+
1001
+ telugu,
1002
+
1003
+ thai,
1004
+
1005
+ turkish,
1006
+
1007
+ ukrainian,
1008
+
1009
+ urdu,
1010
+
1011
+ uzbek,
1012
+
1013
+ vietnamese,
1014
+ }
1015
+
1016
+ /// <summary>
1017
+ /// Enumeration of valid types for performance counters.
1018
+ /// </summary>
1019
+ [GeneratedCode("XsdGen", "4.0.0.0")]
1020
+ public enum PerformanceCounterTypesType
1021
+ {
1022
+
1023
+ IllegalValue = int.MaxValue,
1024
+
1025
+ NotSet = -1,
1026
+
1027
+ averageBase,
1028
+
1029
+ averageCount64,
1030
+
1031
+ averageTimer32,
1032
+
1033
+ counterDelta32,
1034
+
1035
+ counterTimerInverse,
1036
+
1037
+ sampleFraction,
1038
+
1039
+ timer100Ns,
1040
+
1041
+ counterTimer,
1042
+
1043
+ rawFraction,
1044
+
1045
+ timer100NsInverse,
1046
+
1047
+ counterMultiTimer,
1048
+
1049
+ counterMultiTimer100Ns,
1050
+
1051
+ counterMultiTimerInverse,
1052
+
1053
+ counterMultiTimer100NsInverse,
1054
+
1055
+ elapsedTime,
1056
+
1057
+ sampleBase,
1058
+
1059
+ rawBase,
1060
+
1061
+ counterMultiBase,
1062
+
1063
+ rateOfCountsPerSecond64,
1064
+
1065
+ rateOfCountsPerSecond32,
1066
+
1067
+ countPerTimeInterval64,
1068
+
1069
+ countPerTimeInterval32,
1070
+
1071
+ sampleCounter,
1072
+
1073
+ counterDelta64,
1074
+
1075
+ numberOfItems64,
1076
+
1077
+ numberOfItems32,
1078
+
1079
+ numberOfItemsHEX64,
1080
+
1081
+ numberOfItemsHEX32,
1082
+ }
1083
+
1084
+ /// <summary>
1085
+ /// Closes applications or schedules a reboot if application cannot be closed.
1086
+ /// </summary>
1087
+ [GeneratedCode("XsdGen", "4.0.0.0")]
1088
+ public class CloseApplication : ISchemaElement, ISetAttributes
1089
+ {
1090
+
1091
+ private string idField;
1092
+
1093
+ private bool idFieldSet;
1094
+
1095
+ private string targetField;
1096
+
1097
+ private bool targetFieldSet;
1098
+
1099
+ private string descriptionField;
1100
+
1101
+ private bool descriptionFieldSet;
1102
+
1103
+ private int sequenceField;
1104
+
1105
+ private bool sequenceFieldSet;
1106
+
1107
+ private YesNoType closeMessageField;
1108
+
1109
+ private bool closeMessageFieldSet;
1110
+
1111
+ private YesNoType endSessionMessageField;
1112
+
1113
+ private bool endSessionMessageFieldSet;
1114
+
1115
+ private YesNoType elevatedCloseMessageField;
1116
+
1117
+ private bool elevatedCloseMessageFieldSet;
1118
+
1119
+ private YesNoType elevatedEndSessionMessageField;
1120
+
1121
+ private bool elevatedEndSessionMessageFieldSet;
1122
+
1123
+ private YesNoType rebootPromptField;
1124
+
1125
+ private bool rebootPromptFieldSet;
1126
+
1127
+ private YesNoType promptToContinueField;
1128
+
1129
+ private bool promptToContinueFieldSet;
1130
+
1131
+ private string propertyField;
1132
+
1133
+ private bool propertyFieldSet;
1134
+
1135
+ private int terminateProcessField;
1136
+
1137
+ private bool terminateProcessFieldSet;
1138
+
1139
+ private int timeoutField;
1140
+
1141
+ private bool timeoutFieldSet;
1142
+
1143
+ private string contentField;
1144
+
1145
+ private bool contentFieldSet;
1146
+
1147
+ private ISchemaElement parentElement;
1148
+
1149
+ /// <summary>
1150
+ /// Identifier for the close application (primary key). If the Id is not specified, one will be generated.
1151
+ /// </summary>
1152
+ public string Id
1153
+ {
1154
+ get
1155
+ {
1156
+ return this.idField;
1157
+ }
1158
+ set
1159
+ {
1160
+ this.idFieldSet = true;
1161
+ this.idField = value;
1162
+ }
1163
+ }
1164
+
1165
+ /// <summary>
1166
+ /// Name of the exectuable to be closed. This should only be the file name.
1167
+ /// </summary>
1168
+ public string Target
1169
+ {
1170
+ get
1171
+ {
1172
+ return this.targetField;
1173
+ }
1174
+ set
1175
+ {
1176
+ this.targetFieldSet = true;
1177
+ this.targetField = value;
1178
+ }
1179
+ }
1180
+
1181
+ /// <summary>
1182
+ /// Description to show if application is running and needs to be closed.
1183
+ /// </summary>
1184
+ public string Description
1185
+ {
1186
+ get
1187
+ {
1188
+ return this.descriptionField;
1189
+ }
1190
+ set
1191
+ {
1192
+ this.descriptionFieldSet = true;
1193
+ this.descriptionField = value;
1194
+ }
1195
+ }
1196
+
1197
+ /// <summary>
1198
+ /// Optionally orders the applications to be closed.
1199
+ /// </summary>
1200
+ public int Sequence
1201
+ {
1202
+ get
1203
+ {
1204
+ return this.sequenceField;
1205
+ }
1206
+ set
1207
+ {
1208
+ this.sequenceFieldSet = true;
1209
+ this.sequenceField = value;
1210
+ }
1211
+ }
1212
+
1213
+ /// <summary>
1214
+ /// Optionally sends a close message to the application. Default is no.
1215
+ /// </summary>
1216
+ public YesNoType CloseMessage
1217
+ {
1218
+ get
1219
+ {
1220
+ return this.closeMessageField;
1221
+ }
1222
+ set
1223
+ {
1224
+ this.closeMessageFieldSet = true;
1225
+ this.closeMessageField = value;
1226
+ }
1227
+ }
1228
+
1229
+ /// <summary>
1230
+ /// Sends WM_QUERYENDSESSION then WM_ENDSESSION messages to the application. Default is "no".
1231
+ /// </summary>
1232
+ public YesNoType EndSessionMessage
1233
+ {
1234
+ get
1235
+ {
1236
+ return this.endSessionMessageField;
1237
+ }
1238
+ set
1239
+ {
1240
+ this.endSessionMessageFieldSet = true;
1241
+ this.endSessionMessageField = value;
1242
+ }
1243
+ }
1244
+
1245
+ /// <summary>
1246
+ /// Optionally sends a close message to the application from deffered action without impersonation. Default is no.
1247
+ /// </summary>
1248
+ public YesNoType ElevatedCloseMessage
1249
+ {
1250
+ get
1251
+ {
1252
+ return this.elevatedCloseMessageField;
1253
+ }
1254
+ set
1255
+ {
1256
+ this.elevatedCloseMessageFieldSet = true;
1257
+ this.elevatedCloseMessageField = value;
1258
+ }
1259
+ }
1260
+
1261
+ /// <summary>
1262
+ /// Sends WM_QUERYENDSESSION then WM_ENDSESSION messages to the application from a deffered action without impersonation. Default is "no".
1263
+ /// </summary>
1264
+ public YesNoType ElevatedEndSessionMessage
1265
+ {
1266
+ get
1267
+ {
1268
+ return this.elevatedEndSessionMessageField;
1269
+ }
1270
+ set
1271
+ {
1272
+ this.elevatedEndSessionMessageFieldSet = true;
1273
+ this.elevatedEndSessionMessageField = value;
1274
+ }
1275
+ }
1276
+
1277
+ /// <summary>
1278
+ /// Optionally prompts for reboot if application is still running. The default is "yes". The TerminateProcess attribute must be "no" or not specified if this attribute is "yes".
1279
+ /// </summary>
1280
+ public YesNoType RebootPrompt
1281
+ {
1282
+ get
1283
+ {
1284
+ return this.rebootPromptField;
1285
+ }
1286
+ set
1287
+ {
1288
+ this.rebootPromptFieldSet = true;
1289
+ this.rebootPromptField = value;
1290
+ }
1291
+ }
1292
+
1293
+ /// <summary>
1294
+ /// When this attribute is set to "yes", the user will be prompted when the application is still running. The Description attribute must contain the message to
1295
+ /// display in the prompt. The prompt occurs before executing any of the other options and gives the options to "Abort", "Retry", or "Ignore". Abort will cancel
1296
+ /// the install. Retry will attempt the check again and if the application is still running, prompt again. "Ignore" will continue and execute any other options
1297
+ /// set on the CloseApplication element. The default is "no".
1298
+ /// </summary>
1299
+ public YesNoType PromptToContinue
1300
+ {
1301
+ get
1302
+ {
1303
+ return this.promptToContinueField;
1304
+ }
1305
+ set
1306
+ {
1307
+ this.promptToContinueFieldSet = true;
1308
+ this.promptToContinueField = value;
1309
+ }
1310
+ }
1311
+
1312
+ /// <summary>
1313
+ /// Property to be set if application is still running. Useful for launch conditions or to conditionalize custom UI to ask user to shut down apps.
1314
+ /// </summary>
1315
+ public string Property
1316
+ {
1317
+ get
1318
+ {
1319
+ return this.propertyField;
1320
+ }
1321
+ set
1322
+ {
1323
+ this.propertyFieldSet = true;
1324
+ this.propertyField = value;
1325
+ }
1326
+ }
1327
+
1328
+ /// <summary>
1329
+ /// Attempts to terminates process and return the specified exit code if application is still running after sending any requested close and/or end session messages.
1330
+ /// If this attribute is specified, the RebootPrompt attribute must be "no". The default is "no".
1331
+ /// </summary>
1332
+ public int TerminateProcess
1333
+ {
1334
+ get
1335
+ {
1336
+ return this.terminateProcessField;
1337
+ }
1338
+ set
1339
+ {
1340
+ this.terminateProcessFieldSet = true;
1341
+ this.terminateProcessField = value;
1342
+ }
1343
+ }
1344
+
1345
+ /// <summary>
1346
+ /// Optional time in seconds to wait for the application to exit after the close and/or end session messages. If the application is still running after the timeout then
1347
+ /// the RebootPrompt or TerminateProcess attributes will be considered. The default value is "5" seconds.
1348
+ /// </summary>
1349
+ public int Timeout
1350
+ {
1351
+ get
1352
+ {
1353
+ return this.timeoutField;
1354
+ }
1355
+ set
1356
+ {
1357
+ this.timeoutFieldSet = true;
1358
+ this.timeoutField = value;
1359
+ }
1360
+ }
1361
+
1362
+ /// <summary>
1363
+ /// Condition that determines if the application should be closed. Must be blank or evaluate to true
1364
+ /// for the application to be scheduled for closing.
1365
+ /// </summary>
1366
+ public string Content
1367
+ {
1368
+ get
1369
+ {
1370
+ return this.contentField;
1371
+ }
1372
+ set
1373
+ {
1374
+ this.contentFieldSet = true;
1375
+ this.contentField = value;
1376
+ }
1377
+ }
1378
+
1379
+ public virtual ISchemaElement ParentElement
1380
+ {
1381
+ get
1382
+ {
1383
+ return this.parentElement;
1384
+ }
1385
+ set
1386
+ {
1387
+ this.parentElement = value;
1388
+ }
1389
+ }
1390
+
1391
+ /// <summary>
1392
+ /// Processes this element and all child elements into an XmlWriter.
1393
+ /// </summary>
1394
+ [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
1395
+ public virtual void OutputXml(XmlWriter writer)
1396
+ {
1397
+ if ((null == writer))
1398
+ {
1399
+ throw new ArgumentNullException("writer");
1400
+ }
1401
+ writer.WriteStartElement("CloseApplication", "http://wixtoolset.org/schemas/v4/wxs/util");
1402
+ if (this.idFieldSet)
1403
+ {
1404
+ writer.WriteAttributeString("Id", this.idField);
1405
+ }
1406
+ if (this.targetFieldSet)
1407
+ {
1408
+ writer.WriteAttributeString("Target", this.targetField);
1409
+ }
1410
+ if (this.descriptionFieldSet)
1411
+ {
1412
+ writer.WriteAttributeString("Description", this.descriptionField);
1413
+ }
1414
+ if (this.sequenceFieldSet)
1415
+ {
1416
+ writer.WriteAttributeString("Sequence", this.sequenceField.ToString(CultureInfo.InvariantCulture));
1417
+ }
1418
+ if (this.closeMessageFieldSet)
1419
+ {
1420
+ if ((this.closeMessageField == YesNoType.no))
1421
+ {
1422
+ writer.WriteAttributeString("CloseMessage", "no");
1423
+ }
1424
+ if ((this.closeMessageField == YesNoType.yes))
1425
+ {
1426
+ writer.WriteAttributeString("CloseMessage", "yes");
1427
+ }
1428
+ }
1429
+ if (this.endSessionMessageFieldSet)
1430
+ {
1431
+ if ((this.endSessionMessageField == YesNoType.no))
1432
+ {
1433
+ writer.WriteAttributeString("EndSessionMessage", "no");
1434
+ }
1435
+ if ((this.endSessionMessageField == YesNoType.yes))
1436
+ {
1437
+ writer.WriteAttributeString("EndSessionMessage", "yes");
1438
+ }
1439
+ }
1440
+ if (this.elevatedCloseMessageFieldSet)
1441
+ {
1442
+ if ((this.elevatedCloseMessageField == YesNoType.no))
1443
+ {
1444
+ writer.WriteAttributeString("ElevatedCloseMessage", "no");
1445
+ }
1446
+ if ((this.elevatedCloseMessageField == YesNoType.yes))
1447
+ {
1448
+ writer.WriteAttributeString("ElevatedCloseMessage", "yes");
1449
+ }
1450
+ }
1451
+ if (this.elevatedEndSessionMessageFieldSet)
1452
+ {
1453
+ if ((this.elevatedEndSessionMessageField == YesNoType.no))
1454
+ {
1455
+ writer.WriteAttributeString("ElevatedEndSessionMessage", "no");
1456
+ }
1457
+ if ((this.elevatedEndSessionMessageField == YesNoType.yes))
1458
+ {
1459
+ writer.WriteAttributeString("ElevatedEndSessionMessage", "yes");
1460
+ }
1461
+ }
1462
+ if (this.rebootPromptFieldSet)
1463
+ {
1464
+ if ((this.rebootPromptField == YesNoType.no))
1465
+ {
1466
+ writer.WriteAttributeString("RebootPrompt", "no");
1467
+ }
1468
+ if ((this.rebootPromptField == YesNoType.yes))
1469
+ {
1470
+ writer.WriteAttributeString("RebootPrompt", "yes");
1471
+ }
1472
+ }
1473
+ if (this.promptToContinueFieldSet)
1474
+ {
1475
+ if ((this.promptToContinueField == YesNoType.no))
1476
+ {
1477
+ writer.WriteAttributeString("PromptToContinue", "no");
1478
+ }
1479
+ if ((this.promptToContinueField == YesNoType.yes))
1480
+ {
1481
+ writer.WriteAttributeString("PromptToContinue", "yes");
1482
+ }
1483
+ }
1484
+ if (this.propertyFieldSet)
1485
+ {
1486
+ writer.WriteAttributeString("Property", this.propertyField);
1487
+ }
1488
+ if (this.terminateProcessFieldSet)
1489
+ {
1490
+ writer.WriteAttributeString("TerminateProcess", this.terminateProcessField.ToString(CultureInfo.InvariantCulture));
1491
+ }
1492
+ if (this.timeoutFieldSet)
1493
+ {
1494
+ writer.WriteAttributeString("Timeout", this.timeoutField.ToString(CultureInfo.InvariantCulture));
1495
+ }
1496
+ if (this.contentFieldSet)
1497
+ {
1498
+ writer.WriteString(this.contentField);
1499
+ }
1500
+ writer.WriteEndElement();
1501
+ }
1502
+
1503
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
1504
+ [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
1505
+ void ISetAttributes.SetAttribute(string name, string value)
1506
+ {
1507
+ if (String.IsNullOrEmpty(name))
1508
+ {
1509
+ throw new ArgumentNullException("name");
1510
+ }
1511
+ if (("Id" == name))
1512
+ {
1513
+ this.idField = value;
1514
+ this.idFieldSet = true;
1515
+ }
1516
+ if (("Target" == name))
1517
+ {
1518
+ this.targetField = value;
1519
+ this.targetFieldSet = true;
1520
+ }
1521
+ if (("Description" == name))
1522
+ {
1523
+ this.descriptionField = value;
1524
+ this.descriptionFieldSet = true;
1525
+ }
1526
+ if (("Sequence" == name))
1527
+ {
1528
+ this.sequenceField = Convert.ToInt32(value, CultureInfo.InvariantCulture);
1529
+ this.sequenceFieldSet = true;
1530
+ }
1531
+ if (("CloseMessage" == name))
1532
+ {
1533
+ this.closeMessageField = Enums.ParseYesNoType(value);
1534
+ this.closeMessageFieldSet = true;
1535
+ }
1536
+ if (("EndSessionMessage" == name))
1537
+ {
1538
+ this.endSessionMessageField = Enums.ParseYesNoType(value);
1539
+ this.endSessionMessageFieldSet = true;
1540
+ }
1541
+ if (("ElevatedCloseMessage" == name))
1542
+ {
1543
+ this.elevatedCloseMessageField = Enums.ParseYesNoType(value);
1544
+ this.elevatedCloseMessageFieldSet = true;
1545
+ }
1546
+ if (("ElevatedEndSessionMessage" == name))
1547
+ {
1548
+ this.elevatedEndSessionMessageField = Enums.ParseYesNoType(value);
1549
+ this.elevatedEndSessionMessageFieldSet = true;
1550
+ }
1551
+ if (("RebootPrompt" == name))
1552
+ {
1553
+ this.rebootPromptField = Enums.ParseYesNoType(value);
1554
+ this.rebootPromptFieldSet = true;
1555
+ }
1556
+ if (("PromptToContinue" == name))
1557
+ {
1558
+ this.promptToContinueField = Enums.ParseYesNoType(value);
1559
+ this.promptToContinueFieldSet = true;
1560
+ }
1561
+ if (("Property" == name))
1562
+ {
1563
+ this.propertyField = value;
1564
+ this.propertyFieldSet = true;
1565
+ }
1566
+ if (("TerminateProcess" == name))
1567
+ {
1568
+ this.terminateProcessField = Convert.ToInt32(value, CultureInfo.InvariantCulture);
1569
+ this.terminateProcessFieldSet = true;
1570
+ }
1571
+ if (("Timeout" == name))
1572
+ {
1573
+ this.timeoutField = Convert.ToInt32(value, CultureInfo.InvariantCulture);
1574
+ this.timeoutFieldSet = true;
1575
+ }
1576
+ if (("Content" == name))
1577
+ {
1578
+ this.contentField = value;
1579
+ this.contentFieldSet = true;
1580
+ }
1581
+ }
1582
+ }
1583
+
1584
+ /// <summary>
1585
+ /// Describes a component search.
1586
+ /// </summary>
1587
+ [GeneratedCode("XsdGen", "4.0.0.0")]
1588
+ public class ComponentSearch : ISchemaElement, ISetAttributes
1589
+ {
1590
+
1591
+ private string idField;
1592
+
1593
+ private bool idFieldSet;
1594
+
1595
+ private string variableField;
1596
+
1597
+ private bool variableFieldSet;
1598
+
1599
+ private string conditionField;
1600
+
1601
+ private bool conditionFieldSet;
1602
+
1603
+ private string afterField;
1604
+
1605
+ private bool afterFieldSet;
1606
+
1607
+ private string guidField;
1608
+
1609
+ private bool guidFieldSet;
1610
+
1611
+ private string productCodeField;
1612
+
1613
+ private bool productCodeFieldSet;
1614
+
1615
+ private ResultType resultField;
1616
+
1617
+ private bool resultFieldSet;
1618
+
1619
+ private ISchemaElement parentElement;
1620
+
1621
+ /// <summary>
1622
+ /// Id of the search for ordering and dependency.
1623
+ /// </summary>
1624
+ public string Id
1625
+ {
1626
+ get
1627
+ {
1628
+ return this.idField;
1629
+ }
1630
+ set
1631
+ {
1632
+ this.idFieldSet = true;
1633
+ this.idField = value;
1634
+ }
1635
+ }
1636
+
1637
+ /// <summary>
1638
+ /// Name of the variable in which to place the result of the search.
1639
+ /// </summary>
1640
+ public string Variable
1641
+ {
1642
+ get
1643
+ {
1644
+ return this.variableField;
1645
+ }
1646
+ set
1647
+ {
1648
+ this.variableFieldSet = true;
1649
+ this.variableField = value;
1650
+ }
1651
+ }
1652
+
1653
+ /// <summary>
1654
+ /// Condition for evaluating the search. If this evaluates to false, the search is not executed at all.
1655
+ /// </summary>
1656
+ public string Condition
1657
+ {
1658
+ get
1659
+ {
1660
+ return this.conditionField;
1661
+ }
1662
+ set
1663
+ {
1664
+ this.conditionFieldSet = true;
1665
+ this.conditionField = value;
1666
+ }
1667
+ }
1668
+
1669
+ /// <summary>
1670
+ /// Id of the search that this one should come after.
1671
+ /// </summary>
1672
+ public string After
1673
+ {
1674
+ get
1675
+ {
1676
+ return this.afterField;
1677
+ }
1678
+ set
1679
+ {
1680
+ this.afterFieldSet = true;
1681
+ this.afterField = value;
1682
+ }
1683
+ }
1684
+
1685
+ /// <summary>
1686
+ /// Component to search for.
1687
+ /// </summary>
1688
+ public string Guid
1689
+ {
1690
+ get
1691
+ {
1692
+ return this.guidField;
1693
+ }
1694
+ set
1695
+ {
1696
+ this.guidFieldSet = true;
1697
+ this.guidField = value;
1698
+ }
1699
+ }
1700
+
1701
+ /// <summary>
1702
+ /// Optional ProductCode to determine if the component is installed.
1703
+ /// </summary>
1704
+ public string ProductCode
1705
+ {
1706
+ get
1707
+ {
1708
+ return this.productCodeField;
1709
+ }
1710
+ set
1711
+ {
1712
+ this.productCodeFieldSet = true;
1713
+ this.productCodeField = value;
1714
+ }
1715
+ }
1716
+
1717
+ /// <summary>
1718
+ /// Rather than saving the matching key path into the variable, a ComponentSearch can save an attribute of the component instead.
1719
+ /// </summary>
1720
+ public ResultType Result
1721
+ {
1722
+ get
1723
+ {
1724
+ return this.resultField;
1725
+ }
1726
+ set
1727
+ {
1728
+ this.resultFieldSet = true;
1729
+ this.resultField = value;
1730
+ }
1731
+ }
1732
+
1733
+ public virtual ISchemaElement ParentElement
1734
+ {
1735
+ get
1736
+ {
1737
+ return this.parentElement;
1738
+ }
1739
+ set
1740
+ {
1741
+ this.parentElement = value;
1742
+ }
1743
+ }
1744
+
1745
+ /// <summary>
1746
+ /// Parses a ResultType from a string.
1747
+ /// </summary>
1748
+ public static ResultType ParseResultType(string value)
1749
+ {
1750
+ ResultType parsedValue;
1751
+ ComponentSearch.TryParseResultType(value, out parsedValue);
1752
+ return parsedValue;
1753
+ }
1754
+
1755
+ /// <summary>
1756
+ /// Tries to parse a ResultType from a string.
1757
+ /// </summary>
1758
+ public static bool TryParseResultType(string value, out ResultType parsedValue)
1759
+ {
1760
+ parsedValue = ResultType.NotSet;
1761
+ if (string.IsNullOrEmpty(value))
1762
+ {
1763
+ return false;
1764
+ }
1765
+ if (("directory" == value))
1766
+ {
1767
+ parsedValue = ResultType.directory;
1768
+ }
1769
+ else
1770
+ {
1771
+ if (("state" == value))
1772
+ {
1773
+ parsedValue = ResultType.state;
1774
+ }
1775
+ else
1776
+ {
1777
+ if (("keyPath" == value))
1778
+ {
1779
+ parsedValue = ResultType.keyPath;
1780
+ }
1781
+ else
1782
+ {
1783
+ parsedValue = ResultType.IllegalValue;
1784
+ return false;
1785
+ }
1786
+ }
1787
+ }
1788
+ return true;
1789
+ }
1790
+
1791
+ /// <summary>
1792
+ /// Processes this element and all child elements into an XmlWriter.
1793
+ /// </summary>
1794
+ [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
1795
+ public virtual void OutputXml(XmlWriter writer)
1796
+ {
1797
+ if ((null == writer))
1798
+ {
1799
+ throw new ArgumentNullException("writer");
1800
+ }
1801
+ writer.WriteStartElement("ComponentSearch", "http://wixtoolset.org/schemas/v4/wxs/util");
1802
+ if (this.idFieldSet)
1803
+ {
1804
+ writer.WriteAttributeString("Id", this.idField);
1805
+ }
1806
+ if (this.variableFieldSet)
1807
+ {
1808
+ writer.WriteAttributeString("Variable", this.variableField);
1809
+ }
1810
+ if (this.conditionFieldSet)
1811
+ {
1812
+ writer.WriteAttributeString("Condition", this.conditionField);
1813
+ }
1814
+ if (this.afterFieldSet)
1815
+ {
1816
+ writer.WriteAttributeString("After", this.afterField);
1817
+ }
1818
+ if (this.guidFieldSet)
1819
+ {
1820
+ writer.WriteAttributeString("Guid", this.guidField);
1821
+ }
1822
+ if (this.productCodeFieldSet)
1823
+ {
1824
+ writer.WriteAttributeString("ProductCode", this.productCodeField);
1825
+ }
1826
+ if (this.resultFieldSet)
1827
+ {
1828
+ if ((this.resultField == ResultType.directory))
1829
+ {
1830
+ writer.WriteAttributeString("Result", "directory");
1831
+ }
1832
+ if ((this.resultField == ResultType.state))
1833
+ {
1834
+ writer.WriteAttributeString("Result", "state");
1835
+ }
1836
+ if ((this.resultField == ResultType.keyPath))
1837
+ {
1838
+ writer.WriteAttributeString("Result", "keyPath");
1839
+ }
1840
+ }
1841
+ writer.WriteEndElement();
1842
+ }
1843
+
1844
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
1845
+ void ISetAttributes.SetAttribute(string name, string value)
1846
+ {
1847
+ if (String.IsNullOrEmpty(name))
1848
+ {
1849
+ throw new ArgumentNullException("name");
1850
+ }
1851
+ if (("Id" == name))
1852
+ {
1853
+ this.idField = value;
1854
+ this.idFieldSet = true;
1855
+ }
1856
+ if (("Variable" == name))
1857
+ {
1858
+ this.variableField = value;
1859
+ this.variableFieldSet = true;
1860
+ }
1861
+ if (("Condition" == name))
1862
+ {
1863
+ this.conditionField = value;
1864
+ this.conditionFieldSet = true;
1865
+ }
1866
+ if (("After" == name))
1867
+ {
1868
+ this.afterField = value;
1869
+ this.afterFieldSet = true;
1870
+ }
1871
+ if (("Guid" == name))
1872
+ {
1873
+ this.guidField = value;
1874
+ this.guidFieldSet = true;
1875
+ }
1876
+ if (("ProductCode" == name))
1877
+ {
1878
+ this.productCodeField = value;
1879
+ this.productCodeFieldSet = true;
1880
+ }
1881
+ if (("Result" == name))
1882
+ {
1883
+ this.resultField = ComponentSearch.ParseResultType(value);
1884
+ this.resultFieldSet = true;
1885
+ }
1886
+ }
1887
+
1888
+ [GeneratedCode("XsdGen", "4.0.0.0")]
1889
+ public enum ResultType
1890
+ {
1891
+
1892
+ IllegalValue = int.MaxValue,
1893
+
1894
+ NotSet = -1,
1895
+
1896
+ /// <summary>
1897
+ /// Saves the parent directory for the component's file key path; other types of key path are returned unmodified.
1898
+ /// </summary>
1899
+ directory,
1900
+
1901
+ /// <summary>
1902
+ /// Saves the state of the component: absent (2), locally installed (3), will run from source (4), or installed in default location (either local or from source) (5)
1903
+ /// </summary>
1904
+ state,
1905
+
1906
+ /// <summary>
1907
+ /// Saves the key path of the component if installed. This is the default.
1908
+ /// </summary>
1909
+ keyPath,
1910
+ }
1911
+ }
1912
+
1913
+ /// <summary>
1914
+ /// References a ComponentSearch.
1915
+ /// </summary>
1916
+ [GeneratedCode("XsdGen", "4.0.0.0")]
1917
+ public class ComponentSearchRef : ISchemaElement, ISetAttributes
1918
+ {
1919
+
1920
+ private string idField;
1921
+
1922
+ private bool idFieldSet;
1923
+
1924
+ private ISchemaElement parentElement;
1925
+
1926
+ public string Id
1927
+ {
1928
+ get
1929
+ {
1930
+ return this.idField;
1931
+ }
1932
+ set
1933
+ {
1934
+ this.idFieldSet = true;
1935
+ this.idField = value;
1936
+ }
1937
+ }
1938
+
1939
+ public virtual ISchemaElement ParentElement
1940
+ {
1941
+ get
1942
+ {
1943
+ return this.parentElement;
1944
+ }
1945
+ set
1946
+ {
1947
+ this.parentElement = value;
1948
+ }
1949
+ }
1950
+
1951
+ /// <summary>
1952
+ /// Processes this element and all child elements into an XmlWriter.
1953
+ /// </summary>
1954
+ public virtual void OutputXml(XmlWriter writer)
1955
+ {
1956
+ if ((null == writer))
1957
+ {
1958
+ throw new ArgumentNullException("writer");
1959
+ }
1960
+ writer.WriteStartElement("ComponentSearchRef", "http://wixtoolset.org/schemas/v4/wxs/util");
1961
+ if (this.idFieldSet)
1962
+ {
1963
+ writer.WriteAttributeString("Id", this.idField);
1964
+ }
1965
+ writer.WriteEndElement();
1966
+ }
1967
+
1968
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
1969
+ void ISetAttributes.SetAttribute(string name, string value)
1970
+ {
1971
+ if (String.IsNullOrEmpty(name))
1972
+ {
1973
+ throw new ArgumentNullException("name");
1974
+ }
1975
+ if (("Id" == name))
1976
+ {
1977
+ this.idField = value;
1978
+ this.idFieldSet = true;
1979
+ }
1980
+ }
1981
+ }
1982
+
1983
+ /// <summary>
1984
+ /// Describes a directory search.
1985
+ /// </summary>
1986
+ [GeneratedCode("XsdGen", "4.0.0.0")]
1987
+ public class DirectorySearch : ISchemaElement, ISetAttributes
1988
+ {
1989
+
1990
+ private string idField;
1991
+
1992
+ private bool idFieldSet;
1993
+
1994
+ private string variableField;
1995
+
1996
+ private bool variableFieldSet;
1997
+
1998
+ private string conditionField;
1999
+
2000
+ private bool conditionFieldSet;
2001
+
2002
+ private string afterField;
2003
+
2004
+ private bool afterFieldSet;
2005
+
2006
+ private string pathField;
2007
+
2008
+ private bool pathFieldSet;
2009
+
2010
+ private ResultType resultField;
2011
+
2012
+ private bool resultFieldSet;
2013
+
2014
+ private ISchemaElement parentElement;
2015
+
2016
+ /// <summary>
2017
+ /// Id of the search for ordering and dependency.
2018
+ /// </summary>
2019
+ public string Id
2020
+ {
2021
+ get
2022
+ {
2023
+ return this.idField;
2024
+ }
2025
+ set
2026
+ {
2027
+ this.idFieldSet = true;
2028
+ this.idField = value;
2029
+ }
2030
+ }
2031
+
2032
+ /// <summary>
2033
+ /// Name of the variable in which to place the result of the search.
2034
+ /// </summary>
2035
+ public string Variable
2036
+ {
2037
+ get
2038
+ {
2039
+ return this.variableField;
2040
+ }
2041
+ set
2042
+ {
2043
+ this.variableFieldSet = true;
2044
+ this.variableField = value;
2045
+ }
2046
+ }
2047
+
2048
+ /// <summary>
2049
+ /// Condition for evaluating the search. If this evaluates to false, the search is not executed at all.
2050
+ /// </summary>
2051
+ public string Condition
2052
+ {
2053
+ get
2054
+ {
2055
+ return this.conditionField;
2056
+ }
2057
+ set
2058
+ {
2059
+ this.conditionFieldSet = true;
2060
+ this.conditionField = value;
2061
+ }
2062
+ }
2063
+
2064
+ /// <summary>
2065
+ /// Id of the search that this one should come after.
2066
+ /// </summary>
2067
+ public string After
2068
+ {
2069
+ get
2070
+ {
2071
+ return this.afterField;
2072
+ }
2073
+ set
2074
+ {
2075
+ this.afterFieldSet = true;
2076
+ this.afterField = value;
2077
+ }
2078
+ }
2079
+
2080
+ /// <summary>
2081
+ /// Directory path to search for.
2082
+ /// </summary>
2083
+ public string Path
2084
+ {
2085
+ get
2086
+ {
2087
+ return this.pathField;
2088
+ }
2089
+ set
2090
+ {
2091
+ this.pathFieldSet = true;
2092
+ this.pathField = value;
2093
+ }
2094
+ }
2095
+
2096
+ /// <summary>
2097
+ /// Rather than saving the matching directory path into the variable, a DirectorySearch can save an
2098
+ /// attribute of the matching directory instead.
2099
+ /// </summary>
2100
+ public ResultType Result
2101
+ {
2102
+ get
2103
+ {
2104
+ return this.resultField;
2105
+ }
2106
+ set
2107
+ {
2108
+ this.resultFieldSet = true;
2109
+ this.resultField = value;
2110
+ }
2111
+ }
2112
+
2113
+ public virtual ISchemaElement ParentElement
2114
+ {
2115
+ get
2116
+ {
2117
+ return this.parentElement;
2118
+ }
2119
+ set
2120
+ {
2121
+ this.parentElement = value;
2122
+ }
2123
+ }
2124
+
2125
+ /// <summary>
2126
+ /// Parses a ResultType from a string.
2127
+ /// </summary>
2128
+ public static ResultType ParseResultType(string value)
2129
+ {
2130
+ ResultType parsedValue;
2131
+ DirectorySearch.TryParseResultType(value, out parsedValue);
2132
+ return parsedValue;
2133
+ }
2134
+
2135
+ /// <summary>
2136
+ /// Tries to parse a ResultType from a string.
2137
+ /// </summary>
2138
+ public static bool TryParseResultType(string value, out ResultType parsedValue)
2139
+ {
2140
+ parsedValue = ResultType.NotSet;
2141
+ if (string.IsNullOrEmpty(value))
2142
+ {
2143
+ return false;
2144
+ }
2145
+ if (("exists" == value))
2146
+ {
2147
+ parsedValue = ResultType.exists;
2148
+ }
2149
+ else
2150
+ {
2151
+ parsedValue = ResultType.IllegalValue;
2152
+ return false;
2153
+ }
2154
+ return true;
2155
+ }
2156
+
2157
+ /// <summary>
2158
+ /// Processes this element and all child elements into an XmlWriter.
2159
+ /// </summary>
2160
+ public virtual void OutputXml(XmlWriter writer)
2161
+ {
2162
+ if ((null == writer))
2163
+ {
2164
+ throw new ArgumentNullException("writer");
2165
+ }
2166
+ writer.WriteStartElement("DirectorySearch", "http://wixtoolset.org/schemas/v4/wxs/util");
2167
+ if (this.idFieldSet)
2168
+ {
2169
+ writer.WriteAttributeString("Id", this.idField);
2170
+ }
2171
+ if (this.variableFieldSet)
2172
+ {
2173
+ writer.WriteAttributeString("Variable", this.variableField);
2174
+ }
2175
+ if (this.conditionFieldSet)
2176
+ {
2177
+ writer.WriteAttributeString("Condition", this.conditionField);
2178
+ }
2179
+ if (this.afterFieldSet)
2180
+ {
2181
+ writer.WriteAttributeString("After", this.afterField);
2182
+ }
2183
+ if (this.pathFieldSet)
2184
+ {
2185
+ writer.WriteAttributeString("Path", this.pathField);
2186
+ }
2187
+ if (this.resultFieldSet)
2188
+ {
2189
+ if ((this.resultField == ResultType.exists))
2190
+ {
2191
+ writer.WriteAttributeString("Result", "exists");
2192
+ }
2193
+ }
2194
+ writer.WriteEndElement();
2195
+ }
2196
+
2197
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
2198
+ void ISetAttributes.SetAttribute(string name, string value)
2199
+ {
2200
+ if (String.IsNullOrEmpty(name))
2201
+ {
2202
+ throw new ArgumentNullException("name");
2203
+ }
2204
+ if (("Id" == name))
2205
+ {
2206
+ this.idField = value;
2207
+ this.idFieldSet = true;
2208
+ }
2209
+ if (("Variable" == name))
2210
+ {
2211
+ this.variableField = value;
2212
+ this.variableFieldSet = true;
2213
+ }
2214
+ if (("Condition" == name))
2215
+ {
2216
+ this.conditionField = value;
2217
+ this.conditionFieldSet = true;
2218
+ }
2219
+ if (("After" == name))
2220
+ {
2221
+ this.afterField = value;
2222
+ this.afterFieldSet = true;
2223
+ }
2224
+ if (("Path" == name))
2225
+ {
2226
+ this.pathField = value;
2227
+ this.pathFieldSet = true;
2228
+ }
2229
+ if (("Result" == name))
2230
+ {
2231
+ this.resultField = DirectorySearch.ParseResultType(value);
2232
+ this.resultFieldSet = true;
2233
+ }
2234
+ }
2235
+
2236
+ [GeneratedCode("XsdGen", "4.0.0.0")]
2237
+ public enum ResultType
2238
+ {
2239
+
2240
+ IllegalValue = int.MaxValue,
2241
+
2242
+ NotSet = -1,
2243
+
2244
+ /// <summary>
2245
+ /// Saves true if a matching directory is found; false otherwise.
2246
+ /// </summary>
2247
+ exists,
2248
+ }
2249
+ }
2250
+
2251
+ /// <summary>
2252
+ /// References a DirectorySearch.
2253
+ /// </summary>
2254
+ [GeneratedCode("XsdGen", "4.0.0.0")]
2255
+ public class DirectorySearchRef : ISchemaElement, ISetAttributes
2256
+ {
2257
+
2258
+ private string idField;
2259
+
2260
+ private bool idFieldSet;
2261
+
2262
+ private ISchemaElement parentElement;
2263
+
2264
+ public string Id
2265
+ {
2266
+ get
2267
+ {
2268
+ return this.idField;
2269
+ }
2270
+ set
2271
+ {
2272
+ this.idFieldSet = true;
2273
+ this.idField = value;
2274
+ }
2275
+ }
2276
+
2277
+ public virtual ISchemaElement ParentElement
2278
+ {
2279
+ get
2280
+ {
2281
+ return this.parentElement;
2282
+ }
2283
+ set
2284
+ {
2285
+ this.parentElement = value;
2286
+ }
2287
+ }
2288
+
2289
+ /// <summary>
2290
+ /// Processes this element and all child elements into an XmlWriter.
2291
+ /// </summary>
2292
+ public virtual void OutputXml(XmlWriter writer)
2293
+ {
2294
+ if ((null == writer))
2295
+ {
2296
+ throw new ArgumentNullException("writer");
2297
+ }
2298
+ writer.WriteStartElement("DirectorySearchRef", "http://wixtoolset.org/schemas/v4/wxs/util");
2299
+ if (this.idFieldSet)
2300
+ {
2301
+ writer.WriteAttributeString("Id", this.idField);
2302
+ }
2303
+ writer.WriteEndElement();
2304
+ }
2305
+
2306
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
2307
+ void ISetAttributes.SetAttribute(string name, string value)
2308
+ {
2309
+ if (String.IsNullOrEmpty(name))
2310
+ {
2311
+ throw new ArgumentNullException("name");
2312
+ }
2313
+ if (("Id" == name))
2314
+ {
2315
+ this.idField = value;
2316
+ this.idFieldSet = true;
2317
+ }
2318
+ }
2319
+ }
2320
+
2321
+ /// <summary>
2322
+ /// Creates an event source.
2323
+ /// </summary>
2324
+ [GeneratedCode("XsdGen", "4.0.0.0")]
2325
+ public class EventSource : ISchemaElement, ISetAttributes
2326
+ {
2327
+
2328
+ private int categoryCountField;
2329
+
2330
+ private bool categoryCountFieldSet;
2331
+
2332
+ private string categoryMessageFileField;
2333
+
2334
+ private bool categoryMessageFileFieldSet;
2335
+
2336
+ private string eventMessageFileField;
2337
+
2338
+ private bool eventMessageFileFieldSet;
2339
+
2340
+ private YesNoType keyPathField;
2341
+
2342
+ private bool keyPathFieldSet;
2343
+
2344
+ private string logField;
2345
+
2346
+ private bool logFieldSet;
2347
+
2348
+ private string nameField;
2349
+
2350
+ private bool nameFieldSet;
2351
+
2352
+ private string parameterMessageFileField;
2353
+
2354
+ private bool parameterMessageFileFieldSet;
2355
+
2356
+ private YesNoType supportsErrorsField;
2357
+
2358
+ private bool supportsErrorsFieldSet;
2359
+
2360
+ private YesNoType supportsFailureAuditsField;
2361
+
2362
+ private bool supportsFailureAuditsFieldSet;
2363
+
2364
+ private YesNoType supportsInformationalsField;
2365
+
2366
+ private bool supportsInformationalsFieldSet;
2367
+
2368
+ private YesNoType supportsSuccessAuditsField;
2369
+
2370
+ private bool supportsSuccessAuditsFieldSet;
2371
+
2372
+ private YesNoType supportsWarningsField;
2373
+
2374
+ private bool supportsWarningsFieldSet;
2375
+
2376
+ private ISchemaElement parentElement;
2377
+
2378
+ /// <summary>
2379
+ /// The number of categories in CategoryMessageFile. CategoryMessageFile
2380
+ /// must be specified too.
2381
+ /// </summary>
2382
+ public int CategoryCount
2383
+ {
2384
+ get
2385
+ {
2386
+ return this.categoryCountField;
2387
+ }
2388
+ set
2389
+ {
2390
+ this.categoryCountFieldSet = true;
2391
+ this.categoryCountField = value;
2392
+ }
2393
+ }
2394
+
2395
+ /// <summary>
2396
+ /// Name of the category message file. CategoryCount must be specified too.
2397
+ /// Note that this is a formatted field, so you can use [#fileId] syntax to
2398
+ /// refer to a file being installed. It is also written as a REG_EXPAND_SZ
2399
+ /// string, so you can use %environment_variable% syntax to refer to a file
2400
+ /// already present on the user's machine.
2401
+ /// </summary>
2402
+ public string CategoryMessageFile
2403
+ {
2404
+ get
2405
+ {
2406
+ return this.categoryMessageFileField;
2407
+ }
2408
+ set
2409
+ {
2410
+ this.categoryMessageFileFieldSet = true;
2411
+ this.categoryMessageFileField = value;
2412
+ }
2413
+ }
2414
+
2415
+ /// <summary>
2416
+ /// Name of the event message file.
2417
+ /// Note that this is a formatted field, so you can use [#fileId] syntax to
2418
+ /// refer to a file being installed. It is also written as a REG_EXPAND_SZ
2419
+ /// string, so you can use %environment_variable% syntax to refer to a file
2420
+ /// already present on the user's machine.
2421
+ /// </summary>
2422
+ public string EventMessageFile
2423
+ {
2424
+ get
2425
+ {
2426
+ return this.eventMessageFileField;
2427
+ }
2428
+ set
2429
+ {
2430
+ this.eventMessageFileFieldSet = true;
2431
+ this.eventMessageFileField = value;
2432
+ }
2433
+ }
2434
+
2435
+ /// <summary>
2436
+ /// Marks the EventSource registry as the key path of the component it belongs to.
2437
+ /// </summary>
2438
+ public YesNoType KeyPath
2439
+ {
2440
+ get
2441
+ {
2442
+ return this.keyPathField;
2443
+ }
2444
+ set
2445
+ {
2446
+ this.keyPathFieldSet = true;
2447
+ this.keyPathField = value;
2448
+ }
2449
+ }
2450
+
2451
+ /// <summary>
2452
+ /// Name of the event source's log.
2453
+ /// </summary>
2454
+ public string Log
2455
+ {
2456
+ get
2457
+ {
2458
+ return this.logField;
2459
+ }
2460
+ set
2461
+ {
2462
+ this.logFieldSet = true;
2463
+ this.logField = value;
2464
+ }
2465
+ }
2466
+
2467
+ /// <summary>
2468
+ /// Name of the event source.
2469
+ /// </summary>
2470
+ public string Name
2471
+ {
2472
+ get
2473
+ {
2474
+ return this.nameField;
2475
+ }
2476
+ set
2477
+ {
2478
+ this.nameFieldSet = true;
2479
+ this.nameField = value;
2480
+ }
2481
+ }
2482
+
2483
+ /// <summary>
2484
+ /// Name of the parameter message file.
2485
+ /// Note that this is a formatted field, so you can use [#fileId] syntax to
2486
+ /// refer to a file being installed. It is also written as a REG_EXPAND_SZ
2487
+ /// string, so you can use %environment_variable% syntax to refer to a file
2488
+ /// already present on the user's machine.
2489
+ /// </summary>
2490
+ public string ParameterMessageFile
2491
+ {
2492
+ get
2493
+ {
2494
+ return this.parameterMessageFileField;
2495
+ }
2496
+ set
2497
+ {
2498
+ this.parameterMessageFileFieldSet = true;
2499
+ this.parameterMessageFileField = value;
2500
+ }
2501
+ }
2502
+
2503
+ /// <summary>
2504
+ /// Equivalent to EVENTLOG_ERROR_TYPE.
2505
+ /// </summary>
2506
+ public YesNoType SupportsErrors
2507
+ {
2508
+ get
2509
+ {
2510
+ return this.supportsErrorsField;
2511
+ }
2512
+ set
2513
+ {
2514
+ this.supportsErrorsFieldSet = true;
2515
+ this.supportsErrorsField = value;
2516
+ }
2517
+ }
2518
+
2519
+ /// <summary>
2520
+ /// Equivalent to EVENTLOG_AUDIT_FAILURE.
2521
+ /// </summary>
2522
+ public YesNoType SupportsFailureAudits
2523
+ {
2524
+ get
2525
+ {
2526
+ return this.supportsFailureAuditsField;
2527
+ }
2528
+ set
2529
+ {
2530
+ this.supportsFailureAuditsFieldSet = true;
2531
+ this.supportsFailureAuditsField = value;
2532
+ }
2533
+ }
2534
+
2535
+ /// <summary>
2536
+ /// Equivalent to EVENTLOG_INFORMATION_TYPE.
2537
+ /// </summary>
2538
+ public YesNoType SupportsInformationals
2539
+ {
2540
+ get
2541
+ {
2542
+ return this.supportsInformationalsField;
2543
+ }
2544
+ set
2545
+ {
2546
+ this.supportsInformationalsFieldSet = true;
2547
+ this.supportsInformationalsField = value;
2548
+ }
2549
+ }
2550
+
2551
+ /// <summary>
2552
+ /// Equivalent to EVENTLOG_AUDIT_SUCCESS.
2553
+ /// </summary>
2554
+ public YesNoType SupportsSuccessAudits
2555
+ {
2556
+ get
2557
+ {
2558
+ return this.supportsSuccessAuditsField;
2559
+ }
2560
+ set
2561
+ {
2562
+ this.supportsSuccessAuditsFieldSet = true;
2563
+ this.supportsSuccessAuditsField = value;
2564
+ }
2565
+ }
2566
+
2567
+ /// <summary>
2568
+ /// Equivalent to EVENTLOG_WARNING_TYPE.
2569
+ /// </summary>
2570
+ public YesNoType SupportsWarnings
2571
+ {
2572
+ get
2573
+ {
2574
+ return this.supportsWarningsField;
2575
+ }
2576
+ set
2577
+ {
2578
+ this.supportsWarningsFieldSet = true;
2579
+ this.supportsWarningsField = value;
2580
+ }
2581
+ }
2582
+
2583
+ public virtual ISchemaElement ParentElement
2584
+ {
2585
+ get
2586
+ {
2587
+ return this.parentElement;
2588
+ }
2589
+ set
2590
+ {
2591
+ this.parentElement = value;
2592
+ }
2593
+ }
2594
+
2595
+ /// <summary>
2596
+ /// Processes this element and all child elements into an XmlWriter.
2597
+ /// </summary>
2598
+ [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
2599
+ public virtual void OutputXml(XmlWriter writer)
2600
+ {
2601
+ if ((null == writer))
2602
+ {
2603
+ throw new ArgumentNullException("writer");
2604
+ }
2605
+ writer.WriteStartElement("EventSource", "http://wixtoolset.org/schemas/v4/wxs/util");
2606
+ if (this.categoryCountFieldSet)
2607
+ {
2608
+ writer.WriteAttributeString("CategoryCount", this.categoryCountField.ToString(CultureInfo.InvariantCulture));
2609
+ }
2610
+ if (this.categoryMessageFileFieldSet)
2611
+ {
2612
+ writer.WriteAttributeString("CategoryMessageFile", this.categoryMessageFileField);
2613
+ }
2614
+ if (this.eventMessageFileFieldSet)
2615
+ {
2616
+ writer.WriteAttributeString("EventMessageFile", this.eventMessageFileField);
2617
+ }
2618
+ if (this.keyPathFieldSet)
2619
+ {
2620
+ if ((this.keyPathField == YesNoType.no))
2621
+ {
2622
+ writer.WriteAttributeString("KeyPath", "no");
2623
+ }
2624
+ if ((this.keyPathField == YesNoType.yes))
2625
+ {
2626
+ writer.WriteAttributeString("KeyPath", "yes");
2627
+ }
2628
+ }
2629
+ if (this.logFieldSet)
2630
+ {
2631
+ writer.WriteAttributeString("Log", this.logField);
2632
+ }
2633
+ if (this.nameFieldSet)
2634
+ {
2635
+ writer.WriteAttributeString("Name", this.nameField);
2636
+ }
2637
+ if (this.parameterMessageFileFieldSet)
2638
+ {
2639
+ writer.WriteAttributeString("ParameterMessageFile", this.parameterMessageFileField);
2640
+ }
2641
+ if (this.supportsErrorsFieldSet)
2642
+ {
2643
+ if ((this.supportsErrorsField == YesNoType.no))
2644
+ {
2645
+ writer.WriteAttributeString("SupportsErrors", "no");
2646
+ }
2647
+ if ((this.supportsErrorsField == YesNoType.yes))
2648
+ {
2649
+ writer.WriteAttributeString("SupportsErrors", "yes");
2650
+ }
2651
+ }
2652
+ if (this.supportsFailureAuditsFieldSet)
2653
+ {
2654
+ if ((this.supportsFailureAuditsField == YesNoType.no))
2655
+ {
2656
+ writer.WriteAttributeString("SupportsFailureAudits", "no");
2657
+ }
2658
+ if ((this.supportsFailureAuditsField == YesNoType.yes))
2659
+ {
2660
+ writer.WriteAttributeString("SupportsFailureAudits", "yes");
2661
+ }
2662
+ }
2663
+ if (this.supportsInformationalsFieldSet)
2664
+ {
2665
+ if ((this.supportsInformationalsField == YesNoType.no))
2666
+ {
2667
+ writer.WriteAttributeString("SupportsInformationals", "no");
2668
+ }
2669
+ if ((this.supportsInformationalsField == YesNoType.yes))
2670
+ {
2671
+ writer.WriteAttributeString("SupportsInformationals", "yes");
2672
+ }
2673
+ }
2674
+ if (this.supportsSuccessAuditsFieldSet)
2675
+ {
2676
+ if ((this.supportsSuccessAuditsField == YesNoType.no))
2677
+ {
2678
+ writer.WriteAttributeString("SupportsSuccessAudits", "no");
2679
+ }
2680
+ if ((this.supportsSuccessAuditsField == YesNoType.yes))
2681
+ {
2682
+ writer.WriteAttributeString("SupportsSuccessAudits", "yes");
2683
+ }
2684
+ }
2685
+ if (this.supportsWarningsFieldSet)
2686
+ {
2687
+ if ((this.supportsWarningsField == YesNoType.no))
2688
+ {
2689
+ writer.WriteAttributeString("SupportsWarnings", "no");
2690
+ }
2691
+ if ((this.supportsWarningsField == YesNoType.yes))
2692
+ {
2693
+ writer.WriteAttributeString("SupportsWarnings", "yes");
2694
+ }
2695
+ }
2696
+ writer.WriteEndElement();
2697
+ }
2698
+
2699
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
2700
+ [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
2701
+ void ISetAttributes.SetAttribute(string name, string value)
2702
+ {
2703
+ if (String.IsNullOrEmpty(name))
2704
+ {
2705
+ throw new ArgumentNullException("name");
2706
+ }
2707
+ if (("CategoryCount" == name))
2708
+ {
2709
+ this.categoryCountField = Convert.ToInt32(value, CultureInfo.InvariantCulture);
2710
+ this.categoryCountFieldSet = true;
2711
+ }
2712
+ if (("CategoryMessageFile" == name))
2713
+ {
2714
+ this.categoryMessageFileField = value;
2715
+ this.categoryMessageFileFieldSet = true;
2716
+ }
2717
+ if (("EventMessageFile" == name))
2718
+ {
2719
+ this.eventMessageFileField = value;
2720
+ this.eventMessageFileFieldSet = true;
2721
+ }
2722
+ if (("KeyPath" == name))
2723
+ {
2724
+ this.keyPathField = Enums.ParseYesNoType(value);
2725
+ this.keyPathFieldSet = true;
2726
+ }
2727
+ if (("Log" == name))
2728
+ {
2729
+ this.logField = value;
2730
+ this.logFieldSet = true;
2731
+ }
2732
+ if (("Name" == name))
2733
+ {
2734
+ this.nameField = value;
2735
+ this.nameFieldSet = true;
2736
+ }
2737
+ if (("ParameterMessageFile" == name))
2738
+ {
2739
+ this.parameterMessageFileField = value;
2740
+ this.parameterMessageFileFieldSet = true;
2741
+ }
2742
+ if (("SupportsErrors" == name))
2743
+ {
2744
+ this.supportsErrorsField = Enums.ParseYesNoType(value);
2745
+ this.supportsErrorsFieldSet = true;
2746
+ }
2747
+ if (("SupportsFailureAudits" == name))
2748
+ {
2749
+ this.supportsFailureAuditsField = Enums.ParseYesNoType(value);
2750
+ this.supportsFailureAuditsFieldSet = true;
2751
+ }
2752
+ if (("SupportsInformationals" == name))
2753
+ {
2754
+ this.supportsInformationalsField = Enums.ParseYesNoType(value);
2755
+ this.supportsInformationalsFieldSet = true;
2756
+ }
2757
+ if (("SupportsSuccessAudits" == name))
2758
+ {
2759
+ this.supportsSuccessAuditsField = Enums.ParseYesNoType(value);
2760
+ this.supportsSuccessAuditsFieldSet = true;
2761
+ }
2762
+ if (("SupportsWarnings" == name))
2763
+ {
2764
+ this.supportsWarningsField = Enums.ParseYesNoType(value);
2765
+ this.supportsWarningsFieldSet = true;
2766
+ }
2767
+ }
2768
+ }
2769
+
2770
+ /// <summary>
2771
+ /// Describes a file search.
2772
+ /// </summary>
2773
+ [GeneratedCode("XsdGen", "4.0.0.0")]
2774
+ public class FileSearch : ISchemaElement, ISetAttributes
2775
+ {
2776
+
2777
+ private string idField;
2778
+
2779
+ private bool idFieldSet;
2780
+
2781
+ private string variableField;
2782
+
2783
+ private bool variableFieldSet;
2784
+
2785
+ private string conditionField;
2786
+
2787
+ private bool conditionFieldSet;
2788
+
2789
+ private string afterField;
2790
+
2791
+ private bool afterFieldSet;
2792
+
2793
+ private string pathField;
2794
+
2795
+ private bool pathFieldSet;
2796
+
2797
+ private ResultType resultField;
2798
+
2799
+ private bool resultFieldSet;
2800
+
2801
+ private ISchemaElement parentElement;
2802
+
2803
+ /// <summary>
2804
+ /// Id of the search for ordering and dependency.
2805
+ /// </summary>
2806
+ public string Id
2807
+ {
2808
+ get
2809
+ {
2810
+ return this.idField;
2811
+ }
2812
+ set
2813
+ {
2814
+ this.idFieldSet = true;
2815
+ this.idField = value;
2816
+ }
2817
+ }
2818
+
2819
+ /// <summary>
2820
+ /// Name of the variable in which to place the result of the search.
2821
+ /// </summary>
2822
+ public string Variable
2823
+ {
2824
+ get
2825
+ {
2826
+ return this.variableField;
2827
+ }
2828
+ set
2829
+ {
2830
+ this.variableFieldSet = true;
2831
+ this.variableField = value;
2832
+ }
2833
+ }
2834
+
2835
+ /// <summary>
2836
+ /// Condition for evaluating the search. If this evaluates to false, the search is not executed at all.
2837
+ /// </summary>
2838
+ public string Condition
2839
+ {
2840
+ get
2841
+ {
2842
+ return this.conditionField;
2843
+ }
2844
+ set
2845
+ {
2846
+ this.conditionFieldSet = true;
2847
+ this.conditionField = value;
2848
+ }
2849
+ }
2850
+
2851
+ /// <summary>
2852
+ /// Id of the search that this one should come after.
2853
+ /// </summary>
2854
+ public string After
2855
+ {
2856
+ get
2857
+ {
2858
+ return this.afterField;
2859
+ }
2860
+ set
2861
+ {
2862
+ this.afterFieldSet = true;
2863
+ this.afterField = value;
2864
+ }
2865
+ }
2866
+
2867
+ /// <summary>
2868
+ /// File path to search for.
2869
+ /// </summary>
2870
+ public string Path
2871
+ {
2872
+ get
2873
+ {
2874
+ return this.pathField;
2875
+ }
2876
+ set
2877
+ {
2878
+ this.pathFieldSet = true;
2879
+ this.pathField = value;
2880
+ }
2881
+ }
2882
+
2883
+ /// <summary>
2884
+ /// Rather than saving the matching file path into the variable, a FileSearch can save an attribute of the matching file instead.
2885
+ /// </summary>
2886
+ public ResultType Result
2887
+ {
2888
+ get
2889
+ {
2890
+ return this.resultField;
2891
+ }
2892
+ set
2893
+ {
2894
+ this.resultFieldSet = true;
2895
+ this.resultField = value;
2896
+ }
2897
+ }
2898
+
2899
+ public virtual ISchemaElement ParentElement
2900
+ {
2901
+ get
2902
+ {
2903
+ return this.parentElement;
2904
+ }
2905
+ set
2906
+ {
2907
+ this.parentElement = value;
2908
+ }
2909
+ }
2910
+
2911
+ /// <summary>
2912
+ /// Parses a ResultType from a string.
2913
+ /// </summary>
2914
+ public static ResultType ParseResultType(string value)
2915
+ {
2916
+ ResultType parsedValue;
2917
+ FileSearch.TryParseResultType(value, out parsedValue);
2918
+ return parsedValue;
2919
+ }
2920
+
2921
+ /// <summary>
2922
+ /// Tries to parse a ResultType from a string.
2923
+ /// </summary>
2924
+ public static bool TryParseResultType(string value, out ResultType parsedValue)
2925
+ {
2926
+ parsedValue = ResultType.NotSet;
2927
+ if (string.IsNullOrEmpty(value))
2928
+ {
2929
+ return false;
2930
+ }
2931
+ if (("exists" == value))
2932
+ {
2933
+ parsedValue = ResultType.exists;
2934
+ }
2935
+ else
2936
+ {
2937
+ if (("version" == value))
2938
+ {
2939
+ parsedValue = ResultType.version;
2940
+ }
2941
+ else
2942
+ {
2943
+ parsedValue = ResultType.IllegalValue;
2944
+ return false;
2945
+ }
2946
+ }
2947
+ return true;
2948
+ }
2949
+
2950
+ /// <summary>
2951
+ /// Processes this element and all child elements into an XmlWriter.
2952
+ /// </summary>
2953
+ public virtual void OutputXml(XmlWriter writer)
2954
+ {
2955
+ if ((null == writer))
2956
+ {
2957
+ throw new ArgumentNullException("writer");
2958
+ }
2959
+ writer.WriteStartElement("FileSearch", "http://wixtoolset.org/schemas/v4/wxs/util");
2960
+ if (this.idFieldSet)
2961
+ {
2962
+ writer.WriteAttributeString("Id", this.idField);
2963
+ }
2964
+ if (this.variableFieldSet)
2965
+ {
2966
+ writer.WriteAttributeString("Variable", this.variableField);
2967
+ }
2968
+ if (this.conditionFieldSet)
2969
+ {
2970
+ writer.WriteAttributeString("Condition", this.conditionField);
2971
+ }
2972
+ if (this.afterFieldSet)
2973
+ {
2974
+ writer.WriteAttributeString("After", this.afterField);
2975
+ }
2976
+ if (this.pathFieldSet)
2977
+ {
2978
+ writer.WriteAttributeString("Path", this.pathField);
2979
+ }
2980
+ if (this.resultFieldSet)
2981
+ {
2982
+ if ((this.resultField == ResultType.exists))
2983
+ {
2984
+ writer.WriteAttributeString("Result", "exists");
2985
+ }
2986
+ if ((this.resultField == ResultType.version))
2987
+ {
2988
+ writer.WriteAttributeString("Result", "version");
2989
+ }
2990
+ }
2991
+ writer.WriteEndElement();
2992
+ }
2993
+
2994
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
2995
+ void ISetAttributes.SetAttribute(string name, string value)
2996
+ {
2997
+ if (String.IsNullOrEmpty(name))
2998
+ {
2999
+ throw new ArgumentNullException("name");
3000
+ }
3001
+ if (("Id" == name))
3002
+ {
3003
+ this.idField = value;
3004
+ this.idFieldSet = true;
3005
+ }
3006
+ if (("Variable" == name))
3007
+ {
3008
+ this.variableField = value;
3009
+ this.variableFieldSet = true;
3010
+ }
3011
+ if (("Condition" == name))
3012
+ {
3013
+ this.conditionField = value;
3014
+ this.conditionFieldSet = true;
3015
+ }
3016
+ if (("After" == name))
3017
+ {
3018
+ this.afterField = value;
3019
+ this.afterFieldSet = true;
3020
+ }
3021
+ if (("Path" == name))
3022
+ {
3023
+ this.pathField = value;
3024
+ this.pathFieldSet = true;
3025
+ }
3026
+ if (("Result" == name))
3027
+ {
3028
+ this.resultField = FileSearch.ParseResultType(value);
3029
+ this.resultFieldSet = true;
3030
+ }
3031
+ }
3032
+
3033
+ [GeneratedCode("XsdGen", "4.0.0.0")]
3034
+ public enum ResultType
3035
+ {
3036
+
3037
+ IllegalValue = int.MaxValue,
3038
+
3039
+ NotSet = -1,
3040
+
3041
+ /// <summary>
3042
+ /// Saves true if a matching file is found; false otherwise.
3043
+ /// </summary>
3044
+ exists,
3045
+
3046
+ /// <summary>
3047
+ /// Saves the version information for files that have it (.exe, .dll); zero-version (0.0.0.0) otherwise.
3048
+ /// </summary>
3049
+ version,
3050
+ }
3051
+ }
3052
+
3053
+ /// <summary>
3054
+ /// References a FileSearch.
3055
+ /// </summary>
3056
+ [GeneratedCode("XsdGen", "4.0.0.0")]
3057
+ public class FileSearchRef : ISchemaElement, ISetAttributes
3058
+ {
3059
+
3060
+ private string idField;
3061
+
3062
+ private bool idFieldSet;
3063
+
3064
+ private ISchemaElement parentElement;
3065
+
3066
+ public string Id
3067
+ {
3068
+ get
3069
+ {
3070
+ return this.idField;
3071
+ }
3072
+ set
3073
+ {
3074
+ this.idFieldSet = true;
3075
+ this.idField = value;
3076
+ }
3077
+ }
3078
+
3079
+ public virtual ISchemaElement ParentElement
3080
+ {
3081
+ get
3082
+ {
3083
+ return this.parentElement;
3084
+ }
3085
+ set
3086
+ {
3087
+ this.parentElement = value;
3088
+ }
3089
+ }
3090
+
3091
+ /// <summary>
3092
+ /// Processes this element and all child elements into an XmlWriter.
3093
+ /// </summary>
3094
+ public virtual void OutputXml(XmlWriter writer)
3095
+ {
3096
+ if ((null == writer))
3097
+ {
3098
+ throw new ArgumentNullException("writer");
3099
+ }
3100
+ writer.WriteStartElement("FileSearchRef", "http://wixtoolset.org/schemas/v4/wxs/util");
3101
+ if (this.idFieldSet)
3102
+ {
3103
+ writer.WriteAttributeString("Id", this.idField);
3104
+ }
3105
+ writer.WriteEndElement();
3106
+ }
3107
+
3108
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
3109
+ void ISetAttributes.SetAttribute(string name, string value)
3110
+ {
3111
+ if (String.IsNullOrEmpty(name))
3112
+ {
3113
+ throw new ArgumentNullException("name");
3114
+ }
3115
+ if (("Id" == name))
3116
+ {
3117
+ this.idField = value;
3118
+ this.idFieldSet = true;
3119
+ }
3120
+ }
3121
+ }
3122
+
3123
+ /// <summary>
3124
+ /// Creates a file share out of the component's directory.
3125
+ /// </summary>
3126
+ [GeneratedCode("XsdGen", "4.0.0.0")]
3127
+ public class FileShare : IParentElement, ICreateChildren, ISchemaElement, ISetAttributes
3128
+ {
3129
+
3130
+ private ElementCollection children;
3131
+
3132
+ private string idField;
3133
+
3134
+ private bool idFieldSet;
3135
+
3136
+ private string nameField;
3137
+
3138
+ private bool nameFieldSet;
3139
+
3140
+ private string descriptionField;
3141
+
3142
+ private bool descriptionFieldSet;
3143
+
3144
+ private ISchemaElement parentElement;
3145
+
3146
+ public FileShare()
3147
+ {
3148
+ ElementCollection childCollection0 = new ElementCollection(ElementCollection.CollectionType.Sequence);
3149
+ childCollection0.AddItem(new ElementCollection.SequenceItem(typeof(FileSharePermission)));
3150
+ this.children = childCollection0;
3151
+ }
3152
+
3153
+ public virtual IEnumerable Children
3154
+ {
3155
+ get
3156
+ {
3157
+ return this.children;
3158
+ }
3159
+ }
3160
+
3161
+ [SuppressMessage("Microsoft.Design", "CA1043:UseIntegralOrStringArgumentForIndexers")]
3162
+ public virtual IEnumerable this[System.Type childType]
3163
+ {
3164
+ get
3165
+ {
3166
+ return this.children.Filter(childType);
3167
+ }
3168
+ }
3169
+
3170
+ /// <summary>
3171
+ /// Identifier for the file share (primary key).
3172
+ /// </summary>
3173
+ public string Id
3174
+ {
3175
+ get
3176
+ {
3177
+ return this.idField;
3178
+ }
3179
+ set
3180
+ {
3181
+ this.idFieldSet = true;
3182
+ this.idField = value;
3183
+ }
3184
+ }
3185
+
3186
+ /// <summary>
3187
+ /// Name of the file share.
3188
+ /// </summary>
3189
+ public string Name
3190
+ {
3191
+ get
3192
+ {
3193
+ return this.nameField;
3194
+ }
3195
+ set
3196
+ {
3197
+ this.nameFieldSet = true;
3198
+ this.nameField = value;
3199
+ }
3200
+ }
3201
+
3202
+ /// <summary>
3203
+ /// Description of the file share.
3204
+ /// </summary>
3205
+ public string Description
3206
+ {
3207
+ get
3208
+ {
3209
+ return this.descriptionField;
3210
+ }
3211
+ set
3212
+ {
3213
+ this.descriptionFieldSet = true;
3214
+ this.descriptionField = value;
3215
+ }
3216
+ }
3217
+
3218
+ public virtual ISchemaElement ParentElement
3219
+ {
3220
+ get
3221
+ {
3222
+ return this.parentElement;
3223
+ }
3224
+ set
3225
+ {
3226
+ this.parentElement = value;
3227
+ }
3228
+ }
3229
+
3230
+ public virtual void AddChild(ISchemaElement child)
3231
+ {
3232
+ if ((null == child))
3233
+ {
3234
+ throw new ArgumentNullException("child");
3235
+ }
3236
+ this.children.AddElement(child);
3237
+ child.ParentElement = this;
3238
+ }
3239
+
3240
+ public virtual void RemoveChild(ISchemaElement child)
3241
+ {
3242
+ if ((null == child))
3243
+ {
3244
+ throw new ArgumentNullException("child");
3245
+ }
3246
+ this.children.RemoveElement(child);
3247
+ child.ParentElement = null;
3248
+ }
3249
+
3250
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
3251
+ ISchemaElement ICreateChildren.CreateChild(string childName)
3252
+ {
3253
+ if (String.IsNullOrEmpty(childName))
3254
+ {
3255
+ throw new ArgumentNullException("childName");
3256
+ }
3257
+ ISchemaElement childValue = null;
3258
+ if (("FileSharePermission" == childName))
3259
+ {
3260
+ childValue = new FileSharePermission();
3261
+ }
3262
+ if ((null == childValue))
3263
+ {
3264
+ throw new InvalidOperationException(String.Concat(childName, " is not a valid child name."));
3265
+ }
3266
+ return childValue;
3267
+ }
3268
+
3269
+ /// <summary>
3270
+ /// Processes this element and all child elements into an XmlWriter.
3271
+ /// </summary>
3272
+ public virtual void OutputXml(XmlWriter writer)
3273
+ {
3274
+ if ((null == writer))
3275
+ {
3276
+ throw new ArgumentNullException("writer");
3277
+ }
3278
+ writer.WriteStartElement("FileShare", "http://wixtoolset.org/schemas/v4/wxs/util");
3279
+ if (this.idFieldSet)
3280
+ {
3281
+ writer.WriteAttributeString("Id", this.idField);
3282
+ }
3283
+ if (this.nameFieldSet)
3284
+ {
3285
+ writer.WriteAttributeString("Name", this.nameField);
3286
+ }
3287
+ if (this.descriptionFieldSet)
3288
+ {
3289
+ writer.WriteAttributeString("Description", this.descriptionField);
3290
+ }
3291
+ for (IEnumerator enumerator = this.children.GetEnumerator(); enumerator.MoveNext(); )
3292
+ {
3293
+ ISchemaElement childElement = ((ISchemaElement)(enumerator.Current));
3294
+ childElement.OutputXml(writer);
3295
+ }
3296
+ writer.WriteEndElement();
3297
+ }
3298
+
3299
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
3300
+ void ISetAttributes.SetAttribute(string name, string value)
3301
+ {
3302
+ if (String.IsNullOrEmpty(name))
3303
+ {
3304
+ throw new ArgumentNullException("name");
3305
+ }
3306
+ if (("Id" == name))
3307
+ {
3308
+ this.idField = value;
3309
+ this.idFieldSet = true;
3310
+ }
3311
+ if (("Name" == name))
3312
+ {
3313
+ this.nameField = value;
3314
+ this.nameFieldSet = true;
3315
+ }
3316
+ if (("Description" == name))
3317
+ {
3318
+ this.descriptionField = value;
3319
+ this.descriptionFieldSet = true;
3320
+ }
3321
+ }
3322
+ }
3323
+
3324
+ /// <summary>
3325
+ /// Sets ACLs on a FileShare. This element has no Id attribute.
3326
+ /// The table and key are taken from the parent element.
3327
+ /// </summary>
3328
+ [GeneratedCode("XsdGen", "4.0.0.0")]
3329
+ public class FileSharePermission : ISchemaElement, ISetAttributes
3330
+ {
3331
+
3332
+ private string userField;
3333
+
3334
+ private bool userFieldSet;
3335
+
3336
+ private YesNoType readField;
3337
+
3338
+ private bool readFieldSet;
3339
+
3340
+ private YesNoType deleteField;
3341
+
3342
+ private bool deleteFieldSet;
3343
+
3344
+ private YesNoType readPermissionField;
3345
+
3346
+ private bool readPermissionFieldSet;
3347
+
3348
+ private YesNoType changePermissionField;
3349
+
3350
+ private bool changePermissionFieldSet;
3351
+
3352
+ private YesNoType takeOwnershipField;
3353
+
3354
+ private bool takeOwnershipFieldSet;
3355
+
3356
+ private YesNoType readAttributesField;
3357
+
3358
+ private bool readAttributesFieldSet;
3359
+
3360
+ private YesNoType writeAttributesField;
3361
+
3362
+ private bool writeAttributesFieldSet;
3363
+
3364
+ private YesNoType readExtendedAttributesField;
3365
+
3366
+ private bool readExtendedAttributesFieldSet;
3367
+
3368
+ private YesNoType writeExtendedAttributesField;
3369
+
3370
+ private bool writeExtendedAttributesFieldSet;
3371
+
3372
+ private YesNoType synchronizeField;
3373
+
3374
+ private bool synchronizeFieldSet;
3375
+
3376
+ private YesNoType createFileField;
3377
+
3378
+ private bool createFileFieldSet;
3379
+
3380
+ private YesNoType createChildField;
3381
+
3382
+ private bool createChildFieldSet;
3383
+
3384
+ private YesNoType deleteChildField;
3385
+
3386
+ private bool deleteChildFieldSet;
3387
+
3388
+ private YesNoType traverseField;
3389
+
3390
+ private bool traverseFieldSet;
3391
+
3392
+ private YesNoType genericAllField;
3393
+
3394
+ private bool genericAllFieldSet;
3395
+
3396
+ private YesNoType genericExecuteField;
3397
+
3398
+ private bool genericExecuteFieldSet;
3399
+
3400
+ private YesNoType genericWriteField;
3401
+
3402
+ private bool genericWriteFieldSet;
3403
+
3404
+ private YesNoType genericReadField;
3405
+
3406
+ private bool genericReadFieldSet;
3407
+
3408
+ private ISchemaElement parentElement;
3409
+
3410
+ public string User
3411
+ {
3412
+ get
3413
+ {
3414
+ return this.userField;
3415
+ }
3416
+ set
3417
+ {
3418
+ this.userFieldSet = true;
3419
+ this.userField = value;
3420
+ }
3421
+ }
3422
+
3423
+ public YesNoType Read
3424
+ {
3425
+ get
3426
+ {
3427
+ return this.readField;
3428
+ }
3429
+ set
3430
+ {
3431
+ this.readFieldSet = true;
3432
+ this.readField = value;
3433
+ }
3434
+ }
3435
+
3436
+ public YesNoType Delete
3437
+ {
3438
+ get
3439
+ {
3440
+ return this.deleteField;
3441
+ }
3442
+ set
3443
+ {
3444
+ this.deleteFieldSet = true;
3445
+ this.deleteField = value;
3446
+ }
3447
+ }
3448
+
3449
+ public YesNoType ReadPermission
3450
+ {
3451
+ get
3452
+ {
3453
+ return this.readPermissionField;
3454
+ }
3455
+ set
3456
+ {
3457
+ this.readPermissionFieldSet = true;
3458
+ this.readPermissionField = value;
3459
+ }
3460
+ }
3461
+
3462
+ public YesNoType ChangePermission
3463
+ {
3464
+ get
3465
+ {
3466
+ return this.changePermissionField;
3467
+ }
3468
+ set
3469
+ {
3470
+ this.changePermissionFieldSet = true;
3471
+ this.changePermissionField = value;
3472
+ }
3473
+ }
3474
+
3475
+ public YesNoType TakeOwnership
3476
+ {
3477
+ get
3478
+ {
3479
+ return this.takeOwnershipField;
3480
+ }
3481
+ set
3482
+ {
3483
+ this.takeOwnershipFieldSet = true;
3484
+ this.takeOwnershipField = value;
3485
+ }
3486
+ }
3487
+
3488
+ public YesNoType ReadAttributes
3489
+ {
3490
+ get
3491
+ {
3492
+ return this.readAttributesField;
3493
+ }
3494
+ set
3495
+ {
3496
+ this.readAttributesFieldSet = true;
3497
+ this.readAttributesField = value;
3498
+ }
3499
+ }
3500
+
3501
+ public YesNoType WriteAttributes
3502
+ {
3503
+ get
3504
+ {
3505
+ return this.writeAttributesField;
3506
+ }
3507
+ set
3508
+ {
3509
+ this.writeAttributesFieldSet = true;
3510
+ this.writeAttributesField = value;
3511
+ }
3512
+ }
3513
+
3514
+ public YesNoType ReadExtendedAttributes
3515
+ {
3516
+ get
3517
+ {
3518
+ return this.readExtendedAttributesField;
3519
+ }
3520
+ set
3521
+ {
3522
+ this.readExtendedAttributesFieldSet = true;
3523
+ this.readExtendedAttributesField = value;
3524
+ }
3525
+ }
3526
+
3527
+ public YesNoType WriteExtendedAttributes
3528
+ {
3529
+ get
3530
+ {
3531
+ return this.writeExtendedAttributesField;
3532
+ }
3533
+ set
3534
+ {
3535
+ this.writeExtendedAttributesFieldSet = true;
3536
+ this.writeExtendedAttributesField = value;
3537
+ }
3538
+ }
3539
+
3540
+ public YesNoType Synchronize
3541
+ {
3542
+ get
3543
+ {
3544
+ return this.synchronizeField;
3545
+ }
3546
+ set
3547
+ {
3548
+ this.synchronizeFieldSet = true;
3549
+ this.synchronizeField = value;
3550
+ }
3551
+ }
3552
+
3553
+ /// <summary>
3554
+ /// For a directory, the right to create a file in the directory. Only valid under a 'CreateFolder' parent.
3555
+ /// </summary>
3556
+ public YesNoType CreateFile
3557
+ {
3558
+ get
3559
+ {
3560
+ return this.createFileField;
3561
+ }
3562
+ set
3563
+ {
3564
+ this.createFileFieldSet = true;
3565
+ this.createFileField = value;
3566
+ }
3567
+ }
3568
+
3569
+ /// <summary>
3570
+ /// For a directory, the right to create a subdirectory. Only valid under a 'CreateFolder' parent.
3571
+ /// </summary>
3572
+ public YesNoType CreateChild
3573
+ {
3574
+ get
3575
+ {
3576
+ return this.createChildField;
3577
+ }
3578
+ set
3579
+ {
3580
+ this.createChildFieldSet = true;
3581
+ this.createChildField = value;
3582
+ }
3583
+ }
3584
+
3585
+ /// <summary>
3586
+ /// For a directory, the right to delete a directory and all the files it contains, including read-only files. Only valid under a 'CreateFolder' parent.
3587
+ /// </summary>
3588
+ public YesNoType DeleteChild
3589
+ {
3590
+ get
3591
+ {
3592
+ return this.deleteChildField;
3593
+ }
3594
+ set
3595
+ {
3596
+ this.deleteChildFieldSet = true;
3597
+ this.deleteChildField = value;
3598
+ }
3599
+ }
3600
+
3601
+ /// <summary>
3602
+ /// For a directory, the right to traverse the directory. By default, users are assigned the BYPASS_TRAVERSE_CHECKING privilege, which ignores the FILE_TRAVERSE access right. Only valid under a 'CreateFolder' parent.
3603
+ /// </summary>
3604
+ public YesNoType Traverse
3605
+ {
3606
+ get
3607
+ {
3608
+ return this.traverseField;
3609
+ }
3610
+ set
3611
+ {
3612
+ this.traverseFieldSet = true;
3613
+ this.traverseField = value;
3614
+ }
3615
+ }
3616
+
3617
+ public YesNoType GenericAll
3618
+ {
3619
+ get
3620
+ {
3621
+ return this.genericAllField;
3622
+ }
3623
+ set
3624
+ {
3625
+ this.genericAllFieldSet = true;
3626
+ this.genericAllField = value;
3627
+ }
3628
+ }
3629
+
3630
+ public YesNoType GenericExecute
3631
+ {
3632
+ get
3633
+ {
3634
+ return this.genericExecuteField;
3635
+ }
3636
+ set
3637
+ {
3638
+ this.genericExecuteFieldSet = true;
3639
+ this.genericExecuteField = value;
3640
+ }
3641
+ }
3642
+
3643
+ public YesNoType GenericWrite
3644
+ {
3645
+ get
3646
+ {
3647
+ return this.genericWriteField;
3648
+ }
3649
+ set
3650
+ {
3651
+ this.genericWriteFieldSet = true;
3652
+ this.genericWriteField = value;
3653
+ }
3654
+ }
3655
+
3656
+ /// <summary>
3657
+ /// specifying this will fail to grant read access
3658
+ /// </summary>
3659
+ public YesNoType GenericRead
3660
+ {
3661
+ get
3662
+ {
3663
+ return this.genericReadField;
3664
+ }
3665
+ set
3666
+ {
3667
+ this.genericReadFieldSet = true;
3668
+ this.genericReadField = value;
3669
+ }
3670
+ }
3671
+
3672
+ public virtual ISchemaElement ParentElement
3673
+ {
3674
+ get
3675
+ {
3676
+ return this.parentElement;
3677
+ }
3678
+ set
3679
+ {
3680
+ this.parentElement = value;
3681
+ }
3682
+ }
3683
+
3684
+ /// <summary>
3685
+ /// Processes this element and all child elements into an XmlWriter.
3686
+ /// </summary>
3687
+ [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
3688
+ public virtual void OutputXml(XmlWriter writer)
3689
+ {
3690
+ if ((null == writer))
3691
+ {
3692
+ throw new ArgumentNullException("writer");
3693
+ }
3694
+ writer.WriteStartElement("FileSharePermission", "http://wixtoolset.org/schemas/v4/wxs/util");
3695
+ if (this.userFieldSet)
3696
+ {
3697
+ writer.WriteAttributeString("User", this.userField);
3698
+ }
3699
+ if (this.readFieldSet)
3700
+ {
3701
+ if ((this.readField == YesNoType.no))
3702
+ {
3703
+ writer.WriteAttributeString("Read", "no");
3704
+ }
3705
+ if ((this.readField == YesNoType.yes))
3706
+ {
3707
+ writer.WriteAttributeString("Read", "yes");
3708
+ }
3709
+ }
3710
+ if (this.deleteFieldSet)
3711
+ {
3712
+ if ((this.deleteField == YesNoType.no))
3713
+ {
3714
+ writer.WriteAttributeString("Delete", "no");
3715
+ }
3716
+ if ((this.deleteField == YesNoType.yes))
3717
+ {
3718
+ writer.WriteAttributeString("Delete", "yes");
3719
+ }
3720
+ }
3721
+ if (this.readPermissionFieldSet)
3722
+ {
3723
+ if ((this.readPermissionField == YesNoType.no))
3724
+ {
3725
+ writer.WriteAttributeString("ReadPermission", "no");
3726
+ }
3727
+ if ((this.readPermissionField == YesNoType.yes))
3728
+ {
3729
+ writer.WriteAttributeString("ReadPermission", "yes");
3730
+ }
3731
+ }
3732
+ if (this.changePermissionFieldSet)
3733
+ {
3734
+ if ((this.changePermissionField == YesNoType.no))
3735
+ {
3736
+ writer.WriteAttributeString("ChangePermission", "no");
3737
+ }
3738
+ if ((this.changePermissionField == YesNoType.yes))
3739
+ {
3740
+ writer.WriteAttributeString("ChangePermission", "yes");
3741
+ }
3742
+ }
3743
+ if (this.takeOwnershipFieldSet)
3744
+ {
3745
+ if ((this.takeOwnershipField == YesNoType.no))
3746
+ {
3747
+ writer.WriteAttributeString("TakeOwnership", "no");
3748
+ }
3749
+ if ((this.takeOwnershipField == YesNoType.yes))
3750
+ {
3751
+ writer.WriteAttributeString("TakeOwnership", "yes");
3752
+ }
3753
+ }
3754
+ if (this.readAttributesFieldSet)
3755
+ {
3756
+ if ((this.readAttributesField == YesNoType.no))
3757
+ {
3758
+ writer.WriteAttributeString("ReadAttributes", "no");
3759
+ }
3760
+ if ((this.readAttributesField == YesNoType.yes))
3761
+ {
3762
+ writer.WriteAttributeString("ReadAttributes", "yes");
3763
+ }
3764
+ }
3765
+ if (this.writeAttributesFieldSet)
3766
+ {
3767
+ if ((this.writeAttributesField == YesNoType.no))
3768
+ {
3769
+ writer.WriteAttributeString("WriteAttributes", "no");
3770
+ }
3771
+ if ((this.writeAttributesField == YesNoType.yes))
3772
+ {
3773
+ writer.WriteAttributeString("WriteAttributes", "yes");
3774
+ }
3775
+ }
3776
+ if (this.readExtendedAttributesFieldSet)
3777
+ {
3778
+ if ((this.readExtendedAttributesField == YesNoType.no))
3779
+ {
3780
+ writer.WriteAttributeString("ReadExtendedAttributes", "no");
3781
+ }
3782
+ if ((this.readExtendedAttributesField == YesNoType.yes))
3783
+ {
3784
+ writer.WriteAttributeString("ReadExtendedAttributes", "yes");
3785
+ }
3786
+ }
3787
+ if (this.writeExtendedAttributesFieldSet)
3788
+ {
3789
+ if ((this.writeExtendedAttributesField == YesNoType.no))
3790
+ {
3791
+ writer.WriteAttributeString("WriteExtendedAttributes", "no");
3792
+ }
3793
+ if ((this.writeExtendedAttributesField == YesNoType.yes))
3794
+ {
3795
+ writer.WriteAttributeString("WriteExtendedAttributes", "yes");
3796
+ }
3797
+ }
3798
+ if (this.synchronizeFieldSet)
3799
+ {
3800
+ if ((this.synchronizeField == YesNoType.no))
3801
+ {
3802
+ writer.WriteAttributeString("Synchronize", "no");
3803
+ }
3804
+ if ((this.synchronizeField == YesNoType.yes))
3805
+ {
3806
+ writer.WriteAttributeString("Synchronize", "yes");
3807
+ }
3808
+ }
3809
+ if (this.createFileFieldSet)
3810
+ {
3811
+ if ((this.createFileField == YesNoType.no))
3812
+ {
3813
+ writer.WriteAttributeString("CreateFile", "no");
3814
+ }
3815
+ if ((this.createFileField == YesNoType.yes))
3816
+ {
3817
+ writer.WriteAttributeString("CreateFile", "yes");
3818
+ }
3819
+ }
3820
+ if (this.createChildFieldSet)
3821
+ {
3822
+ if ((this.createChildField == YesNoType.no))
3823
+ {
3824
+ writer.WriteAttributeString("CreateChild", "no");
3825
+ }
3826
+ if ((this.createChildField == YesNoType.yes))
3827
+ {
3828
+ writer.WriteAttributeString("CreateChild", "yes");
3829
+ }
3830
+ }
3831
+ if (this.deleteChildFieldSet)
3832
+ {
3833
+ if ((this.deleteChildField == YesNoType.no))
3834
+ {
3835
+ writer.WriteAttributeString("DeleteChild", "no");
3836
+ }
3837
+ if ((this.deleteChildField == YesNoType.yes))
3838
+ {
3839
+ writer.WriteAttributeString("DeleteChild", "yes");
3840
+ }
3841
+ }
3842
+ if (this.traverseFieldSet)
3843
+ {
3844
+ if ((this.traverseField == YesNoType.no))
3845
+ {
3846
+ writer.WriteAttributeString("Traverse", "no");
3847
+ }
3848
+ if ((this.traverseField == YesNoType.yes))
3849
+ {
3850
+ writer.WriteAttributeString("Traverse", "yes");
3851
+ }
3852
+ }
3853
+ if (this.genericAllFieldSet)
3854
+ {
3855
+ if ((this.genericAllField == YesNoType.no))
3856
+ {
3857
+ writer.WriteAttributeString("GenericAll", "no");
3858
+ }
3859
+ if ((this.genericAllField == YesNoType.yes))
3860
+ {
3861
+ writer.WriteAttributeString("GenericAll", "yes");
3862
+ }
3863
+ }
3864
+ if (this.genericExecuteFieldSet)
3865
+ {
3866
+ if ((this.genericExecuteField == YesNoType.no))
3867
+ {
3868
+ writer.WriteAttributeString("GenericExecute", "no");
3869
+ }
3870
+ if ((this.genericExecuteField == YesNoType.yes))
3871
+ {
3872
+ writer.WriteAttributeString("GenericExecute", "yes");
3873
+ }
3874
+ }
3875
+ if (this.genericWriteFieldSet)
3876
+ {
3877
+ if ((this.genericWriteField == YesNoType.no))
3878
+ {
3879
+ writer.WriteAttributeString("GenericWrite", "no");
3880
+ }
3881
+ if ((this.genericWriteField == YesNoType.yes))
3882
+ {
3883
+ writer.WriteAttributeString("GenericWrite", "yes");
3884
+ }
3885
+ }
3886
+ if (this.genericReadFieldSet)
3887
+ {
3888
+ if ((this.genericReadField == YesNoType.no))
3889
+ {
3890
+ writer.WriteAttributeString("GenericRead", "no");
3891
+ }
3892
+ if ((this.genericReadField == YesNoType.yes))
3893
+ {
3894
+ writer.WriteAttributeString("GenericRead", "yes");
3895
+ }
3896
+ }
3897
+ writer.WriteEndElement();
3898
+ }
3899
+
3900
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
3901
+ [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
3902
+ void ISetAttributes.SetAttribute(string name, string value)
3903
+ {
3904
+ if (String.IsNullOrEmpty(name))
3905
+ {
3906
+ throw new ArgumentNullException("name");
3907
+ }
3908
+ if (("User" == name))
3909
+ {
3910
+ this.userField = value;
3911
+ this.userFieldSet = true;
3912
+ }
3913
+ if (("Read" == name))
3914
+ {
3915
+ this.readField = Enums.ParseYesNoType(value);
3916
+ this.readFieldSet = true;
3917
+ }
3918
+ if (("Delete" == name))
3919
+ {
3920
+ this.deleteField = Enums.ParseYesNoType(value);
3921
+ this.deleteFieldSet = true;
3922
+ }
3923
+ if (("ReadPermission" == name))
3924
+ {
3925
+ this.readPermissionField = Enums.ParseYesNoType(value);
3926
+ this.readPermissionFieldSet = true;
3927
+ }
3928
+ if (("ChangePermission" == name))
3929
+ {
3930
+ this.changePermissionField = Enums.ParseYesNoType(value);
3931
+ this.changePermissionFieldSet = true;
3932
+ }
3933
+ if (("TakeOwnership" == name))
3934
+ {
3935
+ this.takeOwnershipField = Enums.ParseYesNoType(value);
3936
+ this.takeOwnershipFieldSet = true;
3937
+ }
3938
+ if (("ReadAttributes" == name))
3939
+ {
3940
+ this.readAttributesField = Enums.ParseYesNoType(value);
3941
+ this.readAttributesFieldSet = true;
3942
+ }
3943
+ if (("WriteAttributes" == name))
3944
+ {
3945
+ this.writeAttributesField = Enums.ParseYesNoType(value);
3946
+ this.writeAttributesFieldSet = true;
3947
+ }
3948
+ if (("ReadExtendedAttributes" == name))
3949
+ {
3950
+ this.readExtendedAttributesField = Enums.ParseYesNoType(value);
3951
+ this.readExtendedAttributesFieldSet = true;
3952
+ }
3953
+ if (("WriteExtendedAttributes" == name))
3954
+ {
3955
+ this.writeExtendedAttributesField = Enums.ParseYesNoType(value);
3956
+ this.writeExtendedAttributesFieldSet = true;
3957
+ }
3958
+ if (("Synchronize" == name))
3959
+ {
3960
+ this.synchronizeField = Enums.ParseYesNoType(value);
3961
+ this.synchronizeFieldSet = true;
3962
+ }
3963
+ if (("CreateFile" == name))
3964
+ {
3965
+ this.createFileField = Enums.ParseYesNoType(value);
3966
+ this.createFileFieldSet = true;
3967
+ }
3968
+ if (("CreateChild" == name))
3969
+ {
3970
+ this.createChildField = Enums.ParseYesNoType(value);
3971
+ this.createChildFieldSet = true;
3972
+ }
3973
+ if (("DeleteChild" == name))
3974
+ {
3975
+ this.deleteChildField = Enums.ParseYesNoType(value);
3976
+ this.deleteChildFieldSet = true;
3977
+ }
3978
+ if (("Traverse" == name))
3979
+ {
3980
+ this.traverseField = Enums.ParseYesNoType(value);
3981
+ this.traverseFieldSet = true;
3982
+ }
3983
+ if (("GenericAll" == name))
3984
+ {
3985
+ this.genericAllField = Enums.ParseYesNoType(value);
3986
+ this.genericAllFieldSet = true;
3987
+ }
3988
+ if (("GenericExecute" == name))
3989
+ {
3990
+ this.genericExecuteField = Enums.ParseYesNoType(value);
3991
+ this.genericExecuteFieldSet = true;
3992
+ }
3993
+ if (("GenericWrite" == name))
3994
+ {
3995
+ this.genericWriteField = Enums.ParseYesNoType(value);
3996
+ this.genericWriteFieldSet = true;
3997
+ }
3998
+ if (("GenericRead" == name))
3999
+ {
4000
+ this.genericReadField = Enums.ParseYesNoType(value);
4001
+ this.genericReadFieldSet = true;
4002
+ }
4003
+ }
4004
+ }
4005
+
4006
+ /// <summary>
4007
+ /// Formats a file's contents at install time. The contents are formatted according to the rules of the
4008
+ /// </summary>
4009
+ [GeneratedCode("XsdGen", "4.0.0.0")]
4010
+ public class FormatFile : ISchemaElement, ISetAttributes
4011
+ {
4012
+
4013
+ private string binaryKeyField;
4014
+
4015
+ private bool binaryKeyFieldSet;
4016
+
4017
+ private ISchemaElement parentElement;
4018
+
4019
+ /// <summary>
4020
+ /// The id of a Binary row that contains a copy of the file. The file in the Binary table overwrites whatever
4021
+ /// file is installed by the parent component.
4022
+ /// </summary>
4023
+ public string BinaryKey
4024
+ {
4025
+ get
4026
+ {
4027
+ return this.binaryKeyField;
4028
+ }
4029
+ set
4030
+ {
4031
+ this.binaryKeyFieldSet = true;
4032
+ this.binaryKeyField = value;
4033
+ }
4034
+ }
4035
+
4036
+ public virtual ISchemaElement ParentElement
4037
+ {
4038
+ get
4039
+ {
4040
+ return this.parentElement;
4041
+ }
4042
+ set
4043
+ {
4044
+ this.parentElement = value;
4045
+ }
4046
+ }
4047
+
4048
+ /// <summary>
4049
+ /// Processes this element and all child elements into an XmlWriter.
4050
+ /// </summary>
4051
+ public virtual void OutputXml(XmlWriter writer)
4052
+ {
4053
+ if ((null == writer))
4054
+ {
4055
+ throw new ArgumentNullException("writer");
4056
+ }
4057
+ writer.WriteStartElement("FormatFile", "http://wixtoolset.org/schemas/v4/wxs/util");
4058
+ if (this.binaryKeyFieldSet)
4059
+ {
4060
+ writer.WriteAttributeString("BinaryKey", this.binaryKeyField);
4061
+ }
4062
+ writer.WriteEndElement();
4063
+ }
4064
+
4065
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
4066
+ void ISetAttributes.SetAttribute(string name, string value)
4067
+ {
4068
+ if (String.IsNullOrEmpty(name))
4069
+ {
4070
+ throw new ArgumentNullException("name");
4071
+ }
4072
+ if (("BinaryKey" == name))
4073
+ {
4074
+ this.binaryKeyField = value;
4075
+ this.binaryKeyFieldSet = true;
4076
+ }
4077
+ }
4078
+ }
4079
+
4080
+ /// <summary>
4081
+ /// Finds user groups on the local machine or specified Active Directory domain. The local machine will be
4082
+ /// searched for the group first then fallback to looking in Active Directory. This element is not capable
4083
+ /// of creating new groups but can be used to add new or existing users to an existing group.
4084
+ /// </summary>
4085
+ [GeneratedCode("XsdGen", "4.0.0.0")]
4086
+ public class Group : ISchemaElement, ISetAttributes
4087
+ {
4088
+
4089
+ private string idField;
4090
+
4091
+ private bool idFieldSet;
4092
+
4093
+ private string nameField;
4094
+
4095
+ private bool nameFieldSet;
4096
+
4097
+ private string domainField;
4098
+
4099
+ private bool domainFieldSet;
4100
+
4101
+ private ISchemaElement parentElement;
4102
+
4103
+ /// <summary>
4104
+ /// Unique identifier in your installation package for this group.
4105
+ /// </summary>
4106
+ public string Id
4107
+ {
4108
+ get
4109
+ {
4110
+ return this.idField;
4111
+ }
4112
+ set
4113
+ {
4114
+ this.idFieldSet = true;
4115
+ this.idField = value;
4116
+ }
4117
+ }
4118
+
4119
+ /// <summary>
4120
+ /// A
4121
+ /// </summary>
4122
+ public string Name
4123
+ {
4124
+ get
4125
+ {
4126
+ return this.nameField;
4127
+ }
4128
+ set
4129
+ {
4130
+ this.nameFieldSet = true;
4131
+ this.nameField = value;
4132
+ }
4133
+ }
4134
+
4135
+ /// <summary>
4136
+ /// An optional
4137
+ /// </summary>
4138
+ public string Domain
4139
+ {
4140
+ get
4141
+ {
4142
+ return this.domainField;
4143
+ }
4144
+ set
4145
+ {
4146
+ this.domainFieldSet = true;
4147
+ this.domainField = value;
4148
+ }
4149
+ }
4150
+
4151
+ public virtual ISchemaElement ParentElement
4152
+ {
4153
+ get
4154
+ {
4155
+ return this.parentElement;
4156
+ }
4157
+ set
4158
+ {
4159
+ this.parentElement = value;
4160
+ }
4161
+ }
4162
+
4163
+ /// <summary>
4164
+ /// Processes this element and all child elements into an XmlWriter.
4165
+ /// </summary>
4166
+ public virtual void OutputXml(XmlWriter writer)
4167
+ {
4168
+ if ((null == writer))
4169
+ {
4170
+ throw new ArgumentNullException("writer");
4171
+ }
4172
+ writer.WriteStartElement("Group", "http://wixtoolset.org/schemas/v4/wxs/util");
4173
+ if (this.idFieldSet)
4174
+ {
4175
+ writer.WriteAttributeString("Id", this.idField);
4176
+ }
4177
+ if (this.nameFieldSet)
4178
+ {
4179
+ writer.WriteAttributeString("Name", this.nameField);
4180
+ }
4181
+ if (this.domainFieldSet)
4182
+ {
4183
+ writer.WriteAttributeString("Domain", this.domainField);
4184
+ }
4185
+ writer.WriteEndElement();
4186
+ }
4187
+
4188
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
4189
+ void ISetAttributes.SetAttribute(string name, string value)
4190
+ {
4191
+ if (String.IsNullOrEmpty(name))
4192
+ {
4193
+ throw new ArgumentNullException("name");
4194
+ }
4195
+ if (("Id" == name))
4196
+ {
4197
+ this.idField = value;
4198
+ this.idFieldSet = true;
4199
+ }
4200
+ if (("Name" == name))
4201
+ {
4202
+ this.nameField = value;
4203
+ this.nameFieldSet = true;
4204
+ }
4205
+ if (("Domain" == name))
4206
+ {
4207
+ this.domainField = value;
4208
+ this.domainFieldSet = true;
4209
+ }
4210
+ }
4211
+ }
4212
+
4213
+ /// <summary>
4214
+ /// Used to join a user to a group
4215
+ /// </summary>
4216
+ [GeneratedCode("XsdGen", "4.0.0.0")]
4217
+ public class GroupRef : ISchemaElement, ISetAttributes
4218
+ {
4219
+
4220
+ private string idField;
4221
+
4222
+ private bool idFieldSet;
4223
+
4224
+ private ISchemaElement parentElement;
4225
+
4226
+ public string Id
4227
+ {
4228
+ get
4229
+ {
4230
+ return this.idField;
4231
+ }
4232
+ set
4233
+ {
4234
+ this.idFieldSet = true;
4235
+ this.idField = value;
4236
+ }
4237
+ }
4238
+
4239
+ public virtual ISchemaElement ParentElement
4240
+ {
4241
+ get
4242
+ {
4243
+ return this.parentElement;
4244
+ }
4245
+ set
4246
+ {
4247
+ this.parentElement = value;
4248
+ }
4249
+ }
4250
+
4251
+ /// <summary>
4252
+ /// Processes this element and all child elements into an XmlWriter.
4253
+ /// </summary>
4254
+ public virtual void OutputXml(XmlWriter writer)
4255
+ {
4256
+ if ((null == writer))
4257
+ {
4258
+ throw new ArgumentNullException("writer");
4259
+ }
4260
+ writer.WriteStartElement("GroupRef", "http://wixtoolset.org/schemas/v4/wxs/util");
4261
+ if (this.idFieldSet)
4262
+ {
4263
+ writer.WriteAttributeString("Id", this.idField);
4264
+ }
4265
+ writer.WriteEndElement();
4266
+ }
4267
+
4268
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
4269
+ void ISetAttributes.SetAttribute(string name, string value)
4270
+ {
4271
+ if (String.IsNullOrEmpty(name))
4272
+ {
4273
+ throw new ArgumentNullException("name");
4274
+ }
4275
+ if (("Id" == name))
4276
+ {
4277
+ this.idField = value;
4278
+ this.idFieldSet = true;
4279
+ }
4280
+ }
4281
+ }
4282
+
4283
+ /// <summary>
4284
+ /// Creates a shortcut to a URL.
4285
+ /// </summary>
4286
+ [GeneratedCode("XsdGen", "4.0.0.0")]
4287
+ public class InternetShortcut : ISchemaElement, ISetAttributes
4288
+ {
4289
+
4290
+ private string idField;
4291
+
4292
+ private bool idFieldSet;
4293
+
4294
+ private string directoryField;
4295
+
4296
+ private bool directoryFieldSet;
4297
+
4298
+ private string nameField;
4299
+
4300
+ private bool nameFieldSet;
4301
+
4302
+ private string targetField;
4303
+
4304
+ private bool targetFieldSet;
4305
+
4306
+ private TypeType typeField;
4307
+
4308
+ private bool typeFieldSet;
4309
+
4310
+ private string iconFileField;
4311
+
4312
+ private bool iconFileFieldSet;
4313
+
4314
+ private int iconIndexField;
4315
+
4316
+ private bool iconIndexFieldSet;
4317
+
4318
+ private ISchemaElement parentElement;
4319
+
4320
+ /// <summary>
4321
+ /// Unique identifier in your installation package for this Internet shortcut.
4322
+ /// </summary>
4323
+ public string Id
4324
+ {
4325
+ get
4326
+ {
4327
+ return this.idField;
4328
+ }
4329
+ set
4330
+ {
4331
+ this.idFieldSet = true;
4332
+ this.idField = value;
4333
+ }
4334
+ }
4335
+
4336
+ /// <summary>
4337
+ /// Identifier reference to Directory element where shortcut is to be created. This attribute's value defaults to the parent Component directory.
4338
+ /// </summary>
4339
+ public string Directory
4340
+ {
4341
+ get
4342
+ {
4343
+ return this.directoryField;
4344
+ }
4345
+ set
4346
+ {
4347
+ this.directoryFieldSet = true;
4348
+ this.directoryField = value;
4349
+ }
4350
+ }
4351
+
4352
+ /// <summary>
4353
+ /// The name of the shortcut file, which is visible to the user. (The .lnk
4354
+ /// extension is added automatically and by default, is not shown to the user.)
4355
+ /// </summary>
4356
+ public string Name
4357
+ {
4358
+ get
4359
+ {
4360
+ return this.nameField;
4361
+ }
4362
+ set
4363
+ {
4364
+ this.nameFieldSet = true;
4365
+ this.nameField = value;
4366
+ }
4367
+ }
4368
+
4369
+ /// <summary>
4370
+ /// URL that should be opened when the user selects the shortcut. Windows
4371
+ /// opens the URL in the appropriate handler for the protocol specified
4372
+ /// in the URL. Note that this is a formatted field, so you can use
4373
+ /// [#fileId] syntax to refer to a file being installed (using the file:
4374
+ /// protocol).
4375
+ /// </summary>
4376
+ public string Target
4377
+ {
4378
+ get
4379
+ {
4380
+ return this.targetField;
4381
+ }
4382
+ set
4383
+ {
4384
+ this.targetFieldSet = true;
4385
+ this.targetField = value;
4386
+ }
4387
+ }
4388
+
4389
+ /// <summary>
4390
+ /// Which type of shortcut should be created.
4391
+ /// </summary>
4392
+ public TypeType Type
4393
+ {
4394
+ get
4395
+ {
4396
+ return this.typeField;
4397
+ }
4398
+ set
4399
+ {
4400
+ this.typeFieldSet = true;
4401
+ this.typeField = value;
4402
+ }
4403
+ }
4404
+
4405
+ /// <summary>
4406
+ /// Icon file that should be displayed. Note that this is a formatted field, so you can use
4407
+ /// [#fileId] syntax to refer to a file being installed (using the file:
4408
+ /// protocol).
4409
+ /// </summary>
4410
+ public string IconFile
4411
+ {
4412
+ get
4413
+ {
4414
+ return this.iconFileField;
4415
+ }
4416
+ set
4417
+ {
4418
+ this.iconFileFieldSet = true;
4419
+ this.iconFileField = value;
4420
+ }
4421
+ }
4422
+
4423
+ /// <summary>
4424
+ /// Index of the icon being referenced
4425
+ /// </summary>
4426
+ public int IconIndex
4427
+ {
4428
+ get
4429
+ {
4430
+ return this.iconIndexField;
4431
+ }
4432
+ set
4433
+ {
4434
+ this.iconIndexFieldSet = true;
4435
+ this.iconIndexField = value;
4436
+ }
4437
+ }
4438
+
4439
+ public virtual ISchemaElement ParentElement
4440
+ {
4441
+ get
4442
+ {
4443
+ return this.parentElement;
4444
+ }
4445
+ set
4446
+ {
4447
+ this.parentElement = value;
4448
+ }
4449
+ }
4450
+
4451
+ /// <summary>
4452
+ /// Parses a TypeType from a string.
4453
+ /// </summary>
4454
+ public static TypeType ParseTypeType(string value)
4455
+ {
4456
+ TypeType parsedValue;
4457
+ InternetShortcut.TryParseTypeType(value, out parsedValue);
4458
+ return parsedValue;
4459
+ }
4460
+
4461
+ /// <summary>
4462
+ /// Tries to parse a TypeType from a string.
4463
+ /// </summary>
4464
+ public static bool TryParseTypeType(string value, out TypeType parsedValue)
4465
+ {
4466
+ parsedValue = TypeType.NotSet;
4467
+ if (string.IsNullOrEmpty(value))
4468
+ {
4469
+ return false;
4470
+ }
4471
+ if (("url" == value))
4472
+ {
4473
+ parsedValue = TypeType.url;
4474
+ }
4475
+ else
4476
+ {
4477
+ if (("link" == value))
4478
+ {
4479
+ parsedValue = TypeType.link;
4480
+ }
4481
+ else
4482
+ {
4483
+ parsedValue = TypeType.IllegalValue;
4484
+ return false;
4485
+ }
4486
+ }
4487
+ return true;
4488
+ }
4489
+
4490
+ /// <summary>
4491
+ /// Processes this element and all child elements into an XmlWriter.
4492
+ /// </summary>
4493
+ [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
4494
+ public virtual void OutputXml(XmlWriter writer)
4495
+ {
4496
+ if ((null == writer))
4497
+ {
4498
+ throw new ArgumentNullException("writer");
4499
+ }
4500
+ writer.WriteStartElement("InternetShortcut", "http://wixtoolset.org/schemas/v4/wxs/util");
4501
+ if (this.idFieldSet)
4502
+ {
4503
+ writer.WriteAttributeString("Id", this.idField);
4504
+ }
4505
+ if (this.directoryFieldSet)
4506
+ {
4507
+ writer.WriteAttributeString("Directory", this.directoryField);
4508
+ }
4509
+ if (this.nameFieldSet)
4510
+ {
4511
+ writer.WriteAttributeString("Name", this.nameField);
4512
+ }
4513
+ if (this.targetFieldSet)
4514
+ {
4515
+ writer.WriteAttributeString("Target", this.targetField);
4516
+ }
4517
+ if (this.typeFieldSet)
4518
+ {
4519
+ if ((this.typeField == TypeType.url))
4520
+ {
4521
+ writer.WriteAttributeString("Type", "url");
4522
+ }
4523
+ if ((this.typeField == TypeType.link))
4524
+ {
4525
+ writer.WriteAttributeString("Type", "link");
4526
+ }
4527
+ }
4528
+ if (this.iconFileFieldSet)
4529
+ {
4530
+ writer.WriteAttributeString("IconFile", this.iconFileField);
4531
+ }
4532
+ if (this.iconIndexFieldSet)
4533
+ {
4534
+ writer.WriteAttributeString("IconIndex", this.iconIndexField.ToString(CultureInfo.InvariantCulture));
4535
+ }
4536
+ writer.WriteEndElement();
4537
+ }
4538
+
4539
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
4540
+ void ISetAttributes.SetAttribute(string name, string value)
4541
+ {
4542
+ if (String.IsNullOrEmpty(name))
4543
+ {
4544
+ throw new ArgumentNullException("name");
4545
+ }
4546
+ if (("Id" == name))
4547
+ {
4548
+ this.idField = value;
4549
+ this.idFieldSet = true;
4550
+ }
4551
+ if (("Directory" == name))
4552
+ {
4553
+ this.directoryField = value;
4554
+ this.directoryFieldSet = true;
4555
+ }
4556
+ if (("Name" == name))
4557
+ {
4558
+ this.nameField = value;
4559
+ this.nameFieldSet = true;
4560
+ }
4561
+ if (("Target" == name))
4562
+ {
4563
+ this.targetField = value;
4564
+ this.targetFieldSet = true;
4565
+ }
4566
+ if (("Type" == name))
4567
+ {
4568
+ this.typeField = InternetShortcut.ParseTypeType(value);
4569
+ this.typeFieldSet = true;
4570
+ }
4571
+ if (("IconFile" == name))
4572
+ {
4573
+ this.iconFileField = value;
4574
+ this.iconFileFieldSet = true;
4575
+ }
4576
+ if (("IconIndex" == name))
4577
+ {
4578
+ this.iconIndexField = Convert.ToInt32(value, CultureInfo.InvariantCulture);
4579
+ this.iconIndexFieldSet = true;
4580
+ }
4581
+ }
4582
+
4583
+ [GeneratedCode("XsdGen", "4.0.0.0")]
4584
+ public enum TypeType
4585
+ {
4586
+
4587
+ IllegalValue = int.MaxValue,
4588
+
4589
+ NotSet = -1,
4590
+
4591
+ /// <summary>
4592
+ /// Creates .url files using IUniformResourceLocatorW.
4593
+ /// </summary>
4594
+ url,
4595
+
4596
+ /// <summary>
4597
+ /// Creates .lnk files using IShellLinkW (default).
4598
+ /// </summary>
4599
+ link,
4600
+ }
4601
+ }
4602
+
4603
+ /// <summary>
4604
+ /// Used to create performance categories and configure performance counters.
4605
+ /// </summary>
4606
+ [GeneratedCode("XsdGen", "4.0.0.0")]
4607
+ public class PerformanceCategory : IParentElement, ICreateChildren, ISchemaElement, ISetAttributes
4608
+ {
4609
+
4610
+ private ElementCollection children;
4611
+
4612
+ private string idField;
4613
+
4614
+ private bool idFieldSet;
4615
+
4616
+ private string nameField;
4617
+
4618
+ private bool nameFieldSet;
4619
+
4620
+ private string helpField;
4621
+
4622
+ private bool helpFieldSet;
4623
+
4624
+ private YesNoType multiInstanceField;
4625
+
4626
+ private bool multiInstanceFieldSet;
4627
+
4628
+ private string libraryField;
4629
+
4630
+ private bool libraryFieldSet;
4631
+
4632
+ private string openField;
4633
+
4634
+ private bool openFieldSet;
4635
+
4636
+ private string closeField;
4637
+
4638
+ private bool closeFieldSet;
4639
+
4640
+ private string collectField;
4641
+
4642
+ private bool collectFieldSet;
4643
+
4644
+ private PerformanceCounterLanguageType defaultLanguageField;
4645
+
4646
+ private bool defaultLanguageFieldSet;
4647
+
4648
+ private ISchemaElement parentElement;
4649
+
4650
+ public PerformanceCategory()
4651
+ {
4652
+ ElementCollection childCollection0 = new ElementCollection(ElementCollection.CollectionType.Sequence);
4653
+ childCollection0.AddItem(new ElementCollection.SequenceItem(typeof(PerformanceCounter)));
4654
+ this.children = childCollection0;
4655
+ }
4656
+
4657
+ public virtual IEnumerable Children
4658
+ {
4659
+ get
4660
+ {
4661
+ return this.children;
4662
+ }
4663
+ }
4664
+
4665
+ [SuppressMessage("Microsoft.Design", "CA1043:UseIntegralOrStringArgumentForIndexers")]
4666
+ public virtual IEnumerable this[System.Type childType]
4667
+ {
4668
+ get
4669
+ {
4670
+ return this.children.Filter(childType);
4671
+ }
4672
+ }
4673
+
4674
+ /// <summary>
4675
+ /// Unique identifier in your installation package for this performance counter category.
4676
+ /// </summary>
4677
+ public string Id
4678
+ {
4679
+ get
4680
+ {
4681
+ return this.idField;
4682
+ }
4683
+ set
4684
+ {
4685
+ this.idFieldSet = true;
4686
+ this.idField = value;
4687
+ }
4688
+ }
4689
+
4690
+ /// <summary>
4691
+ /// Name for the performance counter category. If this attribute is not provided the Id attribute is used as the name of the performance counter category.
4692
+ /// </summary>
4693
+ public string Name
4694
+ {
4695
+ get
4696
+ {
4697
+ return this.nameField;
4698
+ }
4699
+ set
4700
+ {
4701
+ this.nameFieldSet = true;
4702
+ this.nameField = value;
4703
+ }
4704
+ }
4705
+
4706
+ /// <summary>
4707
+ /// Optional help text for the performance counter category.
4708
+ /// </summary>
4709
+ public string Help
4710
+ {
4711
+ get
4712
+ {
4713
+ return this.helpField;
4714
+ }
4715
+ set
4716
+ {
4717
+ this.helpFieldSet = true;
4718
+ this.helpField = value;
4719
+ }
4720
+ }
4721
+
4722
+ /// <summary>
4723
+ /// Flag that specifies whether the performance counter category is multi or single instanced. Default is single instance.
4724
+ /// </summary>
4725
+ public YesNoType MultiInstance
4726
+ {
4727
+ get
4728
+ {
4729
+ return this.multiInstanceField;
4730
+ }
4731
+ set
4732
+ {
4733
+ this.multiInstanceFieldSet = true;
4734
+ this.multiInstanceField = value;
4735
+ }
4736
+ }
4737
+
4738
+ /// <summary>
4739
+ /// DLL that contains the performance counter. The default is "netfxperf.dll" which should be used for all managed code performance counters.
4740
+ /// </summary>
4741
+ public string Library
4742
+ {
4743
+ get
4744
+ {
4745
+ return this.libraryField;
4746
+ }
4747
+ set
4748
+ {
4749
+ this.libraryFieldSet = true;
4750
+ this.libraryField = value;
4751
+ }
4752
+ }
4753
+
4754
+ /// <summary>
4755
+ /// Function entry point in to the Library DLL called when opening the performance counter. The default is "OpenPerformanceData" which should be used for all managed code performance counters.
4756
+ /// </summary>
4757
+ public string Open
4758
+ {
4759
+ get
4760
+ {
4761
+ return this.openField;
4762
+ }
4763
+ set
4764
+ {
4765
+ this.openFieldSet = true;
4766
+ this.openField = value;
4767
+ }
4768
+ }
4769
+
4770
+ /// <summary>
4771
+ /// Function entry point in to the Library DLL called when closing the performance counter. The default is "ClosePerformanceData" which should be used for all managed code performance counters.
4772
+ /// </summary>
4773
+ public string Close
4774
+ {
4775
+ get
4776
+ {
4777
+ return this.closeField;
4778
+ }
4779
+ set
4780
+ {
4781
+ this.closeFieldSet = true;
4782
+ this.closeField = value;
4783
+ }
4784
+ }
4785
+
4786
+ /// <summary>
4787
+ /// Function entry point in to the Library DLL called when collecting data from the performance counter. The default is "CollectPerformanceData" which should be used for all managed code performance counters.
4788
+ /// </summary>
4789
+ public string Collect
4790
+ {
4791
+ get
4792
+ {
4793
+ return this.collectField;
4794
+ }
4795
+ set
4796
+ {
4797
+ this.collectFieldSet = true;
4798
+ this.collectField = value;
4799
+ }
4800
+ }
4801
+
4802
+ /// <summary>
4803
+ /// Default language for the performance category and contained counters' names and help text.
4804
+ /// </summary>
4805
+ public PerformanceCounterLanguageType DefaultLanguage
4806
+ {
4807
+ get
4808
+ {
4809
+ return this.defaultLanguageField;
4810
+ }
4811
+ set
4812
+ {
4813
+ this.defaultLanguageFieldSet = true;
4814
+ this.defaultLanguageField = value;
4815
+ }
4816
+ }
4817
+
4818
+ public virtual ISchemaElement ParentElement
4819
+ {
4820
+ get
4821
+ {
4822
+ return this.parentElement;
4823
+ }
4824
+ set
4825
+ {
4826
+ this.parentElement = value;
4827
+ }
4828
+ }
4829
+
4830
+ public virtual void AddChild(ISchemaElement child)
4831
+ {
4832
+ if ((null == child))
4833
+ {
4834
+ throw new ArgumentNullException("child");
4835
+ }
4836
+ this.children.AddElement(child);
4837
+ child.ParentElement = this;
4838
+ }
4839
+
4840
+ public virtual void RemoveChild(ISchemaElement child)
4841
+ {
4842
+ if ((null == child))
4843
+ {
4844
+ throw new ArgumentNullException("child");
4845
+ }
4846
+ this.children.RemoveElement(child);
4847
+ child.ParentElement = null;
4848
+ }
4849
+
4850
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
4851
+ ISchemaElement ICreateChildren.CreateChild(string childName)
4852
+ {
4853
+ if (String.IsNullOrEmpty(childName))
4854
+ {
4855
+ throw new ArgumentNullException("childName");
4856
+ }
4857
+ ISchemaElement childValue = null;
4858
+ if (("PerformanceCounter" == childName))
4859
+ {
4860
+ childValue = new PerformanceCounter();
4861
+ }
4862
+ if ((null == childValue))
4863
+ {
4864
+ throw new InvalidOperationException(String.Concat(childName, " is not a valid child name."));
4865
+ }
4866
+ return childValue;
4867
+ }
4868
+
4869
+ /// <summary>
4870
+ /// Processes this element and all child elements into an XmlWriter.
4871
+ /// </summary>
4872
+ [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
4873
+ public virtual void OutputXml(XmlWriter writer)
4874
+ {
4875
+ if ((null == writer))
4876
+ {
4877
+ throw new ArgumentNullException("writer");
4878
+ }
4879
+ writer.WriteStartElement("PerformanceCategory", "http://wixtoolset.org/schemas/v4/wxs/util");
4880
+ if (this.idFieldSet)
4881
+ {
4882
+ writer.WriteAttributeString("Id", this.idField);
4883
+ }
4884
+ if (this.nameFieldSet)
4885
+ {
4886
+ writer.WriteAttributeString("Name", this.nameField);
4887
+ }
4888
+ if (this.helpFieldSet)
4889
+ {
4890
+ writer.WriteAttributeString("Help", this.helpField);
4891
+ }
4892
+ if (this.multiInstanceFieldSet)
4893
+ {
4894
+ if ((this.multiInstanceField == YesNoType.no))
4895
+ {
4896
+ writer.WriteAttributeString("MultiInstance", "no");
4897
+ }
4898
+ if ((this.multiInstanceField == YesNoType.yes))
4899
+ {
4900
+ writer.WriteAttributeString("MultiInstance", "yes");
4901
+ }
4902
+ }
4903
+ if (this.libraryFieldSet)
4904
+ {
4905
+ writer.WriteAttributeString("Library", this.libraryField);
4906
+ }
4907
+ if (this.openFieldSet)
4908
+ {
4909
+ writer.WriteAttributeString("Open", this.openField);
4910
+ }
4911
+ if (this.closeFieldSet)
4912
+ {
4913
+ writer.WriteAttributeString("Close", this.closeField);
4914
+ }
4915
+ if (this.collectFieldSet)
4916
+ {
4917
+ writer.WriteAttributeString("Collect", this.collectField);
4918
+ }
4919
+ if (this.defaultLanguageFieldSet)
4920
+ {
4921
+ if ((this.defaultLanguageField == PerformanceCounterLanguageType.afrikaans))
4922
+ {
4923
+ writer.WriteAttributeString("DefaultLanguage", "afrikaans");
4924
+ }
4925
+ if ((this.defaultLanguageField == PerformanceCounterLanguageType.albanian))
4926
+ {
4927
+ writer.WriteAttributeString("DefaultLanguage", "albanian");
4928
+ }
4929
+ if ((this.defaultLanguageField == PerformanceCounterLanguageType.arabic))
4930
+ {
4931
+ writer.WriteAttributeString("DefaultLanguage", "arabic");
4932
+ }
4933
+ if ((this.defaultLanguageField == PerformanceCounterLanguageType.armenian))
4934
+ {
4935
+ writer.WriteAttributeString("DefaultLanguage", "armenian");
4936
+ }
4937
+ if ((this.defaultLanguageField == PerformanceCounterLanguageType.assamese))
4938
+ {
4939
+ writer.WriteAttributeString("DefaultLanguage", "assamese");
4940
+ }
4941
+ if ((this.defaultLanguageField == PerformanceCounterLanguageType.azeri))
4942
+ {
4943
+ writer.WriteAttributeString("DefaultLanguage", "azeri");
4944
+ }
4945
+ if ((this.defaultLanguageField == PerformanceCounterLanguageType.basque))
4946
+ {
4947
+ writer.WriteAttributeString("DefaultLanguage", "basque");
4948
+ }
4949
+ if ((this.defaultLanguageField == PerformanceCounterLanguageType.belarusian))
4950
+ {
4951
+ writer.WriteAttributeString("DefaultLanguage", "belarusian");
4952
+ }
4953
+ if ((this.defaultLanguageField == PerformanceCounterLanguageType.bengali))
4954
+ {
4955
+ writer.WriteAttributeString("DefaultLanguage", "bengali");
4956
+ }
4957
+ if ((this.defaultLanguageField == PerformanceCounterLanguageType.bulgarian))
4958
+ {
4959
+ writer.WriteAttributeString("DefaultLanguage", "bulgarian");
4960
+ }
4961
+ if ((this.defaultLanguageField == PerformanceCounterLanguageType.catalan))
4962
+ {
4963
+ writer.WriteAttributeString("DefaultLanguage", "catalan");
4964
+ }
4965
+ if ((this.defaultLanguageField == PerformanceCounterLanguageType.chinese))
4966
+ {
4967
+ writer.WriteAttributeString("DefaultLanguage", "chinese");
4968
+ }
4969
+ if ((this.defaultLanguageField == PerformanceCounterLanguageType.croatian))
4970
+ {
4971
+ writer.WriteAttributeString("DefaultLanguage", "croatian");
4972
+ }
4973
+ if ((this.defaultLanguageField == PerformanceCounterLanguageType.czech))
4974
+ {
4975
+ writer.WriteAttributeString("DefaultLanguage", "czech");
4976
+ }
4977
+ if ((this.defaultLanguageField == PerformanceCounterLanguageType.danish))
4978
+ {
4979
+ writer.WriteAttributeString("DefaultLanguage", "danish");
4980
+ }
4981
+ if ((this.defaultLanguageField == PerformanceCounterLanguageType.divehi))
4982
+ {
4983
+ writer.WriteAttributeString("DefaultLanguage", "divehi");
4984
+ }
4985
+ if ((this.defaultLanguageField == PerformanceCounterLanguageType.dutch))
4986
+ {
4987
+ writer.WriteAttributeString("DefaultLanguage", "dutch");
4988
+ }
4989
+ if ((this.defaultLanguageField == PerformanceCounterLanguageType.english))
4990
+ {
4991
+ writer.WriteAttributeString("DefaultLanguage", "english");
4992
+ }
4993
+ if ((this.defaultLanguageField == PerformanceCounterLanguageType.estonian))
4994
+ {
4995
+ writer.WriteAttributeString("DefaultLanguage", "estonian");
4996
+ }
4997
+ if ((this.defaultLanguageField == PerformanceCounterLanguageType.faeroese))
4998
+ {
4999
+ writer.WriteAttributeString("DefaultLanguage", "faeroese");
This file is too large to show in full.
src/heat/Serialize/vs.cs
new
+1574
@@ -0,0 +1,1574 @@
1
+//------------------------------------------------------------------------------
2
+// <auto-generated>
3
+// This code was generated by a tool.
4
+// Runtime Version:4.0.30319.42000
5
+//
6
+// Changes to this file may cause incorrect behavior and will be lost if
7
+// the code is regenerated.
8
+// </auto-generated>
9
+//------------------------------------------------------------------------------
10
+
11
+#pragma warning disable 1591
12
+namespace WixToolset.Harvesters.Serialize.VS
13
+{
14
+ using System;
15
+ using System.CodeDom.Compiler;
16
+ using System.Collections;
17
+ using System.Diagnostics.CodeAnalysis;
18
+ using System.Globalization;
19
+ using System.Xml;
20
+ using WixToolset.Harvesters.Serialize;
21
+
22
+
23
+ /// <summary>
24
+ /// Values of this type will either be "yes" or "no".
25
+ /// </summary>
26
+ [GeneratedCode("XsdGen", "4.0.0.0")]
27
+ public enum YesNoType
28
+ {
29
+
30
+ IllegalValue = int.MaxValue,
31
+
32
+ NotSet = -1,
33
+
34
+ no,
35
+
36
+ yes,
37
+ }
38
+
39
+ [GeneratedCode("XsdGen", "4.0.0.0")]
40
+ public class Enums
41
+ {
42
+
43
+ /// <summary>
44
+ /// Parses a YesNoType from a string.
45
+ /// </summary>
46
+ public static YesNoType ParseYesNoType(string value)
47
+ {
48
+ YesNoType parsedValue;
49
+ Enums.TryParseYesNoType(value, out parsedValue);
50
+ return parsedValue;
51
+ }
52
+
53
+ /// <summary>
54
+ /// Tries to parse a YesNoType from a string.
55
+ /// </summary>
56
+ public static bool TryParseYesNoType(string value, out YesNoType parsedValue)
57
+ {
58
+ parsedValue = YesNoType.NotSet;
59
+ if (string.IsNullOrEmpty(value))
60
+ {
61
+ return false;
62
+ }
63
+ if (("no" == value))
64
+ {
65
+ parsedValue = YesNoType.no;
66
+ }
67
+ else
68
+ {
69
+ if (("yes" == value))
70
+ {
71
+ parsedValue = YesNoType.yes;
72
+ }
73
+ else
74
+ {
75
+ parsedValue = YesNoType.IllegalValue;
76
+ return false;
77
+ }
78
+ }
79
+ return true;
80
+ }
81
+ }
82
+
83
+ /// <summary>
84
+ /// Help Namespace for a help collection. The parent file is the key for the HxC (Collection) file.
85
+ /// </summary>
86
+ [GeneratedCode("XsdGen", "4.0.0.0")]
87
+ public class HelpCollection : IParentElement, ICreateChildren, ISchemaElement, ISetAttributes
88
+ {
89
+
90
+ private ElementCollection children;
91
+
92
+ private string idField;
93
+
94
+ private bool idFieldSet;
95
+
96
+ private string descriptionField;
97
+
98
+ private bool descriptionFieldSet;
99
+
100
+ private string nameField;
101
+
102
+ private bool nameFieldSet;
103
+
104
+ private YesNoType suppressCustomActionsField;
105
+
106
+ private bool suppressCustomActionsFieldSet;
107
+
108
+ private ISchemaElement parentElement;
109
+
110
+ public HelpCollection()
111
+ {
112
+ ElementCollection childCollection0 = new ElementCollection(ElementCollection.CollectionType.Choice);
113
+ childCollection0.AddItem(new ElementCollection.ChoiceItem(typeof(HelpFileRef)));
114
+ childCollection0.AddItem(new ElementCollection.ChoiceItem(typeof(HelpFilterRef)));
115
+ childCollection0.AddItem(new ElementCollection.ChoiceItem(typeof(PlugCollectionInto)));
116
+ this.children = childCollection0;
117
+ }
118
+
119
+ public virtual IEnumerable Children
120
+ {
121
+ get
122
+ {
123
+ return this.children;
124
+ }
125
+ }
126
+
127
+ [SuppressMessage("Microsoft.Design", "CA1043:UseIntegralOrStringArgumentForIndexers")]
128
+ public virtual IEnumerable this[System.Type childType]
129
+ {
130
+ get
131
+ {
132
+ return this.children.Filter(childType);
133
+ }
134
+ }
135
+
136
+ /// <summary>
137
+ /// Primary Key for HelpNamespace.
138
+ /// </summary>
139
+ public string Id
140
+ {
141
+ get
142
+ {
143
+ return this.idField;
144
+ }
145
+ set
146
+ {
147
+ this.idFieldSet = true;
148
+ this.idField = value;
149
+ }
150
+ }
151
+
152
+ /// <summary>
153
+ /// Friendly name for Namespace.
154
+ /// </summary>
155
+ public string Description
156
+ {
157
+ get
158
+ {
159
+ return this.descriptionField;
160
+ }
161
+ set
162
+ {
163
+ this.descriptionFieldSet = true;
164
+ this.descriptionField = value;
165
+ }
166
+ }
167
+
168
+ /// <summary>
169
+ /// Internal Microsoft Help ID for this Namespace.
170
+ /// </summary>
171
+ public string Name
172
+ {
173
+ get
174
+ {
175
+ return this.nameField;
176
+ }
177
+ set
178
+ {
179
+ this.nameFieldSet = true;
180
+ this.nameField = value;
181
+ }
182
+ }
183
+
184
+ /// <summary>
185
+ /// Suppress linking Help registration custom actions. Help redistributable merge modules will be required. Use this when building a merge module.
186
+ /// </summary>
187
+ public YesNoType SuppressCustomActions
188
+ {
189
+ get
190
+ {
191
+ return this.suppressCustomActionsField;
192
+ }
193
+ set
194
+ {
195
+ this.suppressCustomActionsFieldSet = true;
196
+ this.suppressCustomActionsField = value;
197
+ }
198
+ }
199
+
200
+ public virtual ISchemaElement ParentElement
201
+ {
202
+ get
203
+ {
204
+ return this.parentElement;
205
+ }
206
+ set
207
+ {
208
+ this.parentElement = value;
209
+ }
210
+ }
211
+
212
+ public virtual void AddChild(ISchemaElement child)
213
+ {
214
+ if ((null == child))
215
+ {
216
+ throw new ArgumentNullException("child");
217
+ }
218
+ this.children.AddElement(child);
219
+ child.ParentElement = this;
220
+ }
221
+
222
+ public virtual void RemoveChild(ISchemaElement child)
223
+ {
224
+ if ((null == child))
225
+ {
226
+ throw new ArgumentNullException("child");
227
+ }
228
+ this.children.RemoveElement(child);
229
+ child.ParentElement = null;
230
+ }
231
+
232
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
233
+ ISchemaElement ICreateChildren.CreateChild(string childName)
234
+ {
235
+ if (String.IsNullOrEmpty(childName))
236
+ {
237
+ throw new ArgumentNullException("childName");
238
+ }
239
+ ISchemaElement childValue = null;
240
+ if (("HelpFileRef" == childName))
241
+ {
242
+ childValue = new HelpFileRef();
243
+ }
244
+ if (("HelpFilterRef" == childName))
245
+ {
246
+ childValue = new HelpFilterRef();
247
+ }
248
+ if (("PlugCollectionInto" == childName))
249
+ {
250
+ childValue = new PlugCollectionInto();
251
+ }
252
+ if ((null == childValue))
253
+ {
254
+ throw new InvalidOperationException(String.Concat(childName, " is not a valid child name."));
255
+ }
256
+ return childValue;
257
+ }
258
+
259
+ /// <summary>
260
+ /// Processes this element and all child elements into an XmlWriter.
261
+ /// </summary>
262
+ public virtual void OutputXml(XmlWriter writer)
263
+ {
264
+ if ((null == writer))
265
+ {
266
+ throw new ArgumentNullException("writer");
267
+ }
268
+ writer.WriteStartElement("HelpCollection", "http://wixtoolset.org/schemas/v4/wxs/vs");
269
+ if (this.idFieldSet)
270
+ {
271
+ writer.WriteAttributeString("Id", this.idField);
272
+ }
273
+ if (this.descriptionFieldSet)
274
+ {
275
+ writer.WriteAttributeString("Description", this.descriptionField);
276
+ }
277
+ if (this.nameFieldSet)
278
+ {
279
+ writer.WriteAttributeString("Name", this.nameField);
280
+ }
281
+ if (this.suppressCustomActionsFieldSet)
282
+ {
283
+ if ((this.suppressCustomActionsField == YesNoType.no))
284
+ {
285
+ writer.WriteAttributeString("SuppressCustomActions", "no");
286
+ }
287
+ if ((this.suppressCustomActionsField == YesNoType.yes))
288
+ {
289
+ writer.WriteAttributeString("SuppressCustomActions", "yes");
290
+ }
291
+ }
292
+ for (IEnumerator enumerator = this.children.GetEnumerator(); enumerator.MoveNext(); )
293
+ {
294
+ ISchemaElement childElement = ((ISchemaElement)(enumerator.Current));
295
+ childElement.OutputXml(writer);
296
+ }
297
+ writer.WriteEndElement();
298
+ }
299
+
300
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
301
+ void ISetAttributes.SetAttribute(string name, string value)
302
+ {
303
+ if (String.IsNullOrEmpty(name))
304
+ {
305
+ throw new ArgumentNullException("name");
306
+ }
307
+ if (("Id" == name))
308
+ {
309
+ this.idField = value;
310
+ this.idFieldSet = true;
311
+ }
312
+ if (("Description" == name))
313
+ {
314
+ this.descriptionField = value;
315
+ this.descriptionFieldSet = true;
316
+ }
317
+ if (("Name" == name))
318
+ {
319
+ this.nameField = value;
320
+ this.nameFieldSet = true;
321
+ }
322
+ if (("SuppressCustomActions" == name))
323
+ {
324
+ this.suppressCustomActionsField = Enums.ParseYesNoType(value);
325
+ this.suppressCustomActionsFieldSet = true;
326
+ }
327
+ }
328
+ }
329
+
330
+ /// <summary>
331
+ /// Filter for Help Namespace.
332
+ /// </summary>
333
+ [GeneratedCode("XsdGen", "4.0.0.0")]
334
+ public class HelpFilter : ISchemaElement, ISetAttributes
335
+ {
336
+
337
+ private string idField;
338
+
339
+ private bool idFieldSet;
340
+
341
+ private string filterDefinitionField;
342
+
343
+ private bool filterDefinitionFieldSet;
344
+
345
+ private string nameField;
346
+
347
+ private bool nameFieldSet;
348
+
349
+ private YesNoType suppressCustomActionsField;
350
+
351
+ private bool suppressCustomActionsFieldSet;
352
+
353
+ private ISchemaElement parentElement;
354
+
355
+ /// <summary>
356
+ /// Primary Key for HelpFilter.
357
+ /// </summary>
358
+ public string Id
359
+ {
360
+ get
361
+ {
362
+ return this.idField;
363
+ }
364
+ set
365
+ {
366
+ this.idFieldSet = true;
367
+ this.idField = value;
368
+ }
369
+ }
370
+
371
+ /// <summary>
372
+ /// Query String for Help Filter.
373
+ /// </summary>
374
+ public string FilterDefinition
375
+ {
376
+ get
377
+ {
378
+ return this.filterDefinitionField;
379
+ }
380
+ set
381
+ {
382
+ this.filterDefinitionFieldSet = true;
383
+ this.filterDefinitionField = value;
384
+ }
385
+ }
386
+
387
+ /// <summary>
388
+ /// Friendly name for Filter.
389
+ /// </summary>
390
+ public string Name
391
+ {
392
+ get
393
+ {
394
+ return this.nameField;
395
+ }
396
+ set
397
+ {
398
+ this.nameFieldSet = true;
399
+ this.nameField = value;
400
+ }
401
+ }
402
+
403
+ /// <summary>
404
+ /// Suppress linking Help registration custom actions. Help redistributable merge modules will be required. Use this when building a merge module.
405
+ /// </summary>
406
+ public YesNoType SuppressCustomActions
407
+ {
408
+ get
409
+ {
410
+ return this.suppressCustomActionsField;
411
+ }
412
+ set
413
+ {
414
+ this.suppressCustomActionsFieldSet = true;
415
+ this.suppressCustomActionsField = value;
416
+ }
417
+ }
418
+
419
+ public virtual ISchemaElement ParentElement
420
+ {
421
+ get
422
+ {
423
+ return this.parentElement;
424
+ }
425
+ set
426
+ {
427
+ this.parentElement = value;
428
+ }
429
+ }
430
+
431
+ /// <summary>
432
+ /// Processes this element and all child elements into an XmlWriter.
433
+ /// </summary>
434
+ public virtual void OutputXml(XmlWriter writer)
435
+ {
436
+ if ((null == writer))
437
+ {
438
+ throw new ArgumentNullException("writer");
439
+ }
440
+ writer.WriteStartElement("HelpFilter", "http://wixtoolset.org/schemas/v4/wxs/vs");
441
+ if (this.idFieldSet)
442
+ {
443
+ writer.WriteAttributeString("Id", this.idField);
444
+ }
445
+ if (this.filterDefinitionFieldSet)
446
+ {
447
+ writer.WriteAttributeString("FilterDefinition", this.filterDefinitionField);
448
+ }
449
+ if (this.nameFieldSet)
450
+ {
451
+ writer.WriteAttributeString("Name", this.nameField);
452
+ }
453
+ if (this.suppressCustomActionsFieldSet)
454
+ {
455
+ if ((this.suppressCustomActionsField == YesNoType.no))
456
+ {
457
+ writer.WriteAttributeString("SuppressCustomActions", "no");
458
+ }
459
+ if ((this.suppressCustomActionsField == YesNoType.yes))
460
+ {
461
+ writer.WriteAttributeString("SuppressCustomActions", "yes");
462
+ }
463
+ }
464
+ writer.WriteEndElement();
465
+ }
466
+
467
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
468
+ void ISetAttributes.SetAttribute(string name, string value)
469
+ {
470
+ if (String.IsNullOrEmpty(name))
471
+ {
472
+ throw new ArgumentNullException("name");
473
+ }
474
+ if (("Id" == name))
475
+ {
476
+ this.idField = value;
477
+ this.idFieldSet = true;
478
+ }
479
+ if (("FilterDefinition" == name))
480
+ {
481
+ this.filterDefinitionField = value;
482
+ this.filterDefinitionFieldSet = true;
483
+ }
484
+ if (("Name" == name))
485
+ {
486
+ this.nameField = value;
487
+ this.nameFieldSet = true;
488
+ }
489
+ if (("SuppressCustomActions" == name))
490
+ {
491
+ this.suppressCustomActionsField = Enums.ParseYesNoType(value);
492
+ this.suppressCustomActionsFieldSet = true;
493
+ }
494
+ }
495
+ }
496
+
497
+ /// <summary>
498
+ /// File for Help Namespace. The parent file is the key for HxS (Title) file.
499
+ /// </summary>
500
+ [GeneratedCode("XsdGen", "4.0.0.0")]
501
+ public class HelpFile : ISchemaElement, ISetAttributes
502
+ {
503
+
504
+ private string idField;
505
+
506
+ private bool idFieldSet;
507
+
508
+ private string attributeIndexField;
509
+
510
+ private bool attributeIndexFieldSet;
511
+
512
+ private string indexField;
513
+
514
+ private bool indexFieldSet;
515
+
516
+ private int languageField;
517
+
518
+ private bool languageFieldSet;
519
+
520
+ private string nameField;
521
+
522
+ private bool nameFieldSet;
523
+
524
+ private string sampleLocationField;
525
+
526
+ private bool sampleLocationFieldSet;
527
+
528
+ private string searchField;
529
+
530
+ private bool searchFieldSet;
531
+
532
+ private YesNoType suppressCustomActionsField;
533
+
534
+ private bool suppressCustomActionsFieldSet;
535
+
536
+ private ISchemaElement parentElement;
537
+
538
+ /// <summary>
539
+ /// Primary Key for HelpFile Table.
540
+ /// </summary>
541
+ public string Id
542
+ {
543
+ get
544
+ {
545
+ return this.idField;
546
+ }
547
+ set
548
+ {
549
+ this.idFieldSet = true;
550
+ this.idField = value;
551
+ }
552
+ }
553
+
554
+ /// <summary>
555
+ /// Key for HxR (Attributes) file.
556
+ /// </summary>
557
+ public string AttributeIndex
558
+ {
559
+ get
560
+ {
561
+ return this.attributeIndexField;
562
+ }
563
+ set
564
+ {
565
+ this.attributeIndexFieldSet = true;
566
+ this.attributeIndexField = value;
567
+ }
568
+ }
569
+
570
+ /// <summary>
571
+ /// Key for HxI (Index) file.
572
+ /// </summary>
573
+ public string Index
574
+ {
575
+ get
576
+ {
577
+ return this.indexField;
578
+ }
579
+ set
580
+ {
581
+ this.indexFieldSet = true;
582
+ this.indexField = value;
583
+ }
584
+ }
585
+
586
+ /// <summary>
587
+ /// Language ID for content file.
588
+ /// </summary>
589
+ public int Language
590
+ {
591
+ get
592
+ {
593
+ return this.languageField;
594
+ }
595
+ set
596
+ {
597
+ this.languageFieldSet = true;
598
+ this.languageField = value;
599
+ }
600
+ }
601
+
602
+ /// <summary>
603
+ /// Internal Microsoft Help ID for this HelpFile.
604
+ /// </summary>
605
+ public string Name
606
+ {
607
+ get
608
+ {
609
+ return this.nameField;
610
+ }
611
+ set
612
+ {
613
+ this.nameFieldSet = true;
614
+ this.nameField = value;
615
+ }
616
+ }
617
+
618
+ /// <summary>
619
+ /// Key for a file that is in the "root" of the samples directory for this HelpFile.
620
+ /// </summary>
621
+ public string SampleLocation
622
+ {
623
+ get
624
+ {
625
+ return this.sampleLocationField;
626
+ }
627
+ set
628
+ {
629
+ this.sampleLocationFieldSet = true;
630
+ this.sampleLocationField = value;
631
+ }
632
+ }
633
+
634
+ /// <summary>
635
+ /// Key for HxQ (Query) file.
636
+ /// </summary>
637
+ public string Search
638
+ {
639
+ get
640
+ {
641
+ return this.searchField;
642
+ }
643
+ set
644
+ {
645
+ this.searchFieldSet = true;
646
+ this.searchField = value;
647
+ }
648
+ }
649
+
650
+ /// <summary>
651
+ /// Suppress linking Help registration custom actions. Help redistributable merge modules will be required. Use this when building a merge module.
652
+ /// </summary>
653
+ public YesNoType SuppressCustomActions
654
+ {
655
+ get
656
+ {
657
+ return this.suppressCustomActionsField;
658
+ }
659
+ set
660
+ {
661
+ this.suppressCustomActionsFieldSet = true;
662
+ this.suppressCustomActionsField = value;
663
+ }
664
+ }
665
+
666
+ public virtual ISchemaElement ParentElement
667
+ {
668
+ get
669
+ {
670
+ return this.parentElement;
671
+ }
672
+ set
673
+ {
674
+ this.parentElement = value;
675
+ }
676
+ }
677
+
678
+ /// <summary>
679
+ /// Processes this element and all child elements into an XmlWriter.
680
+ /// </summary>
681
+ [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
682
+ public virtual void OutputXml(XmlWriter writer)
683
+ {
684
+ if ((null == writer))
685
+ {
686
+ throw new ArgumentNullException("writer");
687
+ }
688
+ writer.WriteStartElement("HelpFile", "http://wixtoolset.org/schemas/v4/wxs/vs");
689
+ if (this.idFieldSet)
690
+ {
691
+ writer.WriteAttributeString("Id", this.idField);
692
+ }
693
+ if (this.attributeIndexFieldSet)
694
+ {
695
+ writer.WriteAttributeString("AttributeIndex", this.attributeIndexField);
696
+ }
697
+ if (this.indexFieldSet)
698
+ {
699
+ writer.WriteAttributeString("Index", this.indexField);
700
+ }
701
+ if (this.languageFieldSet)
702
+ {
703
+ writer.WriteAttributeString("Language", this.languageField.ToString(CultureInfo.InvariantCulture));
704
+ }
705
+ if (this.nameFieldSet)
706
+ {
707
+ writer.WriteAttributeString("Name", this.nameField);
708
+ }
709
+ if (this.sampleLocationFieldSet)
710
+ {
711
+ writer.WriteAttributeString("SampleLocation", this.sampleLocationField);
712
+ }
713
+ if (this.searchFieldSet)
714
+ {
715
+ writer.WriteAttributeString("Search", this.searchField);
716
+ }
717
+ if (this.suppressCustomActionsFieldSet)
718
+ {
719
+ if ((this.suppressCustomActionsField == YesNoType.no))
720
+ {
721
+ writer.WriteAttributeString("SuppressCustomActions", "no");
722
+ }
723
+ if ((this.suppressCustomActionsField == YesNoType.yes))
724
+ {
725
+ writer.WriteAttributeString("SuppressCustomActions", "yes");
726
+ }
727
+ }
728
+ writer.WriteEndElement();
729
+ }
730
+
731
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
732
+ [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
733
+ void ISetAttributes.SetAttribute(string name, string value)
734
+ {
735
+ if (String.IsNullOrEmpty(name))
736
+ {
737
+ throw new ArgumentNullException("name");
738
+ }
739
+ if (("Id" == name))
740
+ {
741
+ this.idField = value;
742
+ this.idFieldSet = true;
743
+ }
744
+ if (("AttributeIndex" == name))
745
+ {
746
+ this.attributeIndexField = value;
747
+ this.attributeIndexFieldSet = true;
748
+ }
749
+ if (("Index" == name))
750
+ {
751
+ this.indexField = value;
752
+ this.indexFieldSet = true;
753
+ }
754
+ if (("Language" == name))
755
+ {
756
+ this.languageField = Convert.ToInt32(value, CultureInfo.InvariantCulture);
757
+ this.languageFieldSet = true;
758
+ }
759
+ if (("Name" == name))
760
+ {
761
+ this.nameField = value;
762
+ this.nameFieldSet = true;
763
+ }
764
+ if (("SampleLocation" == name))
765
+ {
766
+ this.sampleLocationField = value;
767
+ this.sampleLocationFieldSet = true;
768
+ }
769
+ if (("Search" == name))
770
+ {
771
+ this.searchField = value;
772
+ this.searchFieldSet = true;
773
+ }
774
+ if (("SuppressCustomActions" == name))
775
+ {
776
+ this.suppressCustomActionsField = Enums.ParseYesNoType(value);
777
+ this.suppressCustomActionsFieldSet = true;
778
+ }
779
+ }
780
+ }
781
+
782
+ /// <summary>
783
+ /// Plugin for Help Namespace.
784
+ /// </summary>
785
+ [GeneratedCode("XsdGen", "4.0.0.0")]
786
+ public class PlugCollectionInto : ISchemaElement, ISetAttributes
787
+ {
788
+
789
+ private string attributesField;
790
+
791
+ private bool attributesFieldSet;
792
+
793
+ private string tableOfContentsField;
794
+
795
+ private bool tableOfContentsFieldSet;
796
+
797
+ private string targetCollectionField;
798
+
799
+ private bool targetCollectionFieldSet;
800
+
801
+ private string targetTableOfContentsField;
802
+
803
+ private bool targetTableOfContentsFieldSet;
804
+
805
+ private string targetFeatureField;
806
+
807
+ private bool targetFeatureFieldSet;
808
+
809
+ private YesNoType suppressExternalNamespacesField;
810
+
811
+ private bool suppressExternalNamespacesFieldSet;
812
+
813
+ private ISchemaElement parentElement;
814
+
815
+ /// <summary>
816
+ /// Key for HxA (Attributes) file of child namespace.
817
+ /// </summary>
818
+ public string Attributes
819
+ {
820
+ get
821
+ {
822
+ return this.attributesField;
823
+ }
824
+ set
825
+ {
826
+ this.attributesFieldSet = true;
827
+ this.attributesField = value;
828
+ }
829
+ }
830
+
831
+ /// <summary>
832
+ /// Key for HxT file of child namespace.
833
+ /// </summary>
834
+ public string TableOfContents
835
+ {
836
+ get
837
+ {
838
+ return this.tableOfContentsField;
839
+ }
840
+ set
841
+ {
842
+ this.tableOfContentsFieldSet = true;
843
+ this.tableOfContentsField = value;
844
+ }
845
+ }
846
+
847
+ /// <summary>
848
+ /// Foriegn Key into HelpNamespace table for the parent namespace into which the child will be inserted.
849
+ /// The following special keys can be used to plug into external namespaces defined outside of the installer.
850
+ /// MS_VSIPCC_v80 : Visual Studio 2005
851
+ /// MS.VSIPCC.v90 : Visual Studio 2008
852
+ /// </summary>
853
+ public string TargetCollection
854
+ {
855
+ get
856
+ {
857
+ return this.targetCollectionField;
858
+ }
859
+ set
860
+ {
861
+ this.targetCollectionFieldSet = true;
862
+ this.targetCollectionField = value;
863
+ }
864
+ }
865
+
866
+ /// <summary>
867
+ /// Key for HxT file of parent namespace that now includes the new child namespace.
868
+ /// </summary>
869
+ public string TargetTableOfContents
870
+ {
871
+ get
872
+ {
873
+ return this.targetTableOfContentsField;
874
+ }
875
+ set
876
+ {
877
+ this.targetTableOfContentsFieldSet = true;
878
+ this.targetTableOfContentsField = value;
879
+ }
880
+ }
881
+
882
+ /// <summary>
883
+ /// Key for the feature parent of this help collection. Required only when plugging into external namespaces.
884
+ /// </summary>
885
+ public string TargetFeature
886
+ {
887
+ get
888
+ {
889
+ return this.targetFeatureField;
890
+ }
891
+ set
892
+ {
893
+ this.targetFeatureFieldSet = true;
894
+ this.targetFeatureField = value;
895
+ }
896
+ }
897
+
898
+ /// <summary>
899
+ /// Suppress linking Visual Studio Help namespaces. Help redistributable merge modules will be required. Use this when building a merge module.
900
+ /// </summary>
901
+ public YesNoType SuppressExternalNamespaces
902
+ {
903
+ get
904
+ {
905
+ return this.suppressExternalNamespacesField;
906
+ }
907
+ set
908
+ {
909
+ this.suppressExternalNamespacesFieldSet = true;
910
+ this.suppressExternalNamespacesField = value;
911
+ }
912
+ }
913
+
914
+ public virtual ISchemaElement ParentElement
915
+ {
916
+ get
917
+ {
918
+ return this.parentElement;
919
+ }
920
+ set
921
+ {
922
+ this.parentElement = value;
923
+ }
924
+ }
925
+
926
+ /// <summary>
927
+ /// Processes this element and all child elements into an XmlWriter.
928
+ /// </summary>
929
+ public virtual void OutputXml(XmlWriter writer)
930
+ {
931
+ if ((null == writer))
932
+ {
933
+ throw new ArgumentNullException("writer");
934
+ }
935
+ writer.WriteStartElement("PlugCollectionInto", "http://wixtoolset.org/schemas/v4/wxs/vs");
936
+ if (this.attributesFieldSet)
937
+ {
938
+ writer.WriteAttributeString("Attributes", this.attributesField);
939
+ }
940
+ if (this.tableOfContentsFieldSet)
941
+ {
942
+ writer.WriteAttributeString("TableOfContents", this.tableOfContentsField);
943
+ }
944
+ if (this.targetCollectionFieldSet)
945
+ {
946
+ writer.WriteAttributeString("TargetCollection", this.targetCollectionField);
947
+ }
948
+ if (this.targetTableOfContentsFieldSet)
949
+ {
950
+ writer.WriteAttributeString("TargetTableOfContents", this.targetTableOfContentsField);
951
+ }
952
+ if (this.targetFeatureFieldSet)
953
+ {
954
+ writer.WriteAttributeString("TargetFeature", this.targetFeatureField);
955
+ }
956
+ if (this.suppressExternalNamespacesFieldSet)
957
+ {
958
+ if ((this.suppressExternalNamespacesField == YesNoType.no))
959
+ {
960
+ writer.WriteAttributeString("SuppressExternalNamespaces", "no");
961
+ }
962
+ if ((this.suppressExternalNamespacesField == YesNoType.yes))
963
+ {
964
+ writer.WriteAttributeString("SuppressExternalNamespaces", "yes");
965
+ }
966
+ }
967
+ writer.WriteEndElement();
968
+ }
969
+
970
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
971
+ void ISetAttributes.SetAttribute(string name, string value)
972
+ {
973
+ if (String.IsNullOrEmpty(name))
974
+ {
975
+ throw new ArgumentNullException("name");
976
+ }
977
+ if (("Attributes" == name))
978
+ {
979
+ this.attributesField = value;
980
+ this.attributesFieldSet = true;
981
+ }
982
+ if (("TableOfContents" == name))
983
+ {
984
+ this.tableOfContentsField = value;
985
+ this.tableOfContentsFieldSet = true;
986
+ }
987
+ if (("TargetCollection" == name))
988
+ {
989
+ this.targetCollectionField = value;
990
+ this.targetCollectionFieldSet = true;
991
+ }
992
+ if (("TargetTableOfContents" == name))
993
+ {
994
+ this.targetTableOfContentsField = value;
995
+ this.targetTableOfContentsFieldSet = true;
996
+ }
997
+ if (("TargetFeature" == name))
998
+ {
999
+ this.targetFeatureField = value;
1000
+ this.targetFeatureFieldSet = true;
1001
+ }
1002
+ if (("SuppressExternalNamespaces" == name))
1003
+ {
1004
+ this.suppressExternalNamespacesField = Enums.ParseYesNoType(value);
1005
+ this.suppressExternalNamespacesFieldSet = true;
1006
+ }
1007
+ }
1008
+ }
1009
+
1010
+ /// <summary>
1011
+ /// Create a reference to a HelpFile element in another Fragment.
1012
+ /// </summary>
1013
+ [GeneratedCode("XsdGen", "4.0.0.0")]
1014
+ public class HelpFileRef : ISchemaElement, ISetAttributes
1015
+ {
1016
+
1017
+ private string idField;
1018
+
1019
+ private bool idFieldSet;
1020
+
1021
+ private ISchemaElement parentElement;
1022
+
1023
+ /// <summary>
1024
+ /// Primary Key for HelpFile Table.
1025
+ /// </summary>
1026
+ public string Id
1027
+ {
1028
+ get
1029
+ {
1030
+ return this.idField;
1031
+ }
1032
+ set
1033
+ {
1034
+ this.idFieldSet = true;
1035
+ this.idField = value;
1036
+ }
1037
+ }
1038
+
1039
+ public virtual ISchemaElement ParentElement
1040
+ {
1041
+ get
1042
+ {
1043
+ return this.parentElement;
1044
+ }
1045
+ set
1046
+ {
1047
+ this.parentElement = value;
1048
+ }
1049
+ }
1050
+
1051
+ /// <summary>
1052
+ /// Processes this element and all child elements into an XmlWriter.
1053
+ /// </summary>
1054
+ public virtual void OutputXml(XmlWriter writer)
1055
+ {
1056
+ if ((null == writer))
1057
+ {
1058
+ throw new ArgumentNullException("writer");
1059
+ }
1060
+ writer.WriteStartElement("HelpFileRef", "http://wixtoolset.org/schemas/v4/wxs/vs");
1061
+ if (this.idFieldSet)
1062
+ {
1063
+ writer.WriteAttributeString("Id", this.idField);
1064
+ }
1065
+ writer.WriteEndElement();
1066
+ }
1067
+
1068
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
1069
+ void ISetAttributes.SetAttribute(string name, string value)
1070
+ {
1071
+ if (String.IsNullOrEmpty(name))
1072
+ {
1073
+ throw new ArgumentNullException("name");
1074
+ }
1075
+ if (("Id" == name))
1076
+ {
1077
+ this.idField = value;
1078
+ this.idFieldSet = true;
1079
+ }
1080
+ }
1081
+ }
1082
+
1083
+ /// <summary>
1084
+ /// Create a reference to a HelpFile element in another Fragment.
1085
+ /// </summary>
1086
+ [GeneratedCode("XsdGen", "4.0.0.0")]
1087
+ public class HelpFilterRef : ISchemaElement, ISetAttributes
1088
+ {
1089
+
1090
+ private string idField;
1091
+
1092
+ private bool idFieldSet;
1093
+
1094
+ private ISchemaElement parentElement;
1095
+
1096
+ /// <summary>
1097
+ /// Primary Key for HelpFilter.
1098
+ /// </summary>
1099
+ public string Id
1100
+ {
1101
+ get
1102
+ {
1103
+ return this.idField;
1104
+ }
1105
+ set
1106
+ {
1107
+ this.idFieldSet = true;
1108
+ this.idField = value;
1109
+ }
1110
+ }
1111
+
1112
+ public virtual ISchemaElement ParentElement
1113
+ {
1114
+ get
1115
+ {
1116
+ return this.parentElement;
1117
+ }
1118
+ set
1119
+ {
1120
+ this.parentElement = value;
1121
+ }
1122
+ }
1123
+
1124
+ /// <summary>
1125
+ /// Processes this element and all child elements into an XmlWriter.
1126
+ /// </summary>
1127
+ public virtual void OutputXml(XmlWriter writer)
1128
+ {
1129
+ if ((null == writer))
1130
+ {
1131
+ throw new ArgumentNullException("writer");
1132
+ }
1133
+ writer.WriteStartElement("HelpFilterRef", "http://wixtoolset.org/schemas/v4/wxs/vs");
1134
+ if (this.idFieldSet)
1135
+ {
1136
+ writer.WriteAttributeString("Id", this.idField);
1137
+ }
1138
+ writer.WriteEndElement();
1139
+ }
1140
+
1141
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
1142
+ void ISetAttributes.SetAttribute(string name, string value)
1143
+ {
1144
+ if (String.IsNullOrEmpty(name))
1145
+ {
1146
+ throw new ArgumentNullException("name");
1147
+ }
1148
+ if (("Id" == name))
1149
+ {
1150
+ this.idField = value;
1151
+ this.idFieldSet = true;
1152
+ }
1153
+ }
1154
+ }
1155
+
1156
+ /// <summary>
1157
+ /// Create a reference to a HelpCollection element in another Fragment.
1158
+ /// </summary>
1159
+ [GeneratedCode("XsdGen", "4.0.0.0")]
1160
+ public class HelpCollectionRef : IParentElement, ICreateChildren, ISchemaElement, ISetAttributes
1161
+ {
1162
+
1163
+ private ElementCollection children;
1164
+
1165
+ private string idField;
1166
+
1167
+ private bool idFieldSet;
1168
+
1169
+ private ISchemaElement parentElement;
1170
+
1171
+ public HelpCollectionRef()
1172
+ {
1173
+ ElementCollection childCollection0 = new ElementCollection(ElementCollection.CollectionType.Choice);
1174
+ childCollection0.AddItem(new ElementCollection.ChoiceItem(typeof(HelpFileRef)));
1175
+ this.children = childCollection0;
1176
+ }
1177
+
1178
+ public virtual IEnumerable Children
1179
+ {
1180
+ get
1181
+ {
1182
+ return this.children;
1183
+ }
1184
+ }
1185
+
1186
+ [SuppressMessage("Microsoft.Design", "CA1043:UseIntegralOrStringArgumentForIndexers")]
1187
+ public virtual IEnumerable this[System.Type childType]
1188
+ {
1189
+ get
1190
+ {
1191
+ return this.children.Filter(childType);
1192
+ }
1193
+ }
1194
+
1195
+ /// <summary>
1196
+ /// Primary Key for HelpNamespace Table.
1197
+ /// </summary>
1198
+ public string Id
1199
+ {
1200
+ get
1201
+ {
1202
+ return this.idField;
1203
+ }
1204
+ set
1205
+ {
1206
+ this.idFieldSet = true;
1207
+ this.idField = value;
1208
+ }
1209
+ }
1210
+
1211
+ public virtual ISchemaElement ParentElement
1212
+ {
1213
+ get
1214
+ {
1215
+ return this.parentElement;
1216
+ }
1217
+ set
1218
+ {
1219
+ this.parentElement = value;
1220
+ }
1221
+ }
1222
+
1223
+ public virtual void AddChild(ISchemaElement child)
1224
+ {
1225
+ if ((null == child))
1226
+ {
1227
+ throw new ArgumentNullException("child");
1228
+ }
1229
+ this.children.AddElement(child);
1230
+ child.ParentElement = this;
1231
+ }
1232
+
1233
+ public virtual void RemoveChild(ISchemaElement child)
1234
+ {
1235
+ if ((null == child))
1236
+ {
1237
+ throw new ArgumentNullException("child");
1238
+ }
1239
+ this.children.RemoveElement(child);
1240
+ child.ParentElement = null;
1241
+ }
1242
+
1243
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
1244
+ ISchemaElement ICreateChildren.CreateChild(string childName)
1245
+ {
1246
+ if (String.IsNullOrEmpty(childName))
1247
+ {
1248
+ throw new ArgumentNullException("childName");
1249
+ }
1250
+ ISchemaElement childValue = null;
1251
+ if (("HelpFileRef" == childName))
1252
+ {
1253
+ childValue = new HelpFileRef();
1254
+ }
1255
+ if ((null == childValue))
1256
+ {
1257
+ throw new InvalidOperationException(String.Concat(childName, " is not a valid child name."));
1258
+ }
1259
+ return childValue;
1260
+ }
1261
+
1262
+ /// <summary>
1263
+ /// Processes this element and all child elements into an XmlWriter.
1264
+ /// </summary>
1265
+ public virtual void OutputXml(XmlWriter writer)
1266
+ {
1267
+ if ((null == writer))
1268
+ {
1269
+ throw new ArgumentNullException("writer");
1270
+ }
1271
+ writer.WriteStartElement("HelpCollectionRef", "http://wixtoolset.org/schemas/v4/wxs/vs");
1272
+ if (this.idFieldSet)
1273
+ {
1274
+ writer.WriteAttributeString("Id", this.idField);
1275
+ }
1276
+ for (IEnumerator enumerator = this.children.GetEnumerator(); enumerator.MoveNext(); )
1277
+ {
1278
+ ISchemaElement childElement = ((ISchemaElement)(enumerator.Current));
1279
+ childElement.OutputXml(writer);
1280
+ }
1281
+ writer.WriteEndElement();
1282
+ }
1283
+
1284
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
1285
+ void ISetAttributes.SetAttribute(string name, string value)
1286
+ {
1287
+ if (String.IsNullOrEmpty(name))
1288
+ {
1289
+ throw new ArgumentNullException("name");
1290
+ }
1291
+ if (("Id" == name))
1292
+ {
1293
+ this.idField = value;
1294
+ this.idFieldSet = true;
1295
+ }
1296
+ }
1297
+ }
1298
+
1299
+ /// <summary>
1300
+ /// This element provides the metdata required to install/uninstall a file as
1301
+ /// a VSIX Package. The VSIX package file will be installed as part of the MSI
1302
+ /// then passed to the VSIX installer to install the VSIX package. To avoid the
1303
+ /// duplication, simply use the MSI to install the VSIX package itself.
1304
+ /// </summary>
1305
+ [GeneratedCode("XsdGen", "4.0.0.0")]
1306
+ public class VsixPackage : ISchemaElement, ISetAttributes
1307
+ {
1308
+
1309
+ private string fileField;
1310
+
1311
+ private bool fileFieldSet;
1312
+
1313
+ private string packageIdField;
1314
+
1315
+ private bool packageIdFieldSet;
1316
+
1317
+ private YesNoType permanentField;
1318
+
1319
+ private bool permanentFieldSet;
1320
+
1321
+ private string targetField;
1322
+
1323
+ private bool targetFieldSet;
1324
+
1325
+ private string targetVersionField;
1326
+
1327
+ private bool targetVersionFieldSet;
1328
+
1329
+ private YesNoType vitalField;
1330
+
1331
+ private bool vitalFieldSet;
1332
+
1333
+ private string vsixInstallerPathPropertyField;
1334
+
1335
+ private bool vsixInstallerPathPropertyFieldSet;
1336
+
1337
+ private ISchemaElement parentElement;
1338
+
1339
+ /// <summary>
1340
+ /// Reference to file identifer. This attribute is required when the element is not a
1341
+ /// child of a File element and is invalid when the element is a child of the File element.
1342
+ /// </summary>
1343
+ public string File
1344
+ {
1345
+ get
1346
+ {
1347
+ return this.fileField;
1348
+ }
1349
+ set
1350
+ {
1351
+ this.fileFieldSet = true;
1352
+ this.fileField = value;
1353
+ }
1354
+ }
1355
+
1356
+ /// <summary>
1357
+ /// Identity of the VSIX package per its internal manifest. If this value is not correct
1358
+ /// the VSIX package will not correctly uninstall.
1359
+ /// </summary>
1360
+ public string PackageId
1361
+ {
1362
+ get
1363
+ {
1364
+ return this.packageIdField;
1365
+ }
1366
+ set
1367
+ {
1368
+ this.packageIdFieldSet = true;
1369
+ this.packageIdField = value;
1370
+ }
1371
+ }
1372
+
1373
+ /// <summary>
1374
+ /// Indicates whether the VSIX package is uninstalled when the parent Component is uninstalled.
1375
+ /// The default is 'no'.
1376
+ /// </summary>
1377
+ public YesNoType Permanent
1378
+ {
1379
+ get
1380
+ {
1381
+ return this.permanentField;
1382
+ }
1383
+ set
1384
+ {
1385
+ this.permanentFieldSet = true;
1386
+ this.permanentField = value;
1387
+ }
1388
+ }
1389
+
1390
+ /// <summary>
1391
+ /// Specifies the SKU of Visual Studio in which to register the extension. If no target
1392
+ /// is specified the extension is registered with all installed SKUs. If the Target
1393
+ /// attribute is specified the TargetVersion attribute must also be specified. The
1394
+ /// following is a list of known Visual Studio targets: integratedShell, professional,
1395
+ /// premium, ultimate, vbExpress, vcExpress, vcsExpress, vwdExpress
1396
+ /// </summary>
1397
+ public string Target
1398
+ {
1399
+ get
1400
+ {
1401
+ return this.targetField;
1402
+ }
1403
+ set
1404
+ {
1405
+ this.targetFieldSet = true;
1406
+ this.targetField = value;
1407
+ }
1408
+ }
1409
+
1410
+ /// <summary>
1411
+ /// Specifies the version of Visual Studio in which to register the extension. This attribute
1412
+ /// is required if the Target attribute is specified.
1413
+ /// </summary>
1414
+ public string TargetVersion
1415
+ {
1416
+ get
1417
+ {
1418
+ return this.targetVersionField;
1419
+ }
1420
+ set
1421
+ {
1422
+ this.targetVersionFieldSet = true;
1423
+ this.targetVersionField = value;
1424
+ }
1425
+ }
1426
+
1427
+ /// <summary>
1428
+ /// Indicates whether failure to install the VSIX package causes the installation to rollback.
1429
+ /// The default is 'yes'.
1430
+ /// </summary>
1431
+ public YesNoType Vital
1432
+ {
1433
+ get
1434
+ {
1435
+ return this.vitalField;
1436
+ }
1437
+ set
1438
+ {
1439
+ this.vitalFieldSet = true;
1440
+ this.vitalField = value;
1441
+ }
1442
+ }
1443
+
1444
+ /// <summary>
1445
+ /// Optional reference to a Property element that contains the path to the VsixInstaller.exe.
1446
+ /// By default, the latest VsixInstaller.exe on the machine will be used to install the VSIX
1447
+ /// package. It is highly recommended that this attribute is *not* used.
1448
+ /// </summary>
1449
+ public string VsixInstallerPathProperty
1450
+ {
1451
+ get
1452
+ {
1453
+ return this.vsixInstallerPathPropertyField;
1454
+ }
1455
+ set
1456
+ {
1457
+ this.vsixInstallerPathPropertyFieldSet = true;
1458
+ this.vsixInstallerPathPropertyField = value;
1459
+ }
1460
+ }
1461
+
1462
+ public virtual ISchemaElement ParentElement
1463
+ {
1464
+ get
1465
+ {
1466
+ return this.parentElement;
1467
+ }
1468
+ set
1469
+ {
1470
+ this.parentElement = value;
1471
+ }
1472
+ }
1473
+
1474
+ /// <summary>
1475
+ /// Processes this element and all child elements into an XmlWriter.
1476
+ /// </summary>
1477
+ [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
1478
+ public virtual void OutputXml(XmlWriter writer)
1479
+ {
1480
+ if ((null == writer))
1481
+ {
1482
+ throw new ArgumentNullException("writer");
1483
+ }
1484
+ writer.WriteStartElement("VsixPackage", "http://wixtoolset.org/schemas/v4/wxs/vs");
1485
+ if (this.fileFieldSet)
1486
+ {
1487
+ writer.WriteAttributeString("File", this.fileField);
1488
+ }
1489
+ if (this.packageIdFieldSet)
1490
+ {
1491
+ writer.WriteAttributeString("PackageId", this.packageIdField);
1492
+ }
1493
+ if (this.permanentFieldSet)
1494
+ {
1495
+ if ((this.permanentField == YesNoType.no))
1496
+ {
1497
+ writer.WriteAttributeString("Permanent", "no");
1498
+ }
1499
+ if ((this.permanentField == YesNoType.yes))
1500
+ {
1501
+ writer.WriteAttributeString("Permanent", "yes");
1502
+ }
1503
+ }
1504
+ if (this.targetFieldSet)
1505
+ {
1506
+ writer.WriteAttributeString("Target", this.targetField);
1507
+ }
1508
+ if (this.targetVersionFieldSet)
1509
+ {
1510
+ writer.WriteAttributeString("TargetVersion", this.targetVersionField);
1511
+ }
1512
+ if (this.vitalFieldSet)
1513
+ {
1514
+ if ((this.vitalField == YesNoType.no))
1515
+ {
1516
+ writer.WriteAttributeString("Vital", "no");
1517
+ }
1518
+ if ((this.vitalField == YesNoType.yes))
1519
+ {
1520
+ writer.WriteAttributeString("Vital", "yes");
1521
+ }
1522
+ }
1523
+ if (this.vsixInstallerPathPropertyFieldSet)
1524
+ {
1525
+ writer.WriteAttributeString("VsixInstallerPathProperty", this.vsixInstallerPathPropertyField);
1526
+ }
1527
+ writer.WriteEndElement();
1528
+ }
1529
+
1530
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
1531
+ void ISetAttributes.SetAttribute(string name, string value)
1532
+ {
1533
+ if (String.IsNullOrEmpty(name))
1534
+ {
1535
+ throw new ArgumentNullException("name");
1536
+ }
1537
+ if (("File" == name))
1538
+ {
1539
+ this.fileField = value;
1540
+ this.fileFieldSet = true;
1541
+ }
1542
+ if (("PackageId" == name))
1543
+ {
1544
+ this.packageIdField = value;
1545
+ this.packageIdFieldSet = true;
1546
+ }
1547
+ if (("Permanent" == name))
1548
+ {
1549
+ this.permanentField = Enums.ParseYesNoType(value);
1550
+ this.permanentFieldSet = true;
1551
+ }
1552
+ if (("Target" == name))
1553
+ {
1554
+ this.targetField = value;
1555
+ this.targetFieldSet = true;
1556
+ }
1557
+ if (("TargetVersion" == name))
1558
+ {
1559
+ this.targetVersionField = value;
1560
+ this.targetVersionFieldSet = true;
1561
+ }
1562
+ if (("Vital" == name))
1563
+ {
1564
+ this.vitalField = Enums.ParseYesNoType(value);
1565
+ this.vitalFieldSet = true;
1566
+ }
1567
+ if (("VsixInstallerPathProperty" == name))
1568
+ {
1569
+ this.vsixInstallerPathPropertyField = value;
1570
+ this.vsixInstallerPathPropertyFieldSet = true;
1571
+ }
1572
+ }
1573
+ }
1574
+}
src/heat/Serialize/wix.cs
new
+57740
@@ -0,0 +1,57740 @@
1
+//------------------------------------------------------------------------------
2
+// <auto-generated>
3
+// This code was generated by a tool.
4
+// Runtime Version:4.0.30319.42000
5
+//
6
+// Changes to this file may cause incorrect behavior and will be lost if
7
+// the code is regenerated.
8
+// </auto-generated>
9
+//------------------------------------------------------------------------------
10
+
11
+#pragma warning disable 1591 // TODO: add documentation
12
+namespace WixToolset.Harvesters.Serialize
13
+{
14
+ using System;
15
+ using System.CodeDom.Compiler;
16
+ using System.Collections;
17
+ using System.Diagnostics.CodeAnalysis;
18
+ using System.Globalization;
19
+ using System.Xml;
20
+
21
+ /// <summary>
22
+ /// Values of this type will either be "attached" or "detached".
23
+ /// </summary>
24
+ [GeneratedCode("WixBuildTools.XsdGen", "4.0.0.0")]
25
+ public enum BurnContainerType
26
+ {
27
+
28
+ IllegalValue = int.MaxValue,
29
+
30
+ NotSet = -1,
31
+
32
+ attached,
33
+
34
+ detached,
35
+ }
36
+
37
+ [GeneratedCode("WixBuildTools.XsdGen", "4.0.0.0")]
38
+ public class Enums
39
+ {
40
+
41
+ /// <summary>
42
+ /// Parses a BurnContainerType from a string.
43
+ /// </summary>
44
+ public static BurnContainerType ParseBurnContainerType(string value)
45
+ {
46
+ BurnContainerType parsedValue;
47
+ Enums.TryParseBurnContainerType(value, out parsedValue);
48
+ return parsedValue;
49
+ }
50
+
51
+ /// <summary>
52
+ /// Tries to parse a BurnContainerType from a string.
53
+ /// </summary>
54
+ public static bool TryParseBurnContainerType(string value, out BurnContainerType parsedValue)
55
+ {
56
+ parsedValue = BurnContainerType.NotSet;
57
+ if (string.IsNullOrEmpty(value))
58
+ {
59
+ return false;
60
+ }
61
+ if (("attached" == value))
62
+ {
63
+ parsedValue = BurnContainerType.attached;
64
+ }
65
+ else
66
+ {
67
+ if (("detached" == value))
68
+ {
69
+ parsedValue = BurnContainerType.detached;
70
+ }
71
+ else
72
+ {
73
+ parsedValue = BurnContainerType.IllegalValue;
74
+ return false;
75
+ }
76
+ }
77
+ return true;
78
+ }
79
+
80
+ /// <summary>
81
+ /// Parses a BurnExeProtocolType from a string.
82
+ /// </summary>
83
+ public static BurnExeProtocolType ParseBurnExeProtocolType(string value)
84
+ {
85
+ BurnExeProtocolType parsedValue;
86
+ Enums.TryParseBurnExeProtocolType(value, out parsedValue);
87
+ return parsedValue;
88
+ }
89
+
90
+ /// <summary>
91
+ /// Tries to parse a BurnExeProtocolType from a string.
92
+ /// </summary>
93
+ public static bool TryParseBurnExeProtocolType(string value, out BurnExeProtocolType parsedValue)
94
+ {
95
+ parsedValue = BurnExeProtocolType.NotSet;
96
+ if (string.IsNullOrEmpty(value))
97
+ {
98
+ return false;
99
+ }
100
+ if (("none" == value))
101
+ {
102
+ parsedValue = BurnExeProtocolType.none;
103
+ }
104
+ else
105
+ {
106
+ if (("burn" == value))
107
+ {
108
+ parsedValue = BurnExeProtocolType.burn;
109
+ }
110
+ else
111
+ {
112
+ if (("netfx4" == value))
113
+ {
114
+ parsedValue = BurnExeProtocolType.netfx4;
115
+ }
116
+ else
117
+ {
118
+ parsedValue = BurnExeProtocolType.IllegalValue;
119
+ return false;
120
+ }
121
+ }
122
+ }
123
+ return true;
124
+ }
125
+
126
+ /// <summary>
127
+ /// Parses a YesNoType from a string.
128
+ /// </summary>
129
+ public static YesNoType ParseYesNoType(string value)
130
+ {
131
+ YesNoType parsedValue;
132
+ Enums.TryParseYesNoType(value, out parsedValue);
133
+ return parsedValue;
134
+ }
135
+
136
+ /// <summary>
137
+ /// Tries to parse a YesNoType from a string.
138
+ /// </summary>
139
+ public static bool TryParseYesNoType(string value, out YesNoType parsedValue)
140
+ {
141
+ parsedValue = YesNoType.NotSet;
142
+ if (string.IsNullOrEmpty(value))
143
+ {
144
+ return false;
145
+ }
146
+ if (("no" == value))
147
+ {
148
+ parsedValue = YesNoType.no;
149
+ }
150
+ else
151
+ {
152
+ if (("yes" == value))
153
+ {
154
+ parsedValue = YesNoType.yes;
155
+ }
156
+ else
157
+ {
158
+ parsedValue = YesNoType.IllegalValue;
159
+ return false;
160
+ }
161
+ }
162
+ return true;
163
+ }
164
+
165
+ /// <summary>
166
+ /// Parses a YesNoButtonType from a string.
167
+ /// </summary>
168
+ public static YesNoButtonType ParseYesNoButtonType(string value)
169
+ {
170
+ YesNoButtonType parsedValue;
171
+ Enums.TryParseYesNoButtonType(value, out parsedValue);
172
+ return parsedValue;
173
+ }
174
+
175
+ /// <summary>
176
+ /// Tries to parse a YesNoButtonType from a string.
177
+ /// </summary>
178
+ public static bool TryParseYesNoButtonType(string value, out YesNoButtonType parsedValue)
179
+ {
180
+ parsedValue = YesNoButtonType.NotSet;
181
+ if (string.IsNullOrEmpty(value))
182
+ {
183
+ return false;
184
+ }
185
+ if (("no" == value))
186
+ {
187
+ parsedValue = YesNoButtonType.no;
188
+ }
189
+ else
190
+ {
191
+ if (("yes" == value))
192
+ {
193
+ parsedValue = YesNoButtonType.yes;
194
+ }
195
+ else
196
+ {
197
+ if (("button" == value))
198
+ {
199
+ parsedValue = YesNoButtonType.button;
200
+ }
201
+ else
202
+ {
203
+ parsedValue = YesNoButtonType.IllegalValue;
204
+ return false;
205
+ }
206
+ }
207
+ }
208
+ return true;
209
+ }
210
+
211
+ /// <summary>
212
+ /// Parses a YesNoDefaultType from a string.
213
+ /// </summary>
214
+ public static YesNoDefaultType ParseYesNoDefaultType(string value)
215
+ {
216
+ YesNoDefaultType parsedValue;
217
+ Enums.TryParseYesNoDefaultType(value, out parsedValue);
218
+ return parsedValue;
219
+ }
220
+
221
+ /// <summary>
222
+ /// Tries to parse a YesNoDefaultType from a string.
223
+ /// </summary>
224
+ public static bool TryParseYesNoDefaultType(string value, out YesNoDefaultType parsedValue)
225
+ {
226
+ parsedValue = YesNoDefaultType.NotSet;
227
+ if (string.IsNullOrEmpty(value))
228
+ {
229
+ return false;
230
+ }
231
+ if (("default" == value))
232
+ {
233
+ parsedValue = YesNoDefaultType.@default;
234
+ }
235
+ else
236
+ {
237
+ if (("no" == value))
238
+ {
239
+ parsedValue = YesNoDefaultType.no;
240
+ }
241
+ else
242
+ {
243
+ if (("yes" == value))
244
+ {
245
+ parsedValue = YesNoDefaultType.yes;
246
+ }
247
+ else
248
+ {
249
+ parsedValue = YesNoDefaultType.IllegalValue;
250
+ return false;
251
+ }
252
+ }
253
+ }
254
+ return true;
255
+ }
256
+
257
+ /// <summary>
258
+ /// Parses a YesNoAlwaysType from a string.
259
+ /// </summary>
260
+ public static YesNoAlwaysType ParseYesNoAlwaysType(string value)
261
+ {
262
+ YesNoAlwaysType parsedValue;
263
+ Enums.TryParseYesNoAlwaysType(value, out parsedValue);
264
+ return parsedValue;
265
+ }
266
+
267
+ /// <summary>
268
+ /// Tries to parse a YesNoAlwaysType from a string.
269
+ /// </summary>
270
+ public static bool TryParseYesNoAlwaysType(string value, out YesNoAlwaysType parsedValue)
271
+ {
272
+ parsedValue = YesNoAlwaysType.NotSet;
273
+ if (string.IsNullOrEmpty(value))
274
+ {
275
+ return false;
276
+ }
277
+ if (("always" == value))
278
+ {
279
+ parsedValue = YesNoAlwaysType.always;
280
+ }
281
+ else
282
+ {
283
+ if (("no" == value))
284
+ {
285
+ parsedValue = YesNoAlwaysType.no;
286
+ }
287
+ else
288
+ {
289
+ if (("yes" == value))
290
+ {
291
+ parsedValue = YesNoAlwaysType.yes;
292
+ }
293
+ else
294
+ {
295
+ parsedValue = YesNoAlwaysType.IllegalValue;
296
+ return false;
297
+ }
298
+ }
299
+ }
300
+ return true;
301
+ }
302
+
303
+ /// <summary>
304
+ /// Parses a RegistryRootType from a string.
305
+ /// </summary>
306
+ public static RegistryRootType ParseRegistryRootType(string value)
307
+ {
308
+ RegistryRootType parsedValue;
309
+ Enums.TryParseRegistryRootType(value, out parsedValue);
310
+ return parsedValue;
311
+ }
312
+
313
+ /// <summary>
314
+ /// Tries to parse a RegistryRootType from a string.
315
+ /// </summary>
316
+ public static bool TryParseRegistryRootType(string value, out RegistryRootType parsedValue)
317
+ {
318
+ parsedValue = RegistryRootType.NotSet;
319
+ if (string.IsNullOrEmpty(value))
320
+ {
321
+ return false;
322
+ }
323
+ if (("HKMU" == value))
324
+ {
325
+ parsedValue = RegistryRootType.HKMU;
326
+ }
327
+ else
328
+ {
329
+ if (("HKCR" == value))
330
+ {
331
+ parsedValue = RegistryRootType.HKCR;
332
+ }
333
+ else
334
+ {
335
+ if (("HKCU" == value))
336
+ {
337
+ parsedValue = RegistryRootType.HKCU;
338
+ }
339
+ else
340
+ {
341
+ if (("HKLM" == value))
342
+ {
343
+ parsedValue = RegistryRootType.HKLM;
344
+ }
345
+ else
346
+ {
347
+ if (("HKU" == value))
348
+ {
349
+ parsedValue = RegistryRootType.HKU;
350
+ }
351
+ else
352
+ {
353
+ parsedValue = RegistryRootType.IllegalValue;
354
+ return false;
355
+ }
356
+ }
357
+ }
358
+ }
359
+ }
360
+ return true;
361
+ }
362
+
363
+ /// <summary>
364
+ /// Parses a ExitType from a string.
365
+ /// </summary>
366
+ public static ExitType ParseExitType(string value)
367
+ {
368
+ ExitType parsedValue;
369
+ Enums.TryParseExitType(value, out parsedValue);
370
+ return parsedValue;
371
+ }
372
+
373
+ /// <summary>
374
+ /// Tries to parse a ExitType from a string.
375
+ /// </summary>
376
+ public static bool TryParseExitType(string value, out ExitType parsedValue)
377
+ {
378
+ parsedValue = ExitType.NotSet;
379
+ if (string.IsNullOrEmpty(value))
380
+ {
381
+ return false;
382
+ }
383
+ if (("success" == value))
384
+ {
385
+ parsedValue = ExitType.success;
386
+ }
387
+ else
388
+ {
389
+ if (("cancel" == value))
390
+ {
391
+ parsedValue = ExitType.cancel;
392
+ }
393
+ else
394
+ {
395
+ if (("error" == value))
396
+ {
397
+ parsedValue = ExitType.error;
398
+ }
399
+ else
400
+ {
401
+ if (("suspend" == value))
402
+ {
403
+ parsedValue = ExitType.suspend;
404
+ }
405
+ else
406
+ {
407
+ parsedValue = ExitType.IllegalValue;
408
+ return false;
409
+ }
410
+ }
411
+ }
412
+ }
413
+ return true;
414
+ }
415
+
416
+ /// <summary>
417
+ /// Parses a InstallUninstallType from a string.
418
+ /// </summary>
419
+ public static InstallUninstallType ParseInstallUninstallType(string value)
420
+ {
421
+ InstallUninstallType parsedValue;
422
+ Enums.TryParseInstallUninstallType(value, out parsedValue);
423
+ return parsedValue;
424
+ }
425
+
426
+ /// <summary>
427
+ /// Tries to parse a InstallUninstallType from a string.
428
+ /// </summary>
429
+ public static bool TryParseInstallUninstallType(string value, out InstallUninstallType parsedValue)
430
+ {
431
+ parsedValue = InstallUninstallType.NotSet;
432
+ if (string.IsNullOrEmpty(value))
433
+ {
434
+ return false;
435
+ }
436
+ if (("install" == value))
437
+ {
438
+ parsedValue = InstallUninstallType.install;
439
+ }
440
+ else
441
+ {
442
+ if (("uninstall" == value))
443
+ {
444
+ parsedValue = InstallUninstallType.uninstall;
445
+ }
446
+ else
447
+ {
448
+ if (("both" == value))
449
+ {
450
+ parsedValue = InstallUninstallType.both;
451
+ }
452
+ else
453
+ {
454
+ parsedValue = InstallUninstallType.IllegalValue;
455
+ return false;
456
+ }
457
+ }
458
+ }
459
+ return true;
460
+ }
461
+
462
+ /// <summary>
463
+ /// Parses a SequenceType from a string.
464
+ /// </summary>
465
+ public static SequenceType ParseSequenceType(string value)
466
+ {
467
+ SequenceType parsedValue;
468
+ Enums.TryParseSequenceType(value, out parsedValue);
469
+ return parsedValue;
470
+ }
471
+
472
+ /// <summary>
473
+ /// Tries to parse a SequenceType from a string.
474
+ /// </summary>
475
+ public static bool TryParseSequenceType(string value, out SequenceType parsedValue)
476
+ {
477
+ parsedValue = SequenceType.NotSet;
478
+ if (string.IsNullOrEmpty(value))
479
+ {
480
+ return false;
481
+ }
482
+ if (("both" == value))
483
+ {
484
+ parsedValue = SequenceType.both;
485
+ }
486
+ else
487
+ {
488
+ if (("first" == value))
489
+ {
490
+ parsedValue = SequenceType.first;
491
+ }
492
+ else
493
+ {
494
+ if (("execute" == value))
495
+ {
496
+ parsedValue = SequenceType.execute;
497
+ }
498
+ else
499
+ {
500
+ if (("ui" == value))
501
+ {
502
+ parsedValue = SequenceType.ui;
503
+ }
504
+ else
505
+ {
506
+ parsedValue = SequenceType.IllegalValue;
507
+ return false;
508
+ }
509
+ }
510
+ }
511
+ }
512
+ return true;
513
+ }
514
+
515
+ /// <summary>
516
+ /// Parses a CompressionLevelType from a string.
517
+ /// </summary>
518
+ public static CompressionLevelType ParseCompressionLevelType(string value)
519
+ {
520
+ CompressionLevelType parsedValue;
521
+ Enums.TryParseCompressionLevelType(value, out parsedValue);
522
+ return parsedValue;
523
+ }
524
+
525
+ /// <summary>
526
+ /// Tries to parse a CompressionLevelType from a string.
527
+ /// </summary>
528
+ public static bool TryParseCompressionLevelType(string value, out CompressionLevelType parsedValue)
529
+ {
530
+ parsedValue = CompressionLevelType.NotSet;
531
+ if (string.IsNullOrEmpty(value))
532
+ {
533
+ return false;
534
+ }
535
+ if (("high" == value))
536
+ {
537
+ parsedValue = CompressionLevelType.high;
538
+ }
539
+ else
540
+ {
541
+ if (("low" == value))
542
+ {
543
+ parsedValue = CompressionLevelType.low;
544
+ }
545
+ else
546
+ {
547
+ if (("medium" == value))
548
+ {
549
+ parsedValue = CompressionLevelType.medium;
550
+ }
551
+ else
552
+ {
553
+ if (("mszip" == value))
554
+ {
555
+ parsedValue = CompressionLevelType.mszip;
556
+ }
557
+ else
558
+ {
559
+ if (("none" == value))
560
+ {
561
+ parsedValue = CompressionLevelType.none;
562
+ }
563
+ else
564
+ {
565
+ parsedValue = CompressionLevelType.IllegalValue;
566
+ return false;
567
+ }
568
+ }
569
+ }
570
+ }
571
+ }
572
+ return true;
573
+ }
574
+ }
575
+
576
+ /// <summary>
577
+ /// The list of communcation protocols with executable packages Burn supports.
578
+ /// </summary>
579
+ [GeneratedCode("WixBuildTools.XsdGen", "4.0.0.0")]
580
+ public enum BurnExeProtocolType
581
+ {
582
+
583
+ IllegalValue = int.MaxValue,
584
+
585
+ NotSet = -1,
586
+
587
+ /// <summary>
588
+ /// The executable package does not support a communication protocol.
589
+ /// </summary>
590
+ none,
591
+
592
+ /// <summary>
593
+ /// The executable package is another Burn bundle and supports the Burn communication protocol.
594
+ /// </summary>
595
+ burn,
596
+
597
+ /// <summary>
598
+ /// The executable package implements the .NET Framework v4.0 communication protocol.
599
+ /// </summary>
600
+ netfx4,
601
+ }
602
+
603
+ /// <summary>
604
+ /// Values of this type will either be "yes" or "no".
605
+ /// </summary>
606
+ [GeneratedCode("WixBuildTools.XsdGen", "4.0.0.0")]
607
+ public enum YesNoType
608
+ {
609
+
610
+ IllegalValue = int.MaxValue,
611
+
612
+ NotSet = -1,
613
+
614
+ no,
615
+
616
+ yes,
617
+ }
618
+
619
+ /// <summary>
620
+ /// Values of this type will either be "button", "yes" or "no".
621
+ /// </summary>
622
+ [GeneratedCode("WixBuildTools.XsdGen", "4.0.0.0")]
623
+ public enum YesNoButtonType
624
+ {
625
+
626
+ IllegalValue = int.MaxValue,
627
+
628
+ NotSet = -1,
629
+
630
+ no,
631
+
632
+ yes,
633
+
634
+ button,
635
+ }
636
+
637
+ /// <summary>
638
+ /// Values of this type will either be "default", "yes", or "no".
639
+ /// </summary>
640
+ [GeneratedCode("WixBuildTools.XsdGen", "4.0.0.0")]
641
+ public enum YesNoDefaultType
642
+ {
643
+
644
+ IllegalValue = int.MaxValue,
645
+
646
+ NotSet = -1,
647
+
648
+ @default,
649
+
650
+ no,
651
+
652
+ yes,
653
+ }
654
+
655
+ /// <summary>
656
+ /// Values of this type will either be "always", "yes", or "no".
657
+ /// </summary>
658
+ [GeneratedCode("WixBuildTools.XsdGen", "4.0.0.0")]
659
+ public enum YesNoAlwaysType
660
+ {
661
+
662
+ IllegalValue = int.MaxValue,
663
+
664
+ NotSet = -1,
665
+
666
+ always,
667
+
668
+ no,
669
+
670
+ yes,
671
+ }
672
+
673
+ /// <summary>
674
+ /// Values of this type represent possible registry roots.
675
+ /// </summary>
676
+ [GeneratedCode("WixBuildTools.XsdGen", "4.0.0.0")]
677
+ public enum RegistryRootType
678
+ {
679
+
680
+ IllegalValue = int.MaxValue,
681
+
682
+ NotSet = -1,
683
+
684
+ /// <summary>
685
+ /// A per-user installation will make the operation occur under HKEY_CURRENT_USER.
686
+ /// A per-machine installation will make the operation occur under HKEY_LOCAL_MACHINE.
687
+ /// </summary>
688
+ HKMU,
689
+
690
+ /// <summary>
691
+ /// Operation occurs under HKEY_CLASSES_ROOT. When using Windows 2000 or later, the installer writes or removes the value
692
+ /// from the HKCU\Software\Classes hive during per-user installations. When using Windows 2000 or later operating systems,
693
+ /// the installer writes or removes the value from the HKLM\Software\Classes hive during per-machine installations.
694
+ /// </summary>
695
+ HKCR,
696
+
697
+ /// <summary>
698
+ /// Operation occurs under HKEY_CURRENT_USER. It is recommended to set the KeyPath='yes' attribute when setting this value for writing values
699
+ /// in order to ensure that the installer writes the necessary registry entries when there are multiple users on the same computer.
700
+ /// </summary>
701
+ HKCU,
702
+
703
+ /// <summary>
704
+ /// Operation occurs under HKEY_LOCAL_MACHINE.
705
+ /// </summary>
706
+ HKLM,
707
+
708
+ /// <summary>
709
+ /// Operation occurs under HKEY_USERS.
710
+ /// </summary>
711
+ HKU,
712
+ }
713
+
714
+ /// <summary>
715
+ /// Value indicates that this action is executed if the installer returns the associated exit type. Each exit type can be used with no more than one action.
716
+ /// Multiple actions can have exit types assigned, but every action and exit type must be different. Exit types are typically used with dialog boxes.
717
+ /// </summary>
718
+ [GeneratedCode("WixBuildTools.XsdGen", "4.0.0.0")]
719
+ public enum ExitType
720
+ {
721
+
722
+ IllegalValue = int.MaxValue,
723
+
724
+ NotSet = -1,
725
+
726
+ success,
727
+
728
+ cancel,
729
+
730
+ error,
731
+
732
+ suspend,
733
+ }
734
+
735
+ /// <summary>
736
+ /// Specifies whether an action occur on install, uninstall or both.
737
+ /// </summary>
738
+ [GeneratedCode("WixBuildTools.XsdGen", "4.0.0.0")]
739
+ public enum InstallUninstallType
740
+ {
741
+
742
+ IllegalValue = int.MaxValue,
743
+
744
+ NotSet = -1,
745
+
746
+ /// <summary>
747
+ /// The action should happen during install (msiInstallStateLocal or msiInstallStateSource).
748
+ /// </summary>
749
+ install,
750
+
751
+ /// <summary>
752
+ /// The action should happen during uninstall (msiInstallStateAbsent).
753
+ /// </summary>
754
+ uninstall,
755
+
756
+ /// <summary>
757
+ /// The action should happen during both install and uninstall.
758
+ /// </summary>
759
+ both,
760
+ }
761
+
762
+ /// <summary>
763
+ /// Controls which sequences the item assignment is sequenced in.
764
+ /// </summary>
765
+ [GeneratedCode("WixBuildTools.XsdGen", "4.0.0.0")]
766
+ public enum SequenceType
767
+ {
768
+
769
+ IllegalValue = int.MaxValue,
770
+
771
+ NotSet = -1,
772
+
773
+ /// <summary>
774
+ /// Schedules the assignment in the InstallUISequence and the InstallExecuteSequence.
775
+ /// </summary>
776
+ both,
777
+
778
+ /// <summary>
779
+ /// Schedules the assignment to run in the InstallUISequence or the InstallExecuteSequence if the InstallUISequence is skipped.
780
+ /// </summary>
781
+ first,
782
+
783
+ /// <summary>
784
+ /// Schedules the assignment only in the the InstallExecuteSequence.
785
+ /// </summary>
786
+ execute,
787
+
788
+ /// <summary>
789
+ /// Schedules the assignment only in the the InstallUISequence.
790
+ /// </summary>
791
+ ui,
792
+ }
793
+
794
+ /// <summary>
795
+ /// Indicates the compression level for a cabinet.
796
+ /// </summary>
797
+ [GeneratedCode("WixBuildTools.XsdGen", "4.0.0.0")]
798
+ public enum CompressionLevelType
799
+ {
800
+
801
+ IllegalValue = int.MaxValue,
802
+
803
+ NotSet = -1,
804
+
805
+ high,
806
+
807
+ low,
808
+
809
+ medium,
810
+
811
+ mszip,
812
+
813
+ none,
814
+ }
815
+
816
+ [GeneratedCode("WixBuildTools.XsdGen", "4.0.0.0")]
817
+ public abstract class ActionModuleSequenceType : ISchemaElement, ISetAttributes
818
+ {
819
+
820
+ private string afterField;
821
+
822
+ private bool afterFieldSet;
823
+
824
+ private string beforeField;
825
+
826
+ private bool beforeFieldSet;
827
+
828
+ private YesNoType overridableField;
829
+
830
+ private bool overridableFieldSet;
831
+
832
+ private int sequenceField;
833
+
834
+ private bool sequenceFieldSet;
835
+
836
+ private YesNoType suppressField;
837
+
838
+ private bool suppressFieldSet;
839
+
840
+ private string contentField;
841
+
842
+ private bool contentFieldSet;
843
+
844
+ private ISchemaElement parentElement;
845
+
846
+ /// <summary>
847
+ /// The name of an action that this action should come after.
848
+ /// </summary>
849
+ public string After
850
+ {
851
+ get
852
+ {
853
+ return this.afterField;
854
+ }
855
+ set
856
+ {
857
+ this.afterFieldSet = true;
858
+ this.afterField = value;
859
+ }
860
+ }
861
+
862
+ /// <summary>
863
+ /// The name of an action that this action should come before.
864
+ /// </summary>
865
+ public string Before
866
+ {
867
+ get
868
+ {
869
+ return this.beforeField;
870
+ }
871
+ set
872
+ {
873
+ this.beforeFieldSet = true;
874
+ this.beforeField = value;
875
+ }
876
+ }
877
+
878
+ /// <summary>
879
+ /// If "yes", the sequencing of this action may be overridden by sequencing elsewhere.
880
+ /// </summary>
881
+ public YesNoType Overridable
882
+ {
883
+ get
884
+ {
885
+ return this.overridableField;
886
+ }
887
+ set
888
+ {
889
+ this.overridableFieldSet = true;
890
+ this.overridableField = value;
891
+ }
892
+ }
893
+
894
+ /// <summary>
895
+ /// A value used to indicate the position of this action in a sequence.
896
+ /// </summary>
897
+ public int Sequence
898
+ {
899
+ get
900
+ {
901
+ return this.sequenceField;
902
+ }
903
+ set
904
+ {
905
+ this.sequenceFieldSet = true;
906
+ this.sequenceField = value;
907
+ }
908
+ }
909
+
910
+ /// <summary>
911
+ /// If yes, this action will not occur.
912
+ /// </summary>
913
+ public YesNoType Suppress
914
+ {
915
+ get
916
+ {
917
+ return this.suppressField;
918
+ }
919
+ set
920
+ {
921
+ this.suppressFieldSet = true;
922
+ this.suppressField = value;
923
+ }
924
+ }
925
+
926
+ /// <summary>
927
+ /// Text node specifies the condition of the action.
928
+ /// </summary>
929
+ public string Content
930
+ {
931
+ get
932
+ {
933
+ return this.contentField;
934
+ }
935
+ set
936
+ {
937
+ this.contentFieldSet = true;
938
+ this.contentField = value;
939
+ }
940
+ }
941
+
942
+ public virtual ISchemaElement ParentElement
943
+ {
944
+ get
945
+ {
946
+ return this.parentElement;
947
+ }
948
+ set
949
+ {
950
+ this.parentElement = value;
951
+ }
952
+ }
953
+
954
+ /// <summary>
955
+ /// Processes this element and all child elements into an XmlWriter.
956
+ /// </summary>
957
+ public virtual void OutputXml(XmlWriter writer)
958
+ {
959
+ if ((null == writer))
960
+ {
961
+ throw new ArgumentNullException("writer");
962
+ }
963
+ if (this.afterFieldSet)
964
+ {
965
+ writer.WriteAttributeString("After", this.afterField);
966
+ }
967
+ if (this.beforeFieldSet)
968
+ {
969
+ writer.WriteAttributeString("Before", this.beforeField);
970
+ }
971
+ if (this.overridableFieldSet)
972
+ {
973
+ if ((this.overridableField == YesNoType.no))
974
+ {
975
+ writer.WriteAttributeString("Overridable", "no");
976
+ }
977
+ if ((this.overridableField == YesNoType.yes))
978
+ {
979
+ writer.WriteAttributeString("Overridable", "yes");
980
+ }
981
+ }
982
+ if (this.sequenceFieldSet)
983
+ {
984
+ writer.WriteAttributeString("Sequence", this.sequenceField.ToString(CultureInfo.InvariantCulture));
985
+ }
986
+ if (this.suppressFieldSet)
987
+ {
988
+ if ((this.suppressField == YesNoType.no))
989
+ {
990
+ writer.WriteAttributeString("Suppress", "no");
991
+ }
992
+ if ((this.suppressField == YesNoType.yes))
993
+ {
994
+ writer.WriteAttributeString("Suppress", "yes");
995
+ }
996
+ }
997
+ if (this.contentFieldSet)
998
+ {
999
+ writer.WriteString(this.contentField);
1000
+ }
1001
+ }
1002
+
1003
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
1004
+ void ISetAttributes.SetAttribute(string name, string value)
1005
+ {
1006
+ if (String.IsNullOrEmpty(name))
1007
+ {
1008
+ throw new ArgumentNullException("name");
1009
+ }
1010
+ if (("After" == name))
1011
+ {
1012
+ this.afterField = value;
1013
+ this.afterFieldSet = true;
1014
+ }
1015
+ if (("Before" == name))
1016
+ {
1017
+ this.beforeField = value;
1018
+ this.beforeFieldSet = true;
1019
+ }
1020
+ if (("Overridable" == name))
1021
+ {
1022
+ this.overridableField = Enums.ParseYesNoType(value);
1023
+ this.overridableFieldSet = true;
1024
+ }
1025
+ if (("Sequence" == name))
1026
+ {
1027
+ this.sequenceField = Convert.ToInt32(value, CultureInfo.InvariantCulture);
1028
+ this.sequenceFieldSet = true;
1029
+ }
1030
+ if (("Suppress" == name))
1031
+ {
1032
+ this.suppressField = Enums.ParseYesNoType(value);
1033
+ this.suppressFieldSet = true;
1034
+ }
1035
+ if (("Content" == name))
1036
+ {
1037
+ this.contentField = value;
1038
+ this.contentFieldSet = true;
1039
+ }
1040
+ }
1041
+ }
1042
+
1043
+ [GeneratedCode("WixBuildTools.XsdGen", "4.0.0.0")]
1044
+ public abstract class ActionSequenceType : ISchemaElement, ISetAttributes
1045
+ {
1046
+
1047
+ private int sequenceField;
1048
+
1049
+ private bool sequenceFieldSet;
1050
+
1051
+ private YesNoType suppressField;
1052
+
1053
+ private bool suppressFieldSet;
1054
+
1055
+ private string contentField;
1056
+
1057
+ private bool contentFieldSet;
1058
+
1059
+ private ISchemaElement parentElement;
1060
+
1061
+ /// <summary>
1062
+ /// A value used to indicate the position of this action in a sequence.
1063
+ /// </summary>
1064
+ public int Sequence
1065
+ {
1066
+ get
1067
+ {
1068
+ return this.sequenceField;
1069
+ }
1070
+ set
1071
+ {
1072
+ this.sequenceFieldSet = true;
1073
+ this.sequenceField = value;
1074
+ }
1075
+ }
1076
+
1077
+ /// <summary>
1078
+ /// If yes, this action will not occur.
1079
+ /// </summary>
1080
+ public YesNoType Suppress
1081
+ {
1082
+ get
1083
+ {
1084
+ return this.suppressField;
1085
+ }
1086
+ set
1087
+ {
1088
+ this.suppressFieldSet = true;
1089
+ this.suppressField = value;
1090
+ }
1091
+ }
1092
+
1093
+ public string Content
1094
+ {
1095
+ get
1096
+ {
1097
+ return this.contentField;
1098
+ }
1099
+ set
1100
+ {
1101
+ this.contentFieldSet = true;
1102
+ this.contentField = value;
1103
+ }
1104
+ }
1105
+
1106
+ public virtual ISchemaElement ParentElement
1107
+ {
1108
+ get
1109
+ {
1110
+ return this.parentElement;
1111
+ }
1112
+ set
1113
+ {
1114
+ this.parentElement = value;
1115
+ }
1116
+ }
1117
+
1118
+ /// <summary>
1119
+ /// Processes this element and all child elements into an XmlWriter.
1120
+ /// </summary>
1121
+ public virtual void OutputXml(XmlWriter writer)
1122
+ {
1123
+ if ((null == writer))
1124
+ {
1125
+ throw new ArgumentNullException("writer");
1126
+ }
1127
+ if (this.sequenceFieldSet)
1128
+ {
1129
+ writer.WriteAttributeString("Sequence", this.sequenceField.ToString(CultureInfo.InvariantCulture));
1130
+ }
1131
+ if (this.suppressFieldSet)
1132
+ {
1133
+ if ((this.suppressField == YesNoType.no))
1134
+ {
1135
+ writer.WriteAttributeString("Suppress", "no");
1136
+ }
1137
+ if ((this.suppressField == YesNoType.yes))
1138
+ {
1139
+ writer.WriteAttributeString("Suppress", "yes");
1140
+ }
1141
+ }
1142
+ if (this.contentFieldSet)
1143
+ {
1144
+ writer.WriteString(this.contentField);
1145
+ }
1146
+ }
1147
+
1148
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
1149
+ void ISetAttributes.SetAttribute(string name, string value)
1150
+ {
1151
+ if (String.IsNullOrEmpty(name))
1152
+ {
1153
+ throw new ArgumentNullException("name");
1154
+ }
1155
+ if (("Sequence" == name))
1156
+ {
1157
+ this.sequenceField = Convert.ToInt32(value, CultureInfo.InvariantCulture);
1158
+ this.sequenceFieldSet = true;
1159
+ }
1160
+ if (("Suppress" == name))
1161
+ {
1162
+ this.suppressField = Enums.ParseYesNoType(value);
1163
+ this.suppressFieldSet = true;
1164
+ }
1165
+ if (("Content" == name))
1166
+ {
1167
+ this.contentField = value;
1168
+ this.contentFieldSet = true;
1169
+ }
1170
+ }
1171
+ }
1172
+
1173
+ /// <summary>
1174
+ /// This is the top-level container element for every wxs file. Among the possible children,
1175
+ /// the Bundle, Package, Module, Patch, and PatchCreation elements are analogous to the main function in a C program.
1176
+ /// There can only be one of these present when linking occurs. Package compiles into an msi file,
1177
+ /// Module compiles into an msm file, PatchCreation compiles into a pcp file. The Fragment element
1178
+ /// is an atomic unit which ultimately links into either a Package, Module, or PatchCreation. The
1179
+ /// Fragment can either be completely included or excluded during linking.
1180
+ /// </summary>
1181
+ [GeneratedCode("WixBuildTools.XsdGen", "4.0.0.0")]
1182
+ public class Wix : IParentElement, ICreateChildren, ISchemaElement, ISetAttributes
1183
+ {
1184
+
1185
+ private ElementCollection children;
1186
+
1187
+ private string requiredVersionField;
1188
+
1189
+ private bool requiredVersionFieldSet;
1190
+
1191
+ private ISchemaElement parentElement;
1192
+
1193
+ public Wix()
1194
+ {
1195
+ ElementCollection childCollection0 = new ElementCollection(ElementCollection.CollectionType.Choice);
1196
+ ElementCollection childCollection1 = new ElementCollection(ElementCollection.CollectionType.Sequence);
1197
+ ElementCollection childCollection2 = new ElementCollection(ElementCollection.CollectionType.Choice);
1198
+ childCollection2.AddItem(new ElementCollection.ChoiceItem(typeof(Bundle)));
1199
+ childCollection2.AddItem(new ElementCollection.ChoiceItem(typeof(Package)));
1200
+ childCollection2.AddItem(new ElementCollection.ChoiceItem(typeof(Module)));
1201
+ childCollection2.AddItem(new ElementCollection.ChoiceItem(typeof(Patch)));
1202
+ childCollection1.AddCollection(childCollection2);
1203
+ childCollection1.AddItem(new ElementCollection.SequenceItem(typeof(Fragment)));
1204
+ childCollection0.AddCollection(childCollection1);
1205
+ childCollection0.AddItem(new ElementCollection.ChoiceItem(typeof(PatchCreation)));
1206
+ this.children = childCollection0;
1207
+ }
1208
+
1209
+ public virtual IEnumerable Children
1210
+ {
1211
+ get
1212
+ {
1213
+ return this.children;
1214
+ }
1215
+ }
1216
+
1217
+ [SuppressMessage("Microsoft.Design", "CA1043:UseIntegralOrStringArgumentForIndexers")]
1218
+ public virtual IEnumerable this[System.Type childType]
1219
+ {
1220
+ get
1221
+ {
1222
+ return this.children.Filter(childType);
1223
+ }
1224
+ }
1225
+
1226
+ /// <summary>
1227
+ /// Required version of the WiX toolset to compile this input file.
1228
+ /// </summary>
1229
+ public string RequiredVersion
1230
+ {
1231
+ get
1232
+ {
1233
+ return this.requiredVersionField;
1234
+ }
1235
+ set
1236
+ {
1237
+ this.requiredVersionFieldSet = true;
1238
+ this.requiredVersionField = value;
1239
+ }
1240
+ }
1241
+
1242
+ public virtual ISchemaElement ParentElement
1243
+ {
1244
+ get
1245
+ {
1246
+ return this.parentElement;
1247
+ }
1248
+ set
1249
+ {
1250
+ this.parentElement = value;
1251
+ }
1252
+ }
1253
+
1254
+ public virtual void AddChild(ISchemaElement child)
1255
+ {
1256
+ if ((null == child))
1257
+ {
1258
+ throw new ArgumentNullException("child");
1259
+ }
1260
+ this.children.AddElement(child);
1261
+ child.ParentElement = this;
1262
+ }
1263
+
1264
+ public virtual void RemoveChild(ISchemaElement child)
1265
+ {
1266
+ if ((null == child))
1267
+ {
1268
+ throw new ArgumentNullException("child");
1269
+ }
1270
+ this.children.RemoveElement(child);
1271
+ child.ParentElement = null;
1272
+ }
1273
+
1274
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
1275
+ [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
1276
+ ISchemaElement ICreateChildren.CreateChild(string childName)
1277
+ {
1278
+ if (String.IsNullOrEmpty(childName))
1279
+ {
1280
+ throw new ArgumentNullException("childName");
1281
+ }
1282
+ ISchemaElement childValue = null;
1283
+ if (("Bundle" == childName))
1284
+ {
1285
+ childValue = new Bundle();
1286
+ }
1287
+ if (("Package" == childName))
1288
+ {
1289
+ childValue = new Package();
1290
+ }
1291
+ if (("Module" == childName))
1292
+ {
1293
+ childValue = new Module();
1294
+ }
1295
+ if (("Patch" == childName))
1296
+ {
1297
+ childValue = new Patch();
1298
+ }
1299
+ if (("Fragment" == childName))
1300
+ {
1301
+ childValue = new Fragment();
1302
+ }
1303
+ if (("PatchCreation" == childName))
1304
+ {
1305
+ childValue = new PatchCreation();
1306
+ }
1307
+ if ((null == childValue))
1308
+ {
1309
+ throw new InvalidOperationException(String.Concat(childName, " is not a valid child name."));
1310
+ }
1311
+ return childValue;
1312
+ }
1313
+
1314
+ /// <summary>
1315
+ /// Processes this element and all child elements into an XmlWriter.
1316
+ /// </summary>
1317
+ public virtual void OutputXml(XmlWriter writer)
1318
+ {
1319
+ if ((null == writer))
1320
+ {
1321
+ throw new ArgumentNullException("writer");
1322
+ }
1323
+ writer.WriteStartElement("Wix", "http://wixtoolset.org/schemas/v4/wxs");
1324
+ if (this.requiredVersionFieldSet)
1325
+ {
1326
+ writer.WriteAttributeString("RequiredVersion", this.requiredVersionField);
1327
+ }
1328
+ for (IEnumerator enumerator = this.children.GetEnumerator(); enumerator.MoveNext(); )
1329
+ {
1330
+ ISchemaElement childElement = ((ISchemaElement)(enumerator.Current));
1331
+ childElement.OutputXml(writer);
1332
+ }
1333
+ writer.WriteEndElement();
1334
+ }
1335
+
1336
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
1337
+ void ISetAttributes.SetAttribute(string name, string value)
1338
+ {
1339
+ if (String.IsNullOrEmpty(name))
1340
+ {
1341
+ throw new ArgumentNullException("name");
1342
+ }
1343
+ if (("RequiredVersion" == name))
1344
+ {
1345
+ this.requiredVersionField = value;
1346
+ this.requiredVersionFieldSet = true;
1347
+ }
1348
+ }
1349
+ }
1350
+
1351
+ /// <summary>
1352
+ /// This is the top-level container element for every wxi file.
1353
+ /// </summary>
1354
+ [GeneratedCode("WixBuildTools.XsdGen", "4.0.0.0")]
1355
+ public class Include : IParentElement, ICreateChildren, ISchemaElement, ISetAttributes
1356
+ {
1357
+
1358
+ private ElementCollection children;
1359
+
1360
+ private ISchemaElement parentElement;
1361
+
1362
+ public Include()
1363
+ {
1364
+ ElementCollection childCollection0 = new ElementCollection(ElementCollection.CollectionType.Choice);
1365
+ childCollection0.AddItem(new ElementCollection.ChoiceItem(typeof(ISchemaElement)));
1366
+ this.children = childCollection0;
1367
+ }
1368
+
1369
+ public virtual IEnumerable Children
1370
+ {
1371
+ get
1372
+ {
1373
+ return this.children;
1374
+ }
1375
+ }
1376
+
1377
+ [SuppressMessage("Microsoft.Design", "CA1043:UseIntegralOrStringArgumentForIndexers")]
1378
+ public virtual IEnumerable this[System.Type childType]
1379
+ {
1380
+ get
1381
+ {
1382
+ return this.children.Filter(childType);
1383
+ }
1384
+ }
1385
+
1386
+ public virtual ISchemaElement ParentElement
1387
+ {
1388
+ get
1389
+ {
1390
+ return this.parentElement;
1391
+ }
1392
+ set
1393
+ {
1394
+ this.parentElement = value;
1395
+ }
1396
+ }
1397
+
1398
+ public virtual void AddChild(ISchemaElement child)
1399
+ {
1400
+ if ((null == child))
1401
+ {
1402
+ throw new ArgumentNullException("child");
1403
+ }
1404
+ this.children.AddElement(child);
1405
+ child.ParentElement = this;
1406
+ }
1407
+
1408
+ public virtual void RemoveChild(ISchemaElement child)
1409
+ {
1410
+ if ((null == child))
1411
+ {
1412
+ throw new ArgumentNullException("child");
1413
+ }
1414
+ this.children.RemoveElement(child);
1415
+ child.ParentElement = null;
1416
+ }
1417
+
1418
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
1419
+ ISchemaElement ICreateChildren.CreateChild(string childName)
1420
+ {
1421
+ if (String.IsNullOrEmpty(childName))
1422
+ {
1423
+ throw new ArgumentNullException("childName");
1424
+ }
1425
+ ISchemaElement childValue = null;
1426
+ if ((null == childValue))
1427
+ {
1428
+ throw new InvalidOperationException(String.Concat(childName, " is not a valid child name."));
1429
+ }
1430
+ return childValue;
1431
+ }
1432
+
1433
+ /// <summary>
1434
+ /// Processes this element and all child elements into an XmlWriter.
1435
+ /// </summary>
1436
+ public virtual void OutputXml(XmlWriter writer)
1437
+ {
1438
+ if ((null == writer))
1439
+ {
1440
+ throw new ArgumentNullException("writer");
1441
+ }
1442
+ writer.WriteStartElement("Include", "http://wixtoolset.org/schemas/v4/wxs");
1443
+ for (IEnumerator enumerator = this.children.GetEnumerator(); enumerator.MoveNext(); )
1444
+ {
1445
+ ISchemaElement childElement = ((ISchemaElement)(enumerator.Current));
1446
+ childElement.OutputXml(writer);
1447
+ }
1448
+ writer.WriteEndElement();
1449
+ }
1450
+
1451
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
1452
+ void ISetAttributes.SetAttribute(string name, string value)
1453
+ {
1454
+ if (String.IsNullOrEmpty(name))
1455
+ {
1456
+ throw new ArgumentNullException("name");
1457
+ }
1458
+ }
1459
+ }
1460
+
1461
+ /// <summary>
1462
+ /// The root element for creating bundled packages.
1463
+ /// </summary>
1464
+ [GeneratedCode("WixBuildTools.XsdGen", "4.0.0.0")]
1465
+ public class Bundle : IParentElement, ICreateChildren, ISchemaElement, ISetAttributes
1466
+ {
1467
+
1468
+ private ElementCollection children;
1469
+
1470
+ private string aboutUrlField;
1471
+
1472
+ private bool aboutUrlFieldSet;
1473
+
1474
+ private string copyrightField;
1475
+
1476
+ private bool copyrightFieldSet;
1477
+
1478
+ private YesNoDefaultType compressedField;
1479
+
1480
+ private bool compressedFieldSet;
1481
+
1482
+ private YesNoButtonType disableModifyField;
1483
+
1484
+ private bool disableModifyFieldSet;
1485
+
1486
+ private YesNoType disableRemoveField;
1487
+
1488
+ private bool disableRemoveFieldSet;
1489
+
1490
+ private YesNoType disableRepairField;
1491
+
1492
+ private bool disableRepairFieldSet;
1493
+
1494
+ private string helpTelephoneField;
1495
+
1496
+ private bool helpTelephoneFieldSet;
1497
+
1498
+ private string helpUrlField;
1499
+
1500
+ private bool helpUrlFieldSet;
1501
+
1502
+ private string iconSourceFileField;
1503
+
1504
+ private bool iconSourceFileFieldSet;
1505
+
1506
+ private string manufacturerField;
1507
+
1508
+ private bool manufacturerFieldSet;
1509
+
1510
+ private string nameField;
1511
+
1512
+ private bool nameFieldSet;
1513
+
1514
+ private string parentNameField;
1515
+
1516
+ private bool parentNameFieldSet;
1517
+
1518
+ private string splashScreenSourceFileField;
1519
+
1520
+ private bool splashScreenSourceFileFieldSet;
1521
+
1522
+ private string tagField;
1523
+
1524
+ private bool tagFieldSet;
1525
+
1526
+ private string updateUrlField;
1527
+
1528
+ private bool updateUrlFieldSet;
1529
+
1530
+ private string upgradeCodeField;
1531
+
1532
+ private bool upgradeCodeFieldSet;
1533
+
1534
+ private string versionField;
1535
+
1536
+ private bool versionFieldSet;
1537
+
1538
+ private string conditionField;
1539
+
1540
+ private bool conditionFieldSet;
1541
+
1542
+ private ISchemaElement parentElement;
1543
+
1544
+ public Bundle()
1545
+ {
1546
+ ElementCollection childCollection0 = new ElementCollection(ElementCollection.CollectionType.Choice);
1547
+ childCollection0.AddItem(new ElementCollection.ChoiceItem(typeof(ApprovedExeForElevation)));
1548
+ childCollection0.AddItem(new ElementCollection.ChoiceItem(typeof(Log)));
1549
+ childCollection0.AddItem(new ElementCollection.ChoiceItem(typeof(Catalog)));
1550
+ childCollection0.AddItem(new ElementCollection.ChoiceItem(typeof(BootstrapperApplication)));
1551
+ childCollection0.AddItem(new ElementCollection.ChoiceItem(typeof(BootstrapperApplicationRef)));
1552
+ childCollection0.AddItem(new ElementCollection.ChoiceItem(typeof(OptionalUpdateRegistration)));
1553
+ childCollection0.AddItem(new ElementCollection.ChoiceItem(typeof(Chain)));
1554
+ childCollection0.AddItem(new ElementCollection.ChoiceItem(typeof(Container)));
1555
+ childCollection0.AddItem(new ElementCollection.ChoiceItem(typeof(ContainerRef)));
1556
+ childCollection0.AddItem(new ElementCollection.ChoiceItem(typeof(PayloadGroup)));
1557
+ childCollection0.AddItem(new ElementCollection.ChoiceItem(typeof(PayloadGroupRef)));
1558
+ childCollection0.AddItem(new ElementCollection.ChoiceItem(typeof(RelatedBundle)));
1559
+ childCollection0.AddItem(new ElementCollection.ChoiceItem(typeof(Update)));
1560
+ childCollection0.AddItem(new ElementCollection.ChoiceItem(typeof(Variable)));
1561
+ childCollection0.AddItem(new ElementCollection.ChoiceItem(typeof(WixVariable)));
1562
+ childCollection0.AddItem(new ElementCollection.ChoiceItem(typeof(ISchemaElement)));
1563
+ this.children = childCollection0;
1564
+ }
1565
+
1566
+ public virtual IEnumerable Children
1567
+ {
1568
+ get
1569
+ {
1570
+ return this.children;
1571
+ }
1572
+ }
1573
+
1574
+ [SuppressMessage("Microsoft.Design", "CA1043:UseIntegralOrStringArgumentForIndexers")]
1575
+ public virtual IEnumerable this[System.Type childType]
1576
+ {
1577
+ get
1578
+ {
1579
+ return this.children.Filter(childType);
1580
+ }
1581
+ }
1582
+
1583
+ /// <summary>
1584
+ /// A URL for more information about the bundle to display in Programs and Features (also
1585
+ /// known as Add/Remove Programs).
1586
+ /// </summary>
1587
+ public string AboutUrl
1588
+ {
1589
+ get
1590
+ {
1591
+ return this.aboutUrlField;
1592
+ }
1593
+ set
1594
+ {
1595
+ this.aboutUrlFieldSet = true;
1596
+ this.aboutUrlField = value;
1597
+ }
1598
+ }
1599
+
1600
+ /// <summary>
1601
+ /// The legal copyright found in the version resources of final bundle executable. If
1602
+ /// this attribute is not provided the copyright will be set to "Copyright (c) [Bundle/@Manufacturer]. All rights reserved.".
1603
+ /// </summary>
1604
+ public string Copyright
1605
+ {
1606
+ get
1607
+ {
1608
+ return this.copyrightField;
1609
+ }
1610
+ set
1611
+ {
1612
+ this.copyrightFieldSet = true;
1613
+ this.copyrightField = value;
1614
+ }
1615
+ }
1616
+
1617
+ /// <summary>
1618
+ /// Whether Packages and Payloads not assigned to a container should be added to the default attached container or if they should be external. The default is yes.
1619
+ /// </summary>
1620
+ public YesNoDefaultType Compressed
1621
+ {
1622
+ get
1623
+ {
1624
+ return this.compressedField;
1625
+ }
1626
+ set
1627
+ {
1628
+ this.compressedFieldSet = true;
1629
+ this.compressedField = value;
1630
+ }
1631
+ }
1632
+
1633
+ /// <summary>
1634
+ /// Determines whether the bundle can be modified via the Programs and Features (also known as
1635
+ /// Add/Remove Programs). If the value is "button" then Programs and Features will show a single
1636
+ /// "Uninstall/Change" button. If the value is "yes" then Programs and Features will only show
1637
+ /// the "Uninstall" button". If the value is "no", the default, then a "Change" button is shown.
1638
+ /// See the DisableRemove attribute for information how to not display the bundle in Programs
1639
+ /// and Features.
1640
+ /// </summary>
1641
+ public YesNoButtonType DisableModify
1642
+ {
1643
+ get
1644
+ {
1645
+ return this.disableModifyField;
1646
+ }
1647
+ set
1648
+ {
1649
+ this.disableModifyFieldSet = true;
1650
+ this.disableModifyField = value;
1651
+ }
1652
+ }
1653
+
1654
+ /// <summary>
1655
+ /// Determines whether the bundle can be removed via the Programs and Features (also
1656
+ /// known as Add/Remove Programs). If the value is "yes" then the "Uninstall" button will
1657
+ /// not be displayed. The default is "no" which ensures there is an "Uninstall" button to
1658
+ /// remove the bundle. If the "DisableModify" attribute is also "yes" or "button" then the
1659
+ /// bundle will not be displayed in Progams and Features and another mechanism (such as
1660
+ /// registering as a related bundle addon) must be used to ensure the bundle can be removed.
1661
+ /// </summary>
1662
+ public YesNoType DisableRemove
1663
+ {
1664
+ get
1665
+ {
1666
+ return this.disableRemoveField;
1667
+ }
1668
+ set
1669
+ {
1670
+ this.disableRemoveFieldSet = true;
1671
+ this.disableRemoveField = value;
1672
+ }
1673
+ }
1674
+
1675
+ public YesNoType DisableRepair
1676
+ {
1677
+ get
1678
+ {
1679
+ return this.disableRepairField;
1680
+ }
1681
+ set
1682
+ {
1683
+ this.disableRepairFieldSet = true;
1684
+ this.disableRepairField = value;
1685
+ }
1686
+ }
1687
+
1688
+ /// <summary>
1689
+ /// A telephone number for help to display in Programs and Features (also known as
1690
+ /// Add/Remove Programs).
1691
+ /// </summary>
1692
+ public string HelpTelephone
1693
+ {
1694
+ get
1695
+ {
1696
+ return this.helpTelephoneField;
1697
+ }
1698
+ set
1699
+ {
1700
+ this.helpTelephoneFieldSet = true;
1701
+ this.helpTelephoneField = value;
1702
+ }
1703
+ }
1704
+
1705
+ /// <summary>
1706
+ /// A URL to the help for the bundle to display in Programs and Features (also known as
1707
+ /// Add/Remove Programs).
1708
+ /// </summary>
1709
+ public string HelpUrl
1710
+ {
1711
+ get
1712
+ {
1713
+ return this.helpUrlField;
1714
+ }
1715
+ set
1716
+ {
1717
+ this.helpUrlFieldSet = true;
1718
+ this.helpUrlField = value;
1719
+ }
1720
+ }
1721
+
1722
+ /// <summary>
1723
+ /// Path to an icon that will replace the default icon in the final Bundle executable.
1724
+ /// This icon will also be displayed in Programs and Features (also known as Add/Remove
1725
+ /// Programs).
1726
+ /// </summary>
1727
+ public string IconSourceFile
1728
+ {
1729
+ get
1730
+ {
1731
+ return this.iconSourceFileField;
1732
+ }
1733
+ set
1734
+ {
1735
+ this.iconSourceFileFieldSet = true;
1736
+ this.iconSourceFileField = value;
1737
+ }
1738
+ }
1739
+
1740
+ /// <summary>
1741
+ /// The publisher of the bundle to display in Programs and Features (also known as
1742
+ /// Add/Remove Programs).
1743
+ /// </summary>
1744
+ public string Manufacturer
1745
+ {
1746
+ get
1747
+ {
1748
+ return this.manufacturerField;
1749
+ }
1750
+ set
1751
+ {
1752
+ this.manufacturerFieldSet = true;
1753
+ this.manufacturerField = value;
1754
+ }
1755
+ }
1756
+
1757
+ /// <summary>
1758
+ /// The name of the bundle to display in Programs and Features (also known as Add/Remove
1759
+ /// Programs). This name can be accessed and overwritten by a BootstrapperApplication
1760
+ /// using the WixBundleName bundle variable.
1761
+ /// </summary>
1762
+ public string Name
1763
+ {
1764
+ get
1765
+ {
1766
+ return this.nameField;
1767
+ }
1768
+ set
1769
+ {
1770
+ this.nameFieldSet = true;
1771
+ this.nameField = value;
1772
+ }
1773
+ }
1774
+
1775
+ /// <summary>
1776
+ /// The name of the parent bundle to display in Installed Updates (also known as Add/Remove
1777
+ /// Programs). This name is used to nest or group bundles that will appear as updates.
1778
+ /// If the parent name does not actually exist, a virtual parent is created automatically.
1779
+ /// </summary>
1780
+ public string ParentName
1781
+ {
1782
+ get
1783
+ {
1784
+ return this.parentNameField;
1785
+ }
1786
+ set
1787
+ {
1788
+ this.parentNameFieldSet = true;
1789
+ this.parentNameField = value;
1790
+ }
1791
+ }
1792
+
1793
+ /// <summary>
1794
+ /// Path to a bitmap that will be shown as the bootstrapper application is being loaded. If this attribute is not specified, no splash screen will be displayed.
1795
+ /// </summary>
1796
+ public string SplashScreenSourceFile
1797
+ {
1798
+ get
1799
+ {
1800
+ return this.splashScreenSourceFileField;
1801
+ }
1802
+ set
1803
+ {
1804
+ this.splashScreenSourceFileFieldSet = true;
1805
+ this.splashScreenSourceFileField = value;
1806
+ }
1807
+ }
1808
+
1809
+ /// <summary>
1810
+ /// Set this string to uniquely identify this bundle to its own BA, and to related bundles. The value of this string only matters to the BA, and its value has no direct effect on engine functionality.
1811
+ /// </summary>
1812
+ public string Tag
1813
+ {
1814
+ get
1815
+ {
1816
+ return this.tagField;
1817
+ }
1818
+ set
1819
+ {
1820
+ this.tagFieldSet = true;
1821
+ this.tagField = value;
1822
+ }
1823
+ }
1824
+
1825
+ /// <summary>
1826
+ /// A URL for updates of the bundle to display in Programs and Features (also
1827
+ /// known as Add/Remove Programs).
1828
+ /// </summary>
1829
+ public string UpdateUrl
1830
+ {
1831
+ get
1832
+ {
1833
+ return this.updateUrlField;
1834
+ }
1835
+ set
1836
+ {
1837
+ this.updateUrlFieldSet = true;
1838
+ this.updateUrlField = value;
1839
+ }
1840
+ }
1841
+
1842
+ /// <summary>
1843
+ /// Unique identifier for a family of bundles. If two bundles have the same UpgradeCode the
1844
+ /// bundle with the highest version will be installed.
1845
+ /// </summary>
1846
+ public string UpgradeCode
1847
+ {
1848
+ get
1849
+ {
1850
+ return this.upgradeCodeField;
1851
+ }
1852
+ set
1853
+ {
1854
+ this.upgradeCodeFieldSet = true;
1855
+ this.upgradeCodeField = value;
1856
+ }
1857
+ }
1858
+
1859
+ /// <summary>
1860
+ /// The version of the bundle. Newer versions upgrade earlier versions of the bundles
1861
+ /// with matching UpgradeCodes. If the bundle is registered in Programs and Features
1862
+ /// then this attribute will be displayed in the Programs and Features user interface.
1863
+ /// </summary>
1864
+ public string Version
1865
+ {
1866
+ get
1867
+ {
1868
+ return this.versionField;
1869
+ }
1870
+ set
1871
+ {
1872
+ this.versionFieldSet = true;
1873
+ this.versionField = value;
1874
+ }
1875
+ }
1876
+
1877
+ /// <summary>
1878
+ /// The condition of the bundle. If the condition is not met, the bundle will
1879
+ /// refuse to run. Conditions are checked before the bootstrapper application is loaded
1880
+ /// (before detect), and thus can only reference built-in variables such as
1881
+ /// variables which indicate the version of the OS.
1882
+ /// </summary>
1883
+ public string Condition
1884
+ {
1885
+ get
1886
+ {
1887
+ return this.conditionField;
1888
+ }
1889
+ set
1890
+ {
1891
+ this.conditionFieldSet = true;
1892
+ this.conditionField = value;
1893
+ }
1894
+ }
1895
+
1896
+ public virtual ISchemaElement ParentElement
1897
+ {
1898
+ get
1899
+ {
1900
+ return this.parentElement;
1901
+ }
1902
+ set
1903
+ {
1904
+ this.parentElement = value;
1905
+ }
1906
+ }
1907
+
1908
+ public virtual void AddChild(ISchemaElement child)
1909
+ {
1910
+ if ((null == child))
1911
+ {
1912
+ throw new ArgumentNullException("child");
1913
+ }
1914
+ this.children.AddElement(child);
1915
+ child.ParentElement = this;
1916
+ }
1917
+
1918
+ public virtual void RemoveChild(ISchemaElement child)
1919
+ {
1920
+ if ((null == child))
1921
+ {
1922
+ throw new ArgumentNullException("child");
1923
+ }
1924
+ this.children.RemoveElement(child);
1925
+ child.ParentElement = null;
1926
+ }
1927
+
1928
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
1929
+ [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
1930
+ ISchemaElement ICreateChildren.CreateChild(string childName)
1931
+ {
1932
+ if (String.IsNullOrEmpty(childName))
1933
+ {
1934
+ throw new ArgumentNullException("childName");
1935
+ }
1936
+ ISchemaElement childValue = null;
1937
+ if (("ApprovedExeForElevation" == childName))
1938
+ {
1939
+ childValue = new ApprovedExeForElevation();
1940
+ }
1941
+ if (("Log" == childName))
1942
+ {
1943
+ childValue = new Log();
1944
+ }
1945
+ if (("Catalog" == childName))
1946
+ {
1947
+ childValue = new Catalog();
1948
+ }
1949
+ if (("BootstrapperApplication" == childName))
1950
+ {
1951
+ childValue = new BootstrapperApplication();
1952
+ }
1953
+ if (("BootstrapperApplicationRef" == childName))
1954
+ {
1955
+ childValue = new BootstrapperApplicationRef();
1956
+ }
1957
+ if (("OptionalUpdateRegistration" == childName))
1958
+ {
1959
+ childValue = new OptionalUpdateRegistration();
1960
+ }
1961
+ if (("Chain" == childName))
1962
+ {
1963
+ childValue = new Chain();
1964
+ }
1965
+ if (("Container" == childName))
1966
+ {
1967
+ childValue = new Container();
1968
+ }
1969
+ if (("ContainerRef" == childName))
1970
+ {
1971
+ childValue = new ContainerRef();
1972
+ }
1973
+ if (("PayloadGroup" == childName))
1974
+ {
1975
+ childValue = new PayloadGroup();
1976
+ }
1977
+ if (("PayloadGroupRef" == childName))
1978
+ {
1979
+ childValue = new PayloadGroupRef();
1980
+ }
1981
+ if (("RelatedBundle" == childName))
1982
+ {
1983
+ childValue = new RelatedBundle();
1984
+ }
1985
+ if (("Update" == childName))
1986
+ {
1987
+ childValue = new Update();
1988
+ }
1989
+ if (("Variable" == childName))
1990
+ {
1991
+ childValue = new Variable();
1992
+ }
1993
+ if (("WixVariable" == childName))
1994
+ {
1995
+ childValue = new WixVariable();
1996
+ }
1997
+ if ((null == childValue))
1998
+ {
1999
+ throw new InvalidOperationException(String.Concat(childName, " is not a valid child name."));
2000
+ }
2001
+ return childValue;
2002
+ }
2003
+
2004
+ /// <summary>
2005
+ /// Processes this element and all child elements into an XmlWriter.
2006
+ /// </summary>
2007
+ [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
2008
+ public virtual void OutputXml(XmlWriter writer)
2009
+ {
2010
+ if ((null == writer))
2011
+ {
2012
+ throw new ArgumentNullException("writer");
2013
+ }
2014
+ writer.WriteStartElement("Bundle", "http://wixtoolset.org/schemas/v4/wxs");
2015
+ if (this.aboutUrlFieldSet)
2016
+ {
2017
+ writer.WriteAttributeString("AboutUrl", this.aboutUrlField);
2018
+ }
2019
+ if (this.copyrightFieldSet)
2020
+ {
2021
+ writer.WriteAttributeString("Copyright", this.copyrightField);
2022
+ }
2023
+ if (this.compressedFieldSet)
2024
+ {
2025
+ if ((this.compressedField == YesNoDefaultType.@default))
2026
+ {
2027
+ writer.WriteAttributeString("Compressed", "default");
2028
+ }
2029
+ if ((this.compressedField == YesNoDefaultType.no))
2030
+ {
2031
+ writer.WriteAttributeString("Compressed", "no");
2032
+ }
2033
+ if ((this.compressedField == YesNoDefaultType.yes))
2034
+ {
2035
+ writer.WriteAttributeString("Compressed", "yes");
2036
+ }
2037
+ }
2038
+ if (this.disableModifyFieldSet)
2039
+ {
2040
+ if ((this.disableModifyField == YesNoButtonType.no))
2041
+ {
2042
+ writer.WriteAttributeString("DisableModify", "no");
2043
+ }
2044
+ if ((this.disableModifyField == YesNoButtonType.yes))
2045
+ {
2046
+ writer.WriteAttributeString("DisableModify", "yes");
2047
+ }
2048
+ if ((this.disableModifyField == YesNoButtonType.button))
2049
+ {
2050
+ writer.WriteAttributeString("DisableModify", "button");
2051
+ }
2052
+ }
2053
+ if (this.disableRemoveFieldSet)
2054
+ {
2055
+ if ((this.disableRemoveField == YesNoType.no))
2056
+ {
2057
+ writer.WriteAttributeString("DisableRemove", "no");
2058
+ }
2059
+ if ((this.disableRemoveField == YesNoType.yes))
2060
+ {
2061
+ writer.WriteAttributeString("DisableRemove", "yes");
2062
+ }
2063
+ }
2064
+ if (this.disableRepairFieldSet)
2065
+ {
2066
+ if ((this.disableRepairField == YesNoType.no))
2067
+ {
2068
+ writer.WriteAttributeString("DisableRepair", "no");
2069
+ }
2070
+ if ((this.disableRepairField == YesNoType.yes))
2071
+ {
2072
+ writer.WriteAttributeString("DisableRepair", "yes");
2073
+ }
2074
+ }
2075
+ if (this.helpTelephoneFieldSet)
2076
+ {
2077
+ writer.WriteAttributeString("HelpTelephone", this.helpTelephoneField);
2078
+ }
2079
+ if (this.helpUrlFieldSet)
2080
+ {
2081
+ writer.WriteAttributeString("HelpUrl", this.helpUrlField);
2082
+ }
2083
+ if (this.iconSourceFileFieldSet)
2084
+ {
2085
+ writer.WriteAttributeString("IconSourceFile", this.iconSourceFileField);
2086
+ }
2087
+ if (this.manufacturerFieldSet)
2088
+ {
2089
+ writer.WriteAttributeString("Manufacturer", this.manufacturerField);
2090
+ }
2091
+ if (this.nameFieldSet)
2092
+ {
2093
+ writer.WriteAttributeString("Name", this.nameField);
2094
+ }
2095
+ if (this.parentNameFieldSet)
2096
+ {
2097
+ writer.WriteAttributeString("ParentName", this.parentNameField);
2098
+ }
2099
+ if (this.splashScreenSourceFileFieldSet)
2100
+ {
2101
+ writer.WriteAttributeString("SplashScreenSourceFile", this.splashScreenSourceFileField);
2102
+ }
2103
+ if (this.tagFieldSet)
2104
+ {
2105
+ writer.WriteAttributeString("Tag", this.tagField);
2106
+ }
2107
+ if (this.updateUrlFieldSet)
2108
+ {
2109
+ writer.WriteAttributeString("UpdateUrl", this.updateUrlField);
2110
+ }
2111
+ if (this.upgradeCodeFieldSet)
2112
+ {
2113
+ writer.WriteAttributeString("UpgradeCode", this.upgradeCodeField);
2114
+ }
2115
+ if (this.versionFieldSet)
2116
+ {
2117
+ writer.WriteAttributeString("Version", this.versionField);
2118
+ }
2119
+ if (this.conditionFieldSet)
2120
+ {
2121
+ writer.WriteAttributeString("Condition", this.conditionField);
2122
+ }
2123
+ for (IEnumerator enumerator = this.children.GetEnumerator(); enumerator.MoveNext(); )
2124
+ {
2125
+ ISchemaElement childElement = ((ISchemaElement)(enumerator.Current));
2126
+ childElement.OutputXml(writer);
2127
+ }
2128
+ writer.WriteEndElement();
2129
+ }
2130
+
2131
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
2132
+ [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
2133
+ void ISetAttributes.SetAttribute(string name, string value)
2134
+ {
2135
+ if (String.IsNullOrEmpty(name))
2136
+ {
2137
+ throw new ArgumentNullException("name");
2138
+ }
2139
+ if (("AboutUrl" == name))
2140
+ {
2141
+ this.aboutUrlField = value;
2142
+ this.aboutUrlFieldSet = true;
2143
+ }
2144
+ if (("Copyright" == name))
2145
+ {
2146
+ this.copyrightField = value;
2147
+ this.copyrightFieldSet = true;
2148
+ }
2149
+ if (("Compressed" == name))
2150
+ {
2151
+ this.compressedField = Enums.ParseYesNoDefaultType(value);
2152
+ this.compressedFieldSet = true;
2153
+ }
2154
+ if (("DisableModify" == name))
2155
+ {
2156
+ this.disableModifyField = Enums.ParseYesNoButtonType(value);
2157
+ this.disableModifyFieldSet = true;
2158
+ }
2159
+ if (("DisableRemove" == name))
2160
+ {
2161
+ this.disableRemoveField = Enums.ParseYesNoType(value);
2162
+ this.disableRemoveFieldSet = true;
2163
+ }
2164
+ if (("DisableRepair" == name))
2165
+ {
2166
+ this.disableRepairField = Enums.ParseYesNoType(value);
2167
+ this.disableRepairFieldSet = true;
2168
+ }
2169
+ if (("HelpTelephone" == name))
2170
+ {
2171
+ this.helpTelephoneField = value;
2172
+ this.helpTelephoneFieldSet = true;
2173
+ }
2174
+ if (("HelpUrl" == name))
2175
+ {
2176
+ this.helpUrlField = value;
2177
+ this.helpUrlFieldSet = true;
2178
+ }
2179
+ if (("IconSourceFile" == name))
2180
+ {
2181
+ this.iconSourceFileField = value;
2182
+ this.iconSourceFileFieldSet = true;
2183
+ }
2184
+ if (("Manufacturer" == name))
2185
+ {
2186
+ this.manufacturerField = value;
2187
+ this.manufacturerFieldSet = true;
2188
+ }
2189
+ if (("Name" == name))
2190
+ {
2191
+ this.nameField = value;
2192
+ this.nameFieldSet = true;
2193
+ }
2194
+ if (("ParentName" == name))
2195
+ {
2196
+ this.parentNameField = value;
2197
+ this.parentNameFieldSet = true;
2198
+ }
2199
+ if (("SplashScreenSourceFile" == name))
2200
+ {
2201
+ this.splashScreenSourceFileField = value;
2202
+ this.splashScreenSourceFileFieldSet = true;
2203
+ }
2204
+ if (("Tag" == name))
2205
+ {
2206
+ this.tagField = value;
2207
+ this.tagFieldSet = true;
2208
+ }
2209
+ if (("UpdateUrl" == name))
2210
+ {
2211
+ this.updateUrlField = value;
2212
+ this.updateUrlFieldSet = true;
2213
+ }
2214
+ if (("UpgradeCode" == name))
2215
+ {
2216
+ this.upgradeCodeField = value;
2217
+ this.upgradeCodeFieldSet = true;
2218
+ }
2219
+ if (("Version" == name))
2220
+ {
2221
+ this.versionField = value;
2222
+ this.versionFieldSet = true;
2223
+ }
2224
+ if (("Condition" == name))
2225
+ {
2226
+ this.conditionField = value;
2227
+ this.conditionFieldSet = true;
2228
+ }
2229
+ }
2230
+ }
2231
+
2232
+ /// <summary>
2233
+ /// Provides information about an .exe so that the BA can request the engine to run it elevated from any secure location.
2234
+ /// </summary>
2235
+ [GeneratedCode("WixBuildTools.XsdGen", "4.0.0.0")]
2236
+ public class ApprovedExeForElevation : ISchemaElement, ISetAttributes
2237
+ {
2238
+
2239
+ private string idField;
2240
+
2241
+ private bool idFieldSet;
2242
+
2243
+ private string keyField;
2244
+
2245
+ private bool keyFieldSet;
2246
+
2247
+ private string valueField;
2248
+
2249
+ private bool valueFieldSet;
2250
+
2251
+ private YesNoType win64Field;
2252
+
2253
+ private bool win64FieldSet;
2254
+
2255
+ private ISchemaElement parentElement;
2256
+
2257
+ /// <summary>
2258
+ /// The identifier of the ApprovedExeForElevation element.
2259
+ /// </summary>
2260
+ public string Id
2261
+ {
2262
+ get
2263
+ {
2264
+ return this.idField;
2265
+ }
2266
+ set
2267
+ {
2268
+ this.idFieldSet = true;
2269
+ this.idField = value;
2270
+ }
2271
+ }
2272
+
2273
+ /// <summary>
2274
+ /// The key path.
2275
+ /// For security purposes, the root key will be HKLM and Variables are not supported.
2276
+ /// </summary>
2277
+ public string Key
2278
+ {
2279
+ get
2280
+ {
2281
+ return this.keyField;
2282
+ }
2283
+ set
2284
+ {
2285
+ this.keyFieldSet = true;
2286
+ this.keyField = value;
2287
+ }
2288
+ }
2289
+
2290
+ /// <summary>
2291
+ /// The value name.
2292
+ /// For security purposes, Variables are not supported.
2293
+ /// </summary>
2294
+ public string Value
2295
+ {
2296
+ get
2297
+ {
2298
+ return this.valueField;
2299
+ }
2300
+ set
2301
+ {
2302
+ this.valueFieldSet = true;
2303
+ this.valueField = value;
2304
+ }
2305
+ }
2306
+
2307
+ /// <summary>
2308
+ /// Instructs the search to look in the 64-bit registry when the value is 'yes'.
2309
+ /// When the value is 'no', the search looks in the 32-bit registry.
2310
+ /// The default value is 'no'.
2311
+ /// </summary>
2312
+ public YesNoType Win64
2313
+ {
2314
+ get
2315
+ {
2316
+ return this.win64Field;
2317
+ }
2318
+ set
2319
+ {
2320
+ this.win64FieldSet = true;
2321
+ this.win64Field = value;
2322
+ }
2323
+ }
2324
+
2325
+ public virtual ISchemaElement ParentElement
2326
+ {
2327
+ get
2328
+ {
2329
+ return this.parentElement;
2330
+ }
2331
+ set
2332
+ {
2333
+ this.parentElement = value;
2334
+ }
2335
+ }
2336
+
2337
+ /// <summary>
2338
+ /// Processes this element and all child elements into an XmlWriter.
2339
+ /// </summary>
2340
+ public virtual void OutputXml(XmlWriter writer)
2341
+ {
2342
+ if ((null == writer))
2343
+ {
2344
+ throw new ArgumentNullException("writer");
2345
+ }
2346
+ writer.WriteStartElement("ApprovedExeForElevation", "http://wixtoolset.org/schemas/v4/wxs");
2347
+ if (this.idFieldSet)
2348
+ {
2349
+ writer.WriteAttributeString("Id", this.idField);
2350
+ }
2351
+ if (this.keyFieldSet)
2352
+ {
2353
+ writer.WriteAttributeString("Key", this.keyField);
2354
+ }
2355
+ if (this.valueFieldSet)
2356
+ {
2357
+ writer.WriteAttributeString("Value", this.valueField);
2358
+ }
2359
+ if (this.win64FieldSet)
2360
+ {
2361
+ if ((this.win64Field == YesNoType.no))
2362
+ {
2363
+ writer.WriteAttributeString("Win64", "no");
2364
+ }
2365
+ if ((this.win64Field == YesNoType.yes))
2366
+ {
2367
+ writer.WriteAttributeString("Win64", "yes");
2368
+ }
2369
+ }
2370
+ writer.WriteEndElement();
2371
+ }
2372
+
2373
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
2374
+ void ISetAttributes.SetAttribute(string name, string value)
2375
+ {
2376
+ if (String.IsNullOrEmpty(name))
2377
+ {
2378
+ throw new ArgumentNullException("name");
2379
+ }
2380
+ if (("Id" == name))
2381
+ {
2382
+ this.idField = value;
2383
+ this.idFieldSet = true;
2384
+ }
2385
+ if (("Key" == name))
2386
+ {
2387
+ this.keyField = value;
2388
+ this.keyFieldSet = true;
2389
+ }
2390
+ if (("Value" == name))
2391
+ {
2392
+ this.valueField = value;
2393
+ this.valueFieldSet = true;
2394
+ }
2395
+ if (("Win64" == name))
2396
+ {
2397
+ this.win64Field = Enums.ParseYesNoType(value);
2398
+ this.win64FieldSet = true;
2399
+ }
2400
+ }
2401
+ }
2402
+
2403
+ /// <summary>
2404
+ /// Overrides the default log settings for a bundle.
2405
+ /// </summary>
2406
+ [GeneratedCode("WixBuildTools.XsdGen", "4.0.0.0")]
2407
+ public class Log : ISchemaElement, ISetAttributes
2408
+ {
2409
+
2410
+ private YesNoType disableField;
2411
+
2412
+ private bool disableFieldSet;
2413
+
2414
+ private string pathVariableField;
2415
+
2416
+ private bool pathVariableFieldSet;
2417
+
2418
+ private string prefixField;
2419
+
2420
+ private bool prefixFieldSet;
2421
+
2422
+ private string extensionField;
2423
+
2424
+ private bool extensionFieldSet;
2425
+
2426
+ private ISchemaElement parentElement;
2427
+
2428
+ /// <summary>
2429
+ /// Disables the default logging in the Bundle. The end user can still generate a
2430
+ /// log file by specifying the "-l" command-line argument when installing the
2431
+ /// Bundle.
2432
+ /// </summary>
2433
+ public YesNoType Disable
2434
+ {
2435
+ get
2436
+ {
2437
+ return this.disableField;
2438
+ }
2439
+ set
2440
+ {
2441
+ this.disableFieldSet = true;
2442
+ this.disableField = value;
2443
+ }
2444
+ }
2445
+
2446
+ /// <summary>
2447
+ /// Name of a Variable that will hold the path to the log file. An empty value
2448
+ /// will cause the variable to not be set. The default is "WixBundleLog".
2449
+ /// </summary>
2450
+ public string PathVariable
2451
+ {
2452
+ get
2453
+ {
2454
+ return this.pathVariableField;
2455
+ }
2456
+ set
2457
+ {
2458
+ this.pathVariableFieldSet = true;
2459
+ this.pathVariableField = value;
2460
+ }
2461
+ }
2462
+
2463
+ /// <summary>
2464
+ /// File name and optionally a relative path to use as the prefix for the log file. The
2465
+ /// default is to use the Bundle/@Name or, if Bundle/@Name is not specified, the value
2466
+ /// "Setup".
2467
+ /// </summary>
2468
+ public string Prefix
2469
+ {
2470
+ get
2471
+ {
2472
+ return this.prefixField;
2473
+ }
2474
+ set
2475
+ {
2476
+ this.prefixFieldSet = true;
2477
+ this.prefixField = value;
2478
+ }
2479
+ }
2480
+
2481
+ /// <summary>
2482
+ /// The extension to use for the log. The default is ".log".
2483
+ /// </summary>
2484
+ public string Extension
2485
+ {
2486
+ get
2487
+ {
2488
+ return this.extensionField;
2489
+ }
2490
+ set
2491
+ {
2492
+ this.extensionFieldSet = true;
2493
+ this.extensionField = value;
2494
+ }
2495
+ }
2496
+
2497
+ public virtual ISchemaElement ParentElement
2498
+ {
2499
+ get
2500
+ {
2501
+ return this.parentElement;
2502
+ }
2503
+ set
2504
+ {
2505
+ this.parentElement = value;
2506
+ }
2507
+ }
2508
+
2509
+ /// <summary>
2510
+ /// Processes this element and all child elements into an XmlWriter.
2511
+ /// </summary>
2512
+ public virtual void OutputXml(XmlWriter writer)
2513
+ {
2514
+ if ((null == writer))
2515
+ {
2516
+ throw new ArgumentNullException("writer");
2517
+ }
2518
+ writer.WriteStartElement("Log", "http://wixtoolset.org/schemas/v4/wxs");
2519
+ if (this.disableFieldSet)
2520
+ {
2521
+ if ((this.disableField == YesNoType.no))
2522
+ {
2523
+ writer.WriteAttributeString("Disable", "no");
2524
+ }
2525
+ if ((this.disableField == YesNoType.yes))
2526
+ {
2527
+ writer.WriteAttributeString("Disable", "yes");
2528
+ }
2529
+ }
2530
+ if (this.pathVariableFieldSet)
2531
+ {
2532
+ writer.WriteAttributeString("PathVariable", this.pathVariableField);
2533
+ }
2534
+ if (this.prefixFieldSet)
2535
+ {
2536
+ writer.WriteAttributeString("Prefix", this.prefixField);
2537
+ }
2538
+ if (this.extensionFieldSet)
2539
+ {
2540
+ writer.WriteAttributeString("Extension", this.extensionField);
2541
+ }
2542
+ writer.WriteEndElement();
2543
+ }
2544
+
2545
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
2546
+ void ISetAttributes.SetAttribute(string name, string value)
2547
+ {
2548
+ if (String.IsNullOrEmpty(name))
2549
+ {
2550
+ throw new ArgumentNullException("name");
2551
+ }
2552
+ if (("Disable" == name))
2553
+ {
2554
+ this.disableField = Enums.ParseYesNoType(value);
2555
+ this.disableFieldSet = true;
2556
+ }
2557
+ if (("PathVariable" == name))
2558
+ {
2559
+ this.pathVariableField = value;
2560
+ this.pathVariableFieldSet = true;
2561
+ }
2562
+ if (("Prefix" == name))
2563
+ {
2564
+ this.prefixField = value;
2565
+ this.prefixFieldSet = true;
2566
+ }
2567
+ if (("Extension" == name))
2568
+ {
2569
+ this.extensionField = value;
2570
+ this.extensionFieldSet = true;
2571
+ }
2572
+ }
2573
+ }
2574
+
2575
+ /// <summary>
2576
+ /// Specify one or more catalog files that will be used to verify the contents of the bundle.
2577
+ /// </summary>
2578
+ [GeneratedCode("WixBuildTools.XsdGen", "4.0.0.0")]
2579
+ public class Catalog : ISchemaElement, ISetAttributes
2580
+ {
2581
+
2582
+ private string idField;
2583
+
2584
+ private bool idFieldSet;
2585
+
2586
+ private string sourceFileField;
2587
+
2588
+ private bool sourceFileFieldSet;
2589
+
2590
+ private ISchemaElement parentElement;
2591
+
2592
+ /// <summary>
2593
+ /// The identifier of the catalog element.
2594
+ /// </summary>
2595
+ public string Id
2596
+ {
2597
+ get
2598
+ {
2599
+ return this.idField;
2600
+ }
2601
+ set
2602
+ {
2603
+ this.idFieldSet = true;
2604
+ this.idField = value;
2605
+ }
2606
+ }
2607
+
2608
+ /// <summary>
2609
+ /// The catalog file
2610
+ /// </summary>
2611
+ public string SourceFile
2612
+ {
2613
+ get
2614
+ {
2615
+ return this.sourceFileField;
2616
+ }
2617
+ set
2618
+ {
2619
+ this.sourceFileFieldSet = true;
2620
+ this.sourceFileField = value;
2621
+ }
2622
+ }
2623
+
2624
+ public virtual ISchemaElement ParentElement
2625
+ {
2626
+ get
2627
+ {
2628
+ return this.parentElement;
2629
+ }
2630
+ set
2631
+ {
2632
+ this.parentElement = value;
2633
+ }
2634
+ }
2635
+
2636
+ /// <summary>
2637
+ /// Processes this element and all child elements into an XmlWriter.
2638
+ /// </summary>
2639
+ public virtual void OutputXml(XmlWriter writer)
2640
+ {
2641
+ if ((null == writer))
2642
+ {
2643
+ throw new ArgumentNullException("writer");
2644
+ }
2645
+ writer.WriteStartElement("Catalog", "http://wixtoolset.org/schemas/v4/wxs");
2646
+ if (this.idFieldSet)
2647
+ {
2648
+ writer.WriteAttributeString("Id", this.idField);
2649
+ }
2650
+ if (this.sourceFileFieldSet)
2651
+ {
2652
+ writer.WriteAttributeString("SourceFile", this.sourceFileField);
2653
+ }
2654
+ writer.WriteEndElement();
2655
+ }
2656
+
2657
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
2658
+ void ISetAttributes.SetAttribute(string name, string value)
2659
+ {
2660
+ if (String.IsNullOrEmpty(name))
2661
+ {
2662
+ throw new ArgumentNullException("name");
2663
+ }
2664
+ if (("Id" == name))
2665
+ {
2666
+ this.idField = value;
2667
+ this.idFieldSet = true;
2668
+ }
2669
+ if (("SourceFile" == name))
2670
+ {
2671
+ this.sourceFileField = value;
2672
+ this.sourceFileFieldSet = true;
2673
+ }
2674
+ }
2675
+ }
2676
+
2677
+ /// <summary>
2678
+ /// Contains all the relevant information about the setup UI.
2679
+ /// </summary>
2680
+ [GeneratedCode("WixBuildTools.XsdGen", "4.0.0.0")]
2681
+ public class BootstrapperApplication : IParentElement, ICreateChildren, ISchemaElement, ISetAttributes
2682
+ {
2683
+
2684
+ private ElementCollection children;
2685
+
2686
+ private string idField;
2687
+
2688
+ private bool idFieldSet;
2689
+
2690
+ private string sourceFileField;
2691
+
2692
+ private bool sourceFileFieldSet;
2693
+
2694
+ private string nameField;
2695
+
2696
+ private bool nameFieldSet;
2697
+
2698
+ private ISchemaElement parentElement;
2699
+
2700
+ public BootstrapperApplication()
2701
+ {
2702
+ ElementCollection childCollection0 = new ElementCollection(ElementCollection.CollectionType.Choice);
2703
+ childCollection0.AddItem(new ElementCollection.ChoiceItem(typeof(Payload)));
2704
+ childCollection0.AddItem(new ElementCollection.ChoiceItem(typeof(PayloadGroupRef)));
2705
+ childCollection0.AddItem(new ElementCollection.ChoiceItem(typeof(ISchemaElement)));
2706
+ this.children = childCollection0;
2707
+ }
2708
+
2709
+ public virtual IEnumerable Children
2710
+ {
2711
+ get
2712
+ {
2713
+ return this.children;
2714
+ }
2715
+ }
2716
+
2717
+ [SuppressMessage("Microsoft.Design", "CA1043:UseIntegralOrStringArgumentForIndexers")]
2718
+ public virtual IEnumerable this[System.Type childType]
2719
+ {
2720
+ get
2721
+ {
2722
+ return this.children.Filter(childType);
2723
+ }
2724
+ }
2725
+
2726
+ /// <summary>
2727
+ /// The identifier of the BootstrapperApplication element. Only required if you want to reference this element using a BootstrapperApplicationRef element.
2728
+ /// </summary>
2729
+ public string Id
2730
+ {
2731
+ get
2732
+ {
2733
+ return this.idField;
2734
+ }
2735
+ set
2736
+ {
2737
+ this.idFieldSet = true;
2738
+ this.idField = value;
2739
+ }
2740
+ }
2741
+
2742
+ /// <summary>
2743
+ /// The DLL with the bootstrapper application entry function.
2744
+ /// </summary>
2745
+ public string SourceFile
2746
+ {
2747
+ get
2748
+ {
2749
+ return this.sourceFileField;
2750
+ }
2751
+ set
2752
+ {
2753
+ this.sourceFileFieldSet = true;
2754
+ this.sourceFileField = value;
2755
+ }
2756
+ }
2757
+
2758
+ /// <summary>
2759
+ /// The relative destination path and file name for the bootstrapper application DLL. The default is the source file name. Use this attribute to rename the bootstrapper application DLL or extract it into a subfolder. The use of '..' directories is not allowed.
2760
+ /// </summary>
2761
+ public string Name
2762
+ {
2763
+ get
2764
+ {
2765
+ return this.nameField;
2766
+ }
2767
+ set
2768
+ {
2769
+ this.nameFieldSet = true;
2770
+ this.nameField = value;
2771
+ }
2772
+ }
2773
+
2774
+ public virtual ISchemaElement ParentElement
2775
+ {
2776
+ get
2777
+ {
2778
+ return this.parentElement;
2779
+ }
2780
+ set
2781
+ {
2782
+ this.parentElement = value;
2783
+ }
2784
+ }
2785
+
2786
+ public virtual void AddChild(ISchemaElement child)
2787
+ {
2788
+ if ((null == child))
2789
+ {
2790
+ throw new ArgumentNullException("child");
2791
+ }
2792
+ this.children.AddElement(child);
2793
+ child.ParentElement = this;
2794
+ }
2795
+
2796
+ public virtual void RemoveChild(ISchemaElement child)
2797
+ {
2798
+ if ((null == child))
2799
+ {
2800
+ throw new ArgumentNullException("child");
2801
+ }
2802
+ this.children.RemoveElement(child);
2803
+ child.ParentElement = null;
2804
+ }
2805
+
2806
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
2807
+ ISchemaElement ICreateChildren.CreateChild(string childName)
2808
+ {
2809
+ if (String.IsNullOrEmpty(childName))
2810
+ {
2811
+ throw new ArgumentNullException("childName");
2812
+ }
2813
+ ISchemaElement childValue = null;
2814
+ if (("Payload" == childName))
2815
+ {
2816
+ childValue = new Payload();
2817
+ }
2818
+ if (("PayloadGroupRef" == childName))
2819
+ {
2820
+ childValue = new PayloadGroupRef();
2821
+ }
2822
+ if ((null == childValue))
2823
+ {
2824
+ throw new InvalidOperationException(String.Concat(childName, " is not a valid child name."));
2825
+ }
2826
+ return childValue;
2827
+ }
2828
+
2829
+ /// <summary>
2830
+ /// Processes this element and all child elements into an XmlWriter.
2831
+ /// </summary>
2832
+ public virtual void OutputXml(XmlWriter writer)
2833
+ {
2834
+ if ((null == writer))
2835
+ {
2836
+ throw new ArgumentNullException("writer");
2837
+ }
2838
+ writer.WriteStartElement("BootstrapperApplication", "http://wixtoolset.org/schemas/v4/wxs");
2839
+ if (this.idFieldSet)
2840
+ {
2841
+ writer.WriteAttributeString("Id", this.idField);
2842
+ }
2843
+ if (this.sourceFileFieldSet)
2844
+ {
2845
+ writer.WriteAttributeString("SourceFile", this.sourceFileField);
2846
+ }
2847
+ if (this.nameFieldSet)
2848
+ {
2849
+ writer.WriteAttributeString("Name", this.nameField);
2850
+ }
2851
+ for (IEnumerator enumerator = this.children.GetEnumerator(); enumerator.MoveNext(); )
2852
+ {
2853
+ ISchemaElement childElement = ((ISchemaElement)(enumerator.Current));
2854
+ childElement.OutputXml(writer);
2855
+ }
2856
+ writer.WriteEndElement();
2857
+ }
2858
+
2859
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
2860
+ void ISetAttributes.SetAttribute(string name, string value)
2861
+ {
2862
+ if (String.IsNullOrEmpty(name))
2863
+ {
2864
+ throw new ArgumentNullException("name");
2865
+ }
2866
+ if (("Id" == name))
2867
+ {
2868
+ this.idField = value;
2869
+ this.idFieldSet = true;
2870
+ }
2871
+ if (("SourceFile" == name))
2872
+ {
2873
+ this.sourceFileField = value;
2874
+ this.sourceFileFieldSet = true;
2875
+ }
2876
+ if (("Name" == name))
2877
+ {
2878
+ this.nameField = value;
2879
+ this.nameFieldSet = true;
2880
+ }
2881
+ }
2882
+ }
2883
+
2884
+ /// <summary>
2885
+ /// Used to reference a BootstrapperApplication element and optionally add additional payloads to the bootstrapper application.
2886
+ /// </summary>
2887
+ [GeneratedCode("WixBuildTools.XsdGen", "4.0.0.0")]
2888
+ public class BootstrapperApplicationRef : IParentElement, ICreateChildren, ISchemaElement, ISetAttributes
2889
+ {
2890
+
2891
+ private ElementCollection children;
2892
+
2893
+ private string idField;
2894
+
2895
+ private bool idFieldSet;
2896
+
2897
+ private ISchemaElement parentElement;
2898
+
2899
+ public BootstrapperApplicationRef()
2900
+ {
2901
+ ElementCollection childCollection0 = new ElementCollection(ElementCollection.CollectionType.Choice);
2902
+ childCollection0.AddItem(new ElementCollection.ChoiceItem(typeof(Payload)));
2903
+ childCollection0.AddItem(new ElementCollection.ChoiceItem(typeof(PayloadGroupRef)));
2904
+ childCollection0.AddItem(new ElementCollection.ChoiceItem(typeof(ISchemaElement)));
2905
+ this.children = childCollection0;
2906
+ }
2907
+
2908
+ public virtual IEnumerable Children
2909
+ {
2910
+ get
2911
+ {
2912
+ return this.children;
2913
+ }
2914
+ }
2915
+
2916
+ [SuppressMessage("Microsoft.Design", "CA1043:UseIntegralOrStringArgumentForIndexers")]
2917
+ public virtual IEnumerable this[System.Type childType]
2918
+ {
2919
+ get
2920
+ {
2921
+ return this.children.Filter(childType);
2922
+ }
2923
+ }
2924
+
2925
+ /// <summary>
2926
+ /// The identifier of the BootstrapperApplication element to reference.
2927
+ /// </summary>
2928
+ public string Id
2929
+ {
2930
+ get
2931
+ {
2932
+ return this.idField;
2933
+ }
2934
+ set
2935
+ {
2936
+ this.idFieldSet = true;
2937
+ this.idField = value;
2938
+ }
2939
+ }
2940
+
2941
+ public virtual ISchemaElement ParentElement
2942
+ {
2943
+ get
2944
+ {
2945
+ return this.parentElement;
2946
+ }
2947
+ set
2948
+ {
2949
+ this.parentElement = value;
2950
+ }
2951
+ }
2952
+
2953
+ public virtual void AddChild(ISchemaElement child)
2954
+ {
2955
+ if ((null == child))
2956
+ {
2957
+ throw new ArgumentNullException("child");
2958
+ }
2959
+ this.children.AddElement(child);
2960
+ child.ParentElement = this;
2961
+ }
2962
+
2963
+ public virtual void RemoveChild(ISchemaElement child)
2964
+ {
2965
+ if ((null == child))
2966
+ {
2967
+ throw new ArgumentNullException("child");
2968
+ }
2969
+ this.children.RemoveElement(child);
2970
+ child.ParentElement = null;
2971
+ }
2972
+
2973
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
2974
+ ISchemaElement ICreateChildren.CreateChild(string childName)
2975
+ {
2976
+ if (String.IsNullOrEmpty(childName))
2977
+ {
2978
+ throw new ArgumentNullException("childName");
2979
+ }
2980
+ ISchemaElement childValue = null;
2981
+ if (("Payload" == childName))
2982
+ {
2983
+ childValue = new Payload();
2984
+ }
2985
+ if (("PayloadGroupRef" == childName))
2986
+ {
2987
+ childValue = new PayloadGroupRef();
2988
+ }
2989
+ if ((null == childValue))
2990
+ {
2991
+ throw new InvalidOperationException(String.Concat(childName, " is not a valid child name."));
2992
+ }
2993
+ return childValue;
2994
+ }
2995
+
2996
+ /// <summary>
2997
+ /// Processes this element and all child elements into an XmlWriter.
2998
+ /// </summary>
2999
+ public virtual void OutputXml(XmlWriter writer)
3000
+ {
3001
+ if ((null == writer))
3002
+ {
3003
+ throw new ArgumentNullException("writer");
3004
+ }
3005
+ writer.WriteStartElement("BootstrapperApplicationRef", "http://wixtoolset.org/schemas/v4/wxs");
3006
+ if (this.idFieldSet)
3007
+ {
3008
+ writer.WriteAttributeString("Id", this.idField);
3009
+ }
3010
+ for (IEnumerator enumerator = this.children.GetEnumerator(); enumerator.MoveNext(); )
3011
+ {
3012
+ ISchemaElement childElement = ((ISchemaElement)(enumerator.Current));
3013
+ childElement.OutputXml(writer);
3014
+ }
3015
+ writer.WriteEndElement();
3016
+ }
3017
+
3018
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
3019
+ void ISetAttributes.SetAttribute(string name, string value)
3020
+ {
3021
+ if (String.IsNullOrEmpty(name))
3022
+ {
3023
+ throw new ArgumentNullException("name");
3024
+ }
3025
+ if (("Id" == name))
3026
+ {
3027
+ this.idField = value;
3028
+ this.idFieldSet = true;
3029
+ }
3030
+ }
3031
+ }
3032
+
3033
+ /// <summary>
3034
+ /// This element has been deprecated. Use the BootstrapperApplication element instead.
3035
+ /// </summary>
3036
+ [GeneratedCode("WixBuildTools.XsdGen", "4.0.0.0")]
3037
+ public class UX : IParentElement, ICreateChildren, ISchemaElement, ISetAttributes
3038
+ {
3039
+
3040
+ private ElementCollection children;
3041
+
3042
+ private string sourceFileField;
3043
+
3044
+ private bool sourceFileFieldSet;
3045
+
3046
+ private string nameField;
3047
+
3048
+ private bool nameFieldSet;
3049
+
3050
+ private string splashScreenSourceFileField;
3051
+
3052
+ private bool splashScreenSourceFileFieldSet;
3053
+
3054
+ private ISchemaElement parentElement;
3055
+
3056
+ public UX()
3057
+ {
3058
+ ElementCollection childCollection0 = new ElementCollection(ElementCollection.CollectionType.Choice);
3059
+ childCollection0.AddItem(new ElementCollection.ChoiceItem(typeof(Payload)));
3060
+ childCollection0.AddItem(new ElementCollection.ChoiceItem(typeof(PayloadGroupRef)));
3061
+ this.children = childCollection0;
3062
+ }
3063
+
3064
+ public virtual IEnumerable Children
3065
+ {
3066
+ get
3067
+ {
3068
+ return this.children;
3069
+ }
3070
+ }
3071
+
3072
+ [SuppressMessage("Microsoft.Design", "CA1043:UseIntegralOrStringArgumentForIndexers")]
3073
+ public virtual IEnumerable this[System.Type childType]
3074
+ {
3075
+ get
3076
+ {
3077
+ return this.children.Filter(childType);
3078
+ }
3079
+ }
3080
+
3081
+ /// <summary>
3082
+ /// See the BootstrapperApplication instead.
3083
+ /// </summary>
3084
+ public string SourceFile
3085
+ {
3086
+ get
3087
+ {
3088
+ return this.sourceFileField;
3089
+ }
3090
+ set
3091
+ {
3092
+ this.sourceFileFieldSet = true;
3093
+ this.sourceFileField = value;
3094
+ }
3095
+ }
3096
+
3097
+ /// <summary>
3098
+ /// See the BootstrapperApplication instead.
3099
+ /// </summary>
3100
+ public string Name
3101
+ {
3102
+ get
3103
+ {
3104
+ return this.nameField;
3105
+ }
3106
+ set
3107
+ {
3108
+ this.nameFieldSet = true;
3109
+ this.nameField = value;
3110
+ }
3111
+ }
3112
+
3113
+ /// <summary>
3114
+ /// See the BootstrapperApplication instead.
3115
+ /// </summary>
3116
+ public string SplashScreenSourceFile
3117
+ {
3118
+ get
3119
+ {
3120
+ return this.splashScreenSourceFileField;
3121
+ }
3122
+ set
3123
+ {
3124
+ this.splashScreenSourceFileFieldSet = true;
3125
+ this.splashScreenSourceFileField = value;
3126
+ }
3127
+ }
3128
+
3129
+ public virtual ISchemaElement ParentElement
3130
+ {
3131
+ get
3132
+ {
3133
+ return this.parentElement;
3134
+ }
3135
+ set
3136
+ {
3137
+ this.parentElement = value;
3138
+ }
3139
+ }
3140
+
3141
+ public virtual void AddChild(ISchemaElement child)
3142
+ {
3143
+ if ((null == child))
3144
+ {
3145
+ throw new ArgumentNullException("child");
3146
+ }
3147
+ this.children.AddElement(child);
3148
+ child.ParentElement = this;
3149
+ }
3150
+
3151
+ public virtual void RemoveChild(ISchemaElement child)
3152
+ {
3153
+ if ((null == child))
3154
+ {
3155
+ throw new ArgumentNullException("child");
3156
+ }
3157
+ this.children.RemoveElement(child);
3158
+ child.ParentElement = null;
3159
+ }
3160
+
3161
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
3162
+ ISchemaElement ICreateChildren.CreateChild(string childName)
3163
+ {
3164
+ if (String.IsNullOrEmpty(childName))
3165
+ {
3166
+ throw new ArgumentNullException("childName");
3167
+ }
3168
+ ISchemaElement childValue = null;
3169
+ if (("Payload" == childName))
3170
+ {
3171
+ childValue = new Payload();
3172
+ }
3173
+ if (("PayloadGroupRef" == childName))
3174
+ {
3175
+ childValue = new PayloadGroupRef();
3176
+ }
3177
+ if ((null == childValue))
3178
+ {
3179
+ throw new InvalidOperationException(String.Concat(childName, " is not a valid child name."));
3180
+ }
3181
+ return childValue;
3182
+ }
3183
+
3184
+ /// <summary>
3185
+ /// Processes this element and all child elements into an XmlWriter.
3186
+ /// </summary>
3187
+ public virtual void OutputXml(XmlWriter writer)
3188
+ {
3189
+ if ((null == writer))
3190
+ {
3191
+ throw new ArgumentNullException("writer");
3192
+ }
3193
+ writer.WriteStartElement("UX", "http://wixtoolset.org/schemas/v4/wxs");
3194
+ if (this.sourceFileFieldSet)
3195
+ {
3196
+ writer.WriteAttributeString("SourceFile", this.sourceFileField);
3197
+ }
3198
+ if (this.nameFieldSet)
3199
+ {
3200
+ writer.WriteAttributeString("Name", this.nameField);
3201
+ }
3202
+ if (this.splashScreenSourceFileFieldSet)
3203
+ {
3204
+ writer.WriteAttributeString("SplashScreenSourceFile", this.splashScreenSourceFileField);
3205
+ }
3206
+ for (IEnumerator enumerator = this.children.GetEnumerator(); enumerator.MoveNext(); )
3207
+ {
3208
+ ISchemaElement childElement = ((ISchemaElement)(enumerator.Current));
3209
+ childElement.OutputXml(writer);
3210
+ }
3211
+ writer.WriteEndElement();
3212
+ }
3213
+
3214
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
3215
+ void ISetAttributes.SetAttribute(string name, string value)
3216
+ {
3217
+ if (String.IsNullOrEmpty(name))
3218
+ {
3219
+ throw new ArgumentNullException("name");
3220
+ }
3221
+ if (("SourceFile" == name))
3222
+ {
3223
+ this.sourceFileField = value;
3224
+ this.sourceFileFieldSet = true;
3225
+ }
3226
+ if (("Name" == name))
3227
+ {
3228
+ this.nameField = value;
3229
+ this.nameFieldSet = true;
3230
+ }
3231
+ if (("SplashScreenSourceFile" == name))
3232
+ {
3233
+ this.splashScreenSourceFileField = value;
3234
+ this.splashScreenSourceFileFieldSet = true;
3235
+ }
3236
+ }
3237
+ }
3238
+
3239
+ /// <summary>
3240
+ /// Writes additional information to the Windows registry that can be used to detect the bundle.
3241
+ /// This registration is intended primarily for update to an existing product.
3242
+ /// </summary>
3243
+ [GeneratedCode("WixBuildTools.XsdGen", "4.0.0.0")]
3244
+ public class OptionalUpdateRegistration : ISchemaElement, ISetAttributes
3245
+ {
3246
+
3247
+ private string manufacturerField;
3248
+
3249
+ private bool manufacturerFieldSet;
3250
+
3251
+ private string departmentField;
3252
+
3253
+ private bool departmentFieldSet;
3254
+
3255
+ private string productFamilyField;
3256
+
3257
+ private bool productFamilyFieldSet;
3258
+
3259
+ private string nameField;
3260
+
3261
+ private bool nameFieldSet;
3262
+
3263
+ private string classificationField;
3264
+
3265
+ private bool classificationFieldSet;
3266
+
3267
+ private ISchemaElement parentElement;
3268
+
3269
+ /// <summary>
3270
+ /// The name of the manufacturer. The default is the Bundle/@Manufacturer attribute,
3271
+ /// but may also be a short form, ex: Acme instead of Acme Corporation.
3272
+ /// An error is generated at build time if neither attribute is specified.
3273
+ /// </summary>
3274
+ public string Manufacturer
3275
+ {
3276
+ get
3277
+ {
3278
+ return this.manufacturerField;
3279
+ }
3280
+ set
3281
+ {
3282
+ this.manufacturerFieldSet = true;
3283
+ this.manufacturerField = value;
3284
+ }
3285
+ }
3286
+
3287
+ /// <summary>
3288
+ /// The name of the department or division publishing the update bundle.
3289
+ /// The PublishingGroup registry value is not written if this attribute is not specified.
3290
+ /// </summary>
3291
+ public string Department
3292
+ {
3293
+ get
3294
+ {
3295
+ return this.departmentField;
3296
+ }
3297
+ set
3298
+ {
3299
+ this.departmentFieldSet = true;
3300
+ this.departmentField = value;
3301
+ }
3302
+ }
3303
+
3304
+ /// <summary>
3305
+ /// The name of the family of products being updated. The default is the Bundle/@ParentName attribute.
3306
+ /// The corresponding registry key is not created if neither attribute is specified.
3307
+ /// </summary>
3308
+ public string ProductFamily
3309
+ {
3310
+ get
3311
+ {
3312
+ return this.productFamilyField;
3313
+ }
3314
+ set
3315
+ {
3316
+ this.productFamilyFieldSet = true;
3317
+ this.productFamilyField = value;
3318
+ }
3319
+ }
3320
+
3321
+ /// <summary>
3322
+ /// The name of the bundle. The default is the Bundle/@Name attribute,
3323
+ /// but may also be a short form, ex: KB12345 instead of Update to Product (KB12345).
3324
+ /// An error is generated at build time if neither attribute is specified.
3325
+ /// </summary>
3326
+ public string Name
3327
+ {
3328
+ get
3329
+ {
3330
+ return this.nameField;
3331
+ }
3332
+ set
3333
+ {
3334
+ this.nameFieldSet = true;
3335
+ this.nameField = value;
3336
+ }
3337
+ }
3338
+
3339
+ /// <summary>
3340
+ /// The release type of the update bundle, such as Update, Security Update, Service Pack, etc.
3341
+ /// The default value is Update.
3342
+ /// </summary>
3343
+ public string Classification
3344
+ {
3345
+ get
3346
+ {
3347
+ return this.classificationField;
3348
+ }
3349
+ set
3350
+ {
3351
+ this.classificationFieldSet = true;
3352
+ this.classificationField = value;
3353
+ }
3354
+ }
3355
+
3356
+ public virtual ISchemaElement ParentElement
3357
+ {
3358
+ get
3359
+ {
3360
+ return this.parentElement;
3361
+ }
3362
+ set
3363
+ {
3364
+ this.parentElement = value;
3365
+ }
3366
+ }
3367
+
3368
+ /// <summary>
3369
+ /// Processes this element and all child elements into an XmlWriter.
3370
+ /// </summary>
3371
+ public virtual void OutputXml(XmlWriter writer)
3372
+ {
3373
+ if ((null == writer))
3374
+ {
3375
+ throw new ArgumentNullException("writer");
3376
+ }
3377
+ writer.WriteStartElement("OptionalUpdateRegistration", "http://wixtoolset.org/schemas/v4/wxs");
3378
+ if (this.manufacturerFieldSet)
3379
+ {
3380
+ writer.WriteAttributeString("Manufacturer", this.manufacturerField);
3381
+ }
3382
+ if (this.departmentFieldSet)
3383
+ {
3384
+ writer.WriteAttributeString("Department", this.departmentField);
3385
+ }
3386
+ if (this.productFamilyFieldSet)
3387
+ {
3388
+ writer.WriteAttributeString("ProductFamily", this.productFamilyField);
3389
+ }
3390
+ if (this.nameFieldSet)
3391
+ {
3392
+ writer.WriteAttributeString("Name", this.nameField);
3393
+ }
3394
+ if (this.classificationFieldSet)
3395
+ {
3396
+ writer.WriteAttributeString("Classification", this.classificationField);
3397
+ }
3398
+ writer.WriteEndElement();
3399
+ }
3400
+
3401
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
3402
+ void ISetAttributes.SetAttribute(string name, string value)
3403
+ {
3404
+ if (String.IsNullOrEmpty(name))
3405
+ {
3406
+ throw new ArgumentNullException("name");
3407
+ }
3408
+ if (("Manufacturer" == name))
3409
+ {
3410
+ this.manufacturerField = value;
3411
+ this.manufacturerFieldSet = true;
3412
+ }
3413
+ if (("Department" == name))
3414
+ {
3415
+ this.departmentField = value;
3416
+ this.departmentFieldSet = true;
3417
+ }
3418
+ if (("ProductFamily" == name))
3419
+ {
3420
+ this.productFamilyField = value;
3421
+ this.productFamilyFieldSet = true;
3422
+ }
3423
+ if (("Name" == name))
3424
+ {
3425
+ this.nameField = value;
3426
+ this.nameFieldSet = true;
3427
+ }
3428
+ if (("Classification" == name))
3429
+ {
3430
+ this.classificationField = value;
3431
+ this.classificationFieldSet = true;
3432
+ }
3433
+ }
3434
+ }
3435
+
3436
+ /// <summary>
3437
+ /// Contains the chain of packages to install.
3438
+ /// </summary>
3439
+ [GeneratedCode("WixBuildTools.XsdGen", "4.0.0.0")]
3440
+ public class Chain : IParentElement, ICreateChildren, ISchemaElement, ISetAttributes
3441
+ {
3442
+
3443
+ private ElementCollection children;
3444
+
3445
+ private YesNoType disableRollbackField;
3446
+
3447
+ private bool disableRollbackFieldSet;
3448
+
3449
+ private YesNoType disableSystemRestoreField;
3450
+
3451
+ private bool disableSystemRestoreFieldSet;
3452
+
3453
+ private YesNoType parallelCacheField;
3454
+
3455
+ private bool parallelCacheFieldSet;
3456
+
3457
+ private ISchemaElement parentElement;
3458
+
3459
+ public Chain()
3460
+ {
3461
+ ElementCollection childCollection0 = new ElementCollection(ElementCollection.CollectionType.Choice);
3462
+ childCollection0.AddItem(new ElementCollection.ChoiceItem(typeof(MsiPackage)));
3463
+ childCollection0.AddItem(new ElementCollection.ChoiceItem(typeof(MspPackage)));
3464
+ childCollection0.AddItem(new ElementCollection.ChoiceItem(typeof(MsuPackage)));
3465
+ childCollection0.AddItem(new ElementCollection.ChoiceItem(typeof(ExePackage)));
3466
+ childCollection0.AddItem(new ElementCollection.ChoiceItem(typeof(RollbackBoundary)));
3467
+ childCollection0.AddItem(new ElementCollection.ChoiceItem(typeof(PackageGroupRef)));
3468
+ this.children = childCollection0;
3469
+ }
3470
+
3471
+ public virtual IEnumerable Children
3472
+ {
3473
+ get
3474
+ {
3475
+ return this.children;
3476
+ }
3477
+ }
3478
+
3479
+ [SuppressMessage("Microsoft.Design", "CA1043:UseIntegralOrStringArgumentForIndexers")]
3480
+ public virtual IEnumerable this[System.Type childType]
3481
+ {
3482
+ get
3483
+ {
3484
+ return this.children.Filter(childType);
3485
+ }
3486
+ }
3487
+
3488
+ /// <summary>
3489
+ /// Specifies whether the bundle will attempt to rollback packages
3490
+ /// executed in the chain. If "yes" is specified then when a vital
3491
+ /// package fails to install only that package will rollback and the
3492
+ /// chain will stop with the error. The default is "no" which
3493
+ /// indicates all packages executed during the chain will be
3494
+ /// rolledback to their previous state when a vital package fails.
3495
+ /// </summary>
3496
+ public YesNoType DisableRollback
3497
+ {
3498
+ get
3499
+ {
3500
+ return this.disableRollbackField;
3501
+ }
3502
+ set
3503
+ {
3504
+ this.disableRollbackFieldSet = true;
3505
+ this.disableRollbackField = value;
3506
+ }
3507
+ }
3508
+
3509
+ /// <summary>
3510
+ /// Specifies whether the bundle will attempt to create a system
3511
+ /// restore point when executing the chain. If "yes" is specified then
3512
+ /// a system restore point will not be created. The default is "no" which
3513
+ /// indicates a system restore point will be created when the bundle is
3514
+ /// installed, uninstalled, repaired, modified, etc. If the system restore
3515
+ /// point cannot be created, the bundle will log the issue and continue.
3516
+ /// </summary>
3517
+ public YesNoType DisableSystemRestore
3518
+ {
3519
+ get
3520
+ {
3521
+ return this.disableSystemRestoreField;
3522
+ }
3523
+ set
3524
+ {
3525
+ this.disableSystemRestoreFieldSet = true;
3526
+ this.disableSystemRestoreField = value;
3527
+ }
3528
+ }
3529
+
3530
+ /// <summary>
3531
+ /// Specifies whether the bundle will start installing packages
3532
+ /// while other packages are still being cached. If "yes",
3533
+ /// packages will start executing when a rollback boundary is
3534
+ /// encountered. The default is "no" which dictates all packages
3535
+ /// must be cached before any packages will start to be installed.
3536
+ /// </summary>
3537
+ public YesNoType ParallelCache
3538
+ {
3539
+ get
3540
+ {
3541
+ return this.parallelCacheField;
3542
+ }
3543
+ set
3544
+ {
3545
+ this.parallelCacheFieldSet = true;
3546
+ this.parallelCacheField = value;
3547
+ }
3548
+ }
3549
+
3550
+ public virtual ISchemaElement ParentElement
3551
+ {
3552
+ get
3553
+ {
3554
+ return this.parentElement;
3555
+ }
3556
+ set
3557
+ {
3558
+ this.parentElement = value;
3559
+ }
3560
+ }
3561
+
3562
+ public virtual void AddChild(ISchemaElement child)
3563
+ {
3564
+ if ((null == child))
3565
+ {
3566
+ throw new ArgumentNullException("child");
3567
+ }
3568
+ this.children.AddElement(child);
3569
+ child.ParentElement = this;
3570
+ }
3571
+
3572
+ public virtual void RemoveChild(ISchemaElement child)
3573
+ {
3574
+ if ((null == child))
3575
+ {
3576
+ throw new ArgumentNullException("child");
3577
+ }
3578
+ this.children.RemoveElement(child);
3579
+ child.ParentElement = null;
3580
+ }
3581
+
3582
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
3583
+ [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
3584
+ ISchemaElement ICreateChildren.CreateChild(string childName)
3585
+ {
3586
+ if (String.IsNullOrEmpty(childName))
3587
+ {
3588
+ throw new ArgumentNullException("childName");
3589
+ }
3590
+ ISchemaElement childValue = null;
3591
+ if (("MsiPackage" == childName))
3592
+ {
3593
+ childValue = new MsiPackage();
3594
+ }
3595
+ if (("MspPackage" == childName))
3596
+ {
3597
+ childValue = new MspPackage();
3598
+ }
3599
+ if (("MsuPackage" == childName))
3600
+ {
3601
+ childValue = new MsuPackage();
3602
+ }
3603
+ if (("ExePackage" == childName))
3604
+ {
3605
+ childValue = new ExePackage();
3606
+ }
3607
+ if (("RollbackBoundary" == childName))
3608
+ {
3609
+ childValue = new RollbackBoundary();
3610
+ }
3611
+ if (("PackageGroupRef" == childName))
3612
+ {
3613
+ childValue = new PackageGroupRef();
3614
+ }
3615
+ if ((null == childValue))
3616
+ {
3617
+ throw new InvalidOperationException(String.Concat(childName, " is not a valid child name."));
3618
+ }
3619
+ return childValue;
3620
+ }
3621
+
3622
+ /// <summary>
3623
+ /// Processes this element and all child elements into an XmlWriter.
3624
+ /// </summary>
3625
+ public virtual void OutputXml(XmlWriter writer)
3626
+ {
3627
+ if ((null == writer))
3628
+ {
3629
+ throw new ArgumentNullException("writer");
3630
+ }
3631
+ writer.WriteStartElement("Chain", "http://wixtoolset.org/schemas/v4/wxs");
3632
+ if (this.disableRollbackFieldSet)
3633
+ {
3634
+ if ((this.disableRollbackField == YesNoType.no))
3635
+ {
3636
+ writer.WriteAttributeString("DisableRollback", "no");
3637
+ }
3638
+ if ((this.disableRollbackField == YesNoType.yes))
3639
+ {
3640
+ writer.WriteAttributeString("DisableRollback", "yes");
3641
+ }
3642
+ }
3643
+ if (this.disableSystemRestoreFieldSet)
3644
+ {
3645
+ if ((this.disableSystemRestoreField == YesNoType.no))
3646
+ {
3647
+ writer.WriteAttributeString("DisableSystemRestore", "no");
3648
+ }
3649
+ if ((this.disableSystemRestoreField == YesNoType.yes))
3650
+ {
3651
+ writer.WriteAttributeString("DisableSystemRestore", "yes");
3652
+ }
3653
+ }
3654
+ if (this.parallelCacheFieldSet)
3655
+ {
3656
+ if ((this.parallelCacheField == YesNoType.no))
3657
+ {
3658
+ writer.WriteAttributeString("ParallelCache", "no");
3659
+ }
3660
+ if ((this.parallelCacheField == YesNoType.yes))
3661
+ {
3662
+ writer.WriteAttributeString("ParallelCache", "yes");
3663
+ }
3664
+ }
3665
+ for (IEnumerator enumerator = this.children.GetEnumerator(); enumerator.MoveNext(); )
3666
+ {
3667
+ ISchemaElement childElement = ((ISchemaElement)(enumerator.Current));
3668
+ childElement.OutputXml(writer);
3669
+ }
3670
+ writer.WriteEndElement();
3671
+ }
3672
+
3673
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
3674
+ void ISetAttributes.SetAttribute(string name, string value)
3675
+ {
3676
+ if (String.IsNullOrEmpty(name))
3677
+ {
3678
+ throw new ArgumentNullException("name");
3679
+ }
3680
+ if (("DisableRollback" == name))
3681
+ {
3682
+ this.disableRollbackField = Enums.ParseYesNoType(value);
3683
+ this.disableRollbackFieldSet = true;
3684
+ }
3685
+ if (("DisableSystemRestore" == name))
3686
+ {
3687
+ this.disableSystemRestoreField = Enums.ParseYesNoType(value);
3688
+ this.disableSystemRestoreFieldSet = true;
3689
+ }
3690
+ if (("ParallelCache" == name))
3691
+ {
3692
+ this.parallelCacheField = Enums.ParseYesNoType(value);
3693
+ this.parallelCacheFieldSet = true;
3694
+ }
3695
+ }
3696
+ }
3697
+
3698
+ /// <summary>
3699
+ /// Describes a single msi package to install.
3700
+ /// </summary>
3701
+ [GeneratedCode("WixBuildTools.XsdGen", "4.0.0.0")]
3702
+ public class MsiPackage : IParentElement, ICreateChildren, ISchemaElement, ISetAttributes
3703
+ {
3704
+
3705
+ private ElementCollection children;
3706
+
3707
+ private string sourceFileField;
3708
+
3709
+ private bool sourceFileFieldSet;
3710
+
3711
+ private string nameField;
3712
+
3713
+ private bool nameFieldSet;
3714
+
3715
+ private string downloadUrlField;
3716
+
3717
+ private bool downloadUrlFieldSet;
3718
+
3719
+ private string idField;
3720
+
3721
+ private bool idFieldSet;
3722
+
3723
+ private string afterField;
3724
+
3725
+ private bool afterFieldSet;
3726
+
3727
+ private string installSizeField;
3728
+
3729
+ private bool installSizeFieldSet;
3730
+
3731
+ private string installConditionField;
3732
+
3733
+ private bool installConditionFieldSet;
3734
+
3735
+ private YesNoAlwaysType cacheField;
3736
+
3737
+ private bool cacheFieldSet;
3738
+
3739
+ private string cacheIdField;
3740
+
3741
+ private bool cacheIdFieldSet;
3742
+
3743
+ private string displayNameField;
3744
+
3745
+ private bool displayNameFieldSet;
3746
+
3747
+ private string descriptionField;
3748
+
3749
+ private bool descriptionFieldSet;
3750
+
3751
+ private string logPathVariableField;
3752
+
3753
+ private bool logPathVariableFieldSet;
3754
+
3755
+ private string rollbackLogPathVariableField;
3756
+
3757
+ private bool rollbackLogPathVariableFieldSet;
3758
+
3759
+ private YesNoType permanentField;
3760
+
3761
+ private bool permanentFieldSet;
3762
+
3763
+ private YesNoType vitalField;
3764
+
3765
+ private bool vitalFieldSet;
3766
+
3767
+ private YesNoDefaultType compressedField;
3768
+
3769
+ private bool compressedFieldSet;
3770
+
3771
+ private YesNoType enableSignatureVerificationField;
3772
+
3773
+ private bool enableSignatureVerificationFieldSet;
3774
+
3775
+ private YesNoType enableFeatureSelectionField;
3776
+
3777
+ private bool enableFeatureSelectionFieldSet;
3778
+
3779
+ private YesNoType forcePerMachineField;
3780
+
3781
+ private bool forcePerMachineFieldSet;
3782
+
3783
+ private YesNoType suppressLooseFilePayloadGenerationField;
3784
+
3785
+ private bool suppressLooseFilePayloadGenerationFieldSet;
3786
+
3787
+ private YesNoType visibleField;
3788
+
3789
+ private bool visibleFieldSet;
3790
+
3791
+ private ISchemaElement parentElement;
3792
+
3793
+ public MsiPackage()
3794
+ {
3795
+ ElementCollection childCollection0 = new ElementCollection(ElementCollection.CollectionType.Choice);
3796
+ childCollection0.AddItem(new ElementCollection.ChoiceItem(typeof(MsiProperty)));
3797
+ childCollection0.AddItem(new ElementCollection.ChoiceItem(typeof(SlipstreamMsp)));
3798
+ childCollection0.AddItem(new ElementCollection.ChoiceItem(typeof(Payload)));
3799
+ childCollection0.AddItem(new ElementCollection.ChoiceItem(typeof(PayloadGroupRef)));
3800
+ childCollection0.AddItem(new ElementCollection.ChoiceItem(typeof(ISchemaElement)));
3801
+ this.children = childCollection0;
3802
+ }
3803
+
3804
+ public virtual IEnumerable Children
3805
+ {
3806
+ get
3807
+ {
3808
+ return this.children;
3809
+ }
3810
+ }
3811
+
3812
+ [SuppressMessage("Microsoft.Design", "CA1043:UseIntegralOrStringArgumentForIndexers")]
3813
+ public virtual IEnumerable this[System.Type childType]
3814
+ {
3815
+ get
3816
+ {
3817
+ return this.children.Filter(childType);
3818
+ }
3819
+ }
3820
+
3821
+ /// <summary>
3822
+ /// Location of the package to add to the bundle. The default value is the Name attribute, if provided.
3823
+ /// At a minimum, the SourceFile or Name attribute must be specified.
3824
+ /// </summary>
3825
+ public string SourceFile
3826
+ {
3827
+ get
3828
+ {
3829
+ return this.sourceFileField;
3830
+ }
3831
+ set
3832
+ {
3833
+ this.sourceFileFieldSet = true;
3834
+ this.sourceFileField = value;
3835
+ }
3836
+ }
3837
+
3838
+ /// <summary>
3839
+ /// The destination path and file name for this chain payload. Use this attribute to rename the
3840
+ /// chain entry point or extract it into a subfolder. The default value is the file name from the
3841
+ /// SourceFile attribute, if provided. At a minimum, the Name or SourceFile attribute must be specified.
3842
+ /// The use of '..' directories is not allowed.
3843
+ /// </summary>
3844
+ public string Name
3845
+ {
3846
+ get
3847
+ {
3848
+ return this.nameField;
3849
+ }
3850
+ set
3851
+ {
3852
+ this.nameFieldSet = true;
3853
+ this.nameField = value;
3854
+ }
3855
+ }
3856
+
3857
+ public string DownloadUrl
3858
+ {
3859
+ get
3860
+ {
3861
+ return this.downloadUrlField;
3862
+ }
3863
+ set
3864
+ {
3865
+ this.downloadUrlFieldSet = true;
3866
+ this.downloadUrlField = value;
3867
+ }
3868
+ }
3869
+
3870
+ /// <summary>
3871
+ /// Identifier for this package, for ordering and cross-referencing. The default is the Name attribute
3872
+ /// modified to be suitable as an identifier (i.e. invalid characters are replaced with underscores).
3873
+ /// </summary>
3874
+ public string Id
3875
+ {
3876
+ get
3877
+ {
3878
+ return this.idField;
3879
+ }
3880
+ set
3881
+ {
3882
+ this.idFieldSet = true;
3883
+ this.idField = value;
3884
+ }
3885
+ }
3886
+
3887
+ /// <summary>
3888
+ /// The identifier of another package that this one should be installed after. By default the After
3889
+ /// attribute is set to the previous sibling package in the Chain or PackageGroup element. If this
3890
+ /// attribute is specified ensure that a cycle is not created explicitly or implicitly.
3891
+ /// </summary>
3892
+ public string After
3893
+ {
3894
+ get
3895
+ {
3896
+ return this.afterField;
3897
+ }
3898
+ set
3899
+ {
3900
+ this.afterFieldSet = true;
3901
+ this.afterField = value;
3902
+ }
3903
+ }
3904
+
3905
+ /// <summary>
3906
+ /// The size this package will take on disk in bytes after it is installed. By default, the binder will
3907
+ /// calculate the install size by scanning the package (File table for MSIs, Payloads for EXEs)
3908
+ /// and use the total for the install size of the package.
3909
+ /// </summary>
3910
+ public string InstallSize
3911
+ {
3912
+ get
3913
+ {
3914
+ return this.installSizeField;
3915
+ }
3916
+ set
3917
+ {
3918
+ this.installSizeFieldSet = true;
3919
+ this.installSizeField = value;
3920
+ }
3921
+ }
3922
+
3923
+ /// <summary>
3924
+ /// A condition to evaluate before installing the package. The package will only be installed if the condition evaluates to true. If the condition evaluates to false and the bundle is being installed, repaired, or modified, the package will be uninstalled.
3925
+ /// </summary>
3926
+ public string InstallCondition
3927
+ {
3928
+ get
3929
+ {
3930
+ return this.installConditionField;
3931
+ }
3932
+ set
3933
+ {
3934
+ this.installConditionFieldSet = true;
3935
+ this.installConditionField = value;
3936
+ }
3937
+ }
3938
+
3939
+ /// <summary>
3940
+ /// Whether to cache the package. The default is "yes".
3941
+ /// </summary>
3942
+ public YesNoAlwaysType Cache
3943
+ {
3944
+ get
3945
+ {
3946
+ return this.cacheField;
3947
+ }
3948
+ set
3949
+ {
3950
+ this.cacheFieldSet = true;
3951
+ this.cacheField = value;
3952
+ }
3953
+ }
3954
+
3955
+ /// <summary>
3956
+ /// The identifier to use when caching the package.
3957
+ /// </summary>
3958
+ public string CacheId
3959
+ {
3960
+ get
3961
+ {
3962
+ return this.cacheIdField;
3963
+ }
3964
+ set
3965
+ {
3966
+ this.cacheIdFieldSet = true;
3967
+ this.cacheIdField = value;
3968
+ }
3969
+ }
3970
+
3971
+ /// <summary>
3972
+ /// Specifies the display name to place in the bootstrapper application data manifest for the package. By default, ExePackages
3973
+ /// use the ProductName field from the version information, MsiPackages use the ProductName property, and MspPackages use
3974
+ /// the DisplayName patch metadata property. Other package types must use this attribute to define a display name in the
3975
+ /// bootstrapper application data manifest.
3976
+ /// </summary>
3977
+ public string DisplayName
3978
+ {
3979
+ get
3980
+ {
3981
+ return this.displayNameField;
3982
+ }
3983
+ set
3984
+ {
3985
+ this.displayNameFieldSet = true;
3986
+ this.displayNameField = value;
3987
+ }
3988
+ }
3989
+
3990
+ /// <summary>
3991
+ /// Specifies the description to place in the bootstrapper application data manifest for the package. By default, ExePackages
3992
+ /// use the FileName field from the version information, MsiPackages use the ARPCOMMENTS property, and MspPackages use
3993
+ /// the Description patch metadata property. Other package types must use this attribute to define a description in the
3994
+ /// bootstrapper application data manifest.
3995
+ /// </summary>
3996
+ public string Description
3997
+ {
3998
+ get
3999
+ {
4000
+ return this.descriptionField;
4001
+ }
4002
+ set
4003
+ {
4004
+ this.descriptionFieldSet = true;
4005
+ this.descriptionField = value;
4006
+ }
4007
+ }
4008
+
4009
+ /// <summary>
4010
+ /// Name of a Variable that will hold the path to the log file. An empty value will cause the variable to not
4011
+ /// be set. The default is "WixBundleLog_[PackageId]" except for MSU packages which default to no logging.
4012
+ /// </summary>
4013
+ public string LogPathVariable
4014
+ {
4015
+ get
4016
+ {
4017
+ return this.logPathVariableField;
4018
+ }
4019
+ set
4020
+ {
4021
+ this.logPathVariableFieldSet = true;
4022
+ this.logPathVariableField = value;
4023
+ }
4024
+ }
4025
+
4026
+ /// <summary>
4027
+ /// Name of a Variable that will hold the path to the log file used during rollback. An empty value will cause
4028
+ /// the variable to not be set. The default is "WixBundleRollbackLog_[PackageId]" except for MSU packages which
4029
+ /// default to no logging.
4030
+ /// </summary>
4031
+ public string RollbackLogPathVariable
4032
+ {
4033
+ get
4034
+ {
4035
+ return this.rollbackLogPathVariableField;
4036
+ }
4037
+ set
4038
+ {
4039
+ this.rollbackLogPathVariableFieldSet = true;
4040
+ this.rollbackLogPathVariableField = value;
4041
+ }
4042
+ }
4043
+
4044
+ /// <summary>
4045
+ /// Specifies whether the package can be uninstalled. The default is "no".
4046
+ /// </summary>
4047
+ public YesNoType Permanent
4048
+ {
4049
+ get
4050
+ {
4051
+ return this.permanentField;
4052
+ }
4053
+ set
4054
+ {
4055
+ this.permanentFieldSet = true;
4056
+ this.permanentField = value;
4057
+ }
4058
+ }
4059
+
4060
+ /// <summary>
4061
+ /// Specifies whether the package must succeed for the chain to continue. The default "yes"
4062
+ /// indicates that if the package fails then the chain will fail and rollback or stop. If
4063
+ /// "no" is specified then the chain will continue even if the package reports failure.
4064
+ /// </summary>
4065
+ public YesNoType Vital
4066
+ {
4067
+ get
4068
+ {
4069
+ return this.vitalField;
4070
+ }
4071
+ set
4072
+ {
4073
+ this.vitalFieldSet = true;
4074
+ this.vitalField = value;
4075
+ }
4076
+ }
4077
+
4078
+ /// <summary>
4079
+ /// Whether the package payload should be embedded in a container or left as an external payload.
4080
+ /// </summary>
4081
+ public YesNoDefaultType Compressed
4082
+ {
4083
+ get
4084
+ {
4085
+ return this.compressedField;
4086
+ }
4087
+ set
4088
+ {
4089
+ this.compressedFieldSet = true;
4090
+ this.compressedField = value;
4091
+ }
4092
+ }
4093
+
4094
+ /// <summary>
4095
+ /// By default, a Bundle will use the hash of a package to verify its contents. If this attribute is set to "yes"
4096
+ /// and the package is signed with an Authenticode signature the Bundle will verify the contents of the package using the
4097
+ /// signature instead. Beware that there are many real world issues with Windows verifying Authenticode signatures.
4098
+ /// Since the Authenticode signatures are no more secure than hashing the packages directly, the default is "no".
4099
+ /// </summary>
4100
+ public YesNoType EnableSignatureVerification
4101
+ {
4102
+ get
4103
+ {
4104
+ return this.enableSignatureVerificationField;
4105
+ }
4106
+ set
4107
+ {
4108
+ this.enableSignatureVerificationFieldSet = true;
4109
+ this.enableSignatureVerificationField = value;
4110
+ }
4111
+ }
4112
+
4113
+ /// <summary>
4114
+ /// Specifies whether the bundle will allow individual control over the installation state of Features inside
4115
+ /// the msi package. Managing feature selection requires special care to ensure the install, modify, update and
4116
+ /// uninstall behavior of the package is always correct. The default is "no".
4117
+ /// </summary>
4118
+ public YesNoType EnableFeatureSelection
4119
+ {
4120
+ get
4121
+ {
4122
+ return this.enableFeatureSelectionField;
4123
+ }
4124
+ set
4125
+ {
4126
+ this.enableFeatureSelectionFieldSet = true;
4127
+ this.enableFeatureSelectionField = value;
4128
+ }
4129
+ }
4130
+
4131
+ /// <summary>
4132
+ /// Override the automatic per-machine detection of MSI packages and force the package to be per-machine.
4133
+ /// The default is "no", which allows the tools to detect the expected value.
4134
+ /// </summary>
4135
+ public YesNoType ForcePerMachine
4136
+ {
4137
+ get
4138
+ {
4139
+ return this.forcePerMachineField;
4140
+ }
4141
+ set
4142
+ {
4143
+ this.forcePerMachineFieldSet = true;
4144
+ this.forcePerMachineField = value;
4145
+ }
4146
+ }
4147
+
4148
+ /// <summary>
4149
+ /// This attribute has been deprecated. When the value is "yes", the Binder will not read the MSI package
4150
+ /// to detect uncompressed files that would otherwise be automatically included in the Bundle as Payloads.
4151
+ /// The resulting Bundle may not be able to install the MSI package correctly. The default is "no".
4152
+ /// </summary>
4153
+ public YesNoType SuppressLooseFilePayloadGeneration
4154
+ {
4155
+ get
4156
+ {
4157
+ return this.suppressLooseFilePayloadGenerationField;
4158
+ }
4159
+ set
4160
+ {
4161
+ this.suppressLooseFilePayloadGenerationFieldSet = true;
4162
+ this.suppressLooseFilePayloadGenerationField = value;
4163
+ }
4164
+ }
4165
+
4166
+ /// <summary>
4167
+ /// Specifies whether the MSI will be displayed in Programs and Features (also known as Add/Remove Programs). If "yes" is
4168
+ /// specified the MSI package information will be displayed in Programs and Features. The default "no" indicates the MSI
4169
+ /// will not be displayed.
4170
+ /// </summary>
4171
+ public YesNoType Visible
4172
+ {
4173
+ get
4174
+ {
4175
+ return this.visibleField;
4176
+ }
4177
+ set
4178
+ {
4179
+ this.visibleFieldSet = true;
4180
+ this.visibleField = value;
4181
+ }
4182
+ }
4183
+
4184
+ public virtual ISchemaElement ParentElement
4185
+ {
4186
+ get
4187
+ {
4188
+ return this.parentElement;
4189
+ }
4190
+ set
4191
+ {
4192
+ this.parentElement = value;
4193
+ }
4194
+ }
4195
+
4196
+ public virtual void AddChild(ISchemaElement child)
4197
+ {
4198
+ if ((null == child))
4199
+ {
4200
+ throw new ArgumentNullException("child");
4201
+ }
4202
+ this.children.AddElement(child);
4203
+ child.ParentElement = this;
4204
+ }
4205
+
4206
+ public virtual void RemoveChild(ISchemaElement child)
4207
+ {
4208
+ if ((null == child))
4209
+ {
4210
+ throw new ArgumentNullException("child");
4211
+ }
4212
+ this.children.RemoveElement(child);
4213
+ child.ParentElement = null;
4214
+ }
4215
+
4216
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
4217
+ ISchemaElement ICreateChildren.CreateChild(string childName)
4218
+ {
4219
+ if (String.IsNullOrEmpty(childName))
4220
+ {
4221
+ throw new ArgumentNullException("childName");
4222
+ }
4223
+ ISchemaElement childValue = null;
4224
+ if (("MsiProperty" == childName))
4225
+ {
4226
+ childValue = new MsiProperty();
4227
+ }
4228
+ if (("SlipstreamMsp" == childName))
4229
+ {
4230
+ childValue = new SlipstreamMsp();
4231
+ }
4232
+ if (("Payload" == childName))
4233
+ {
4234
+ childValue = new Payload();
4235
+ }
4236
+ if (("PayloadGroupRef" == childName))
4237
+ {
4238
+ childValue = new PayloadGroupRef();
4239
+ }
4240
+ if ((null == childValue))
4241
+ {
4242
+ throw new InvalidOperationException(String.Concat(childName, " is not a valid child name."));
4243
+ }
4244
+ return childValue;
4245
+ }
4246
+
4247
+ /// <summary>
4248
+ /// Processes this element and all child elements into an XmlWriter.
4249
+ /// </summary>
4250
+ [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
4251
+ public virtual void OutputXml(XmlWriter writer)
4252
+ {
4253
+ if ((null == writer))
4254
+ {
4255
+ throw new ArgumentNullException("writer");
4256
+ }
4257
+ writer.WriteStartElement("MsiPackage", "http://wixtoolset.org/schemas/v4/wxs");
4258
+ if (this.sourceFileFieldSet)
4259
+ {
4260
+ writer.WriteAttributeString("SourceFile", this.sourceFileField);
4261
+ }
4262
+ if (this.nameFieldSet)
4263
+ {
4264
+ writer.WriteAttributeString("Name", this.nameField);
4265
+ }
4266
+ if (this.downloadUrlFieldSet)
4267
+ {
4268
+ writer.WriteAttributeString("DownloadUrl", this.downloadUrlField);
4269
+ }
4270
+ if (this.idFieldSet)
4271
+ {
4272
+ writer.WriteAttributeString("Id", this.idField);
4273
+ }
4274
+ if (this.afterFieldSet)
4275
+ {
4276
+ writer.WriteAttributeString("After", this.afterField);
4277
+ }
4278
+ if (this.installSizeFieldSet)
4279
+ {
4280
+ writer.WriteAttributeString("InstallSize", this.installSizeField);
4281
+ }
4282
+ if (this.installConditionFieldSet)
4283
+ {
4284
+ writer.WriteAttributeString("InstallCondition", this.installConditionField);
4285
+ }
4286
+ if (this.cacheFieldSet)
4287
+ {
4288
+ if ((this.cacheField == YesNoAlwaysType.always))
4289
+ {
4290
+ writer.WriteAttributeString("Cache", "always");
4291
+ }
4292
+ if ((this.cacheField == YesNoAlwaysType.no))
4293
+ {
4294
+ writer.WriteAttributeString("Cache", "no");
4295
+ }
4296
+ if ((this.cacheField == YesNoAlwaysType.yes))
4297
+ {
4298
+ writer.WriteAttributeString("Cache", "yes");
4299
+ }
4300
+ }
4301
+ if (this.cacheIdFieldSet)
4302
+ {
4303
+ writer.WriteAttributeString("CacheId", this.cacheIdField);
4304
+ }
4305
+ if (this.displayNameFieldSet)
4306
+ {
4307
+ writer.WriteAttributeString("DisplayName", this.displayNameField);
4308
+ }
4309
+ if (this.descriptionFieldSet)
4310
+ {
4311
+ writer.WriteAttributeString("Description", this.descriptionField);
4312
+ }
4313
+ if (this.logPathVariableFieldSet)
4314
+ {
4315
+ writer.WriteAttributeString("LogPathVariable", this.logPathVariableField);
4316
+ }
4317
+ if (this.rollbackLogPathVariableFieldSet)
4318
+ {
4319
+ writer.WriteAttributeString("RollbackLogPathVariable", this.rollbackLogPathVariableField);
4320
+ }
4321
+ if (this.permanentFieldSet)
4322
+ {
4323
+ if ((this.permanentField == YesNoType.no))
4324
+ {
4325
+ writer.WriteAttributeString("Permanent", "no");
4326
+ }
4327
+ if ((this.permanentField == YesNoType.yes))
4328
+ {
4329
+ writer.WriteAttributeString("Permanent", "yes");
4330
+ }
4331
+ }
4332
+ if (this.vitalFieldSet)
4333
+ {
4334
+ if ((this.vitalField == YesNoType.no))
4335
+ {
4336
+ writer.WriteAttributeString("Vital", "no");
4337
+ }
4338
+ if ((this.vitalField == YesNoType.yes))
4339
+ {
4340
+ writer.WriteAttributeString("Vital", "yes");
4341
+ }
4342
+ }
4343
+ if (this.compressedFieldSet)
4344
+ {
4345
+ if ((this.compressedField == YesNoDefaultType.@default))
4346
+ {
4347
+ writer.WriteAttributeString("Compressed", "default");
4348
+ }
4349
+ if ((this.compressedField == YesNoDefaultType.no))
4350
+ {
4351
+ writer.WriteAttributeString("Compressed", "no");
4352
+ }
4353
+ if ((this.compressedField == YesNoDefaultType.yes))
4354
+ {
4355
+ writer.WriteAttributeString("Compressed", "yes");
4356
+ }
4357
+ }
4358
+ if (this.enableSignatureVerificationFieldSet)
4359
+ {
4360
+ if ((this.enableSignatureVerificationField == YesNoType.no))
4361
+ {
4362
+ writer.WriteAttributeString("EnableSignatureVerification", "no");
4363
+ }
4364
+ if ((this.enableSignatureVerificationField == YesNoType.yes))
4365
+ {
4366
+ writer.WriteAttributeString("EnableSignatureVerification", "yes");
4367
+ }
4368
+ }
4369
+ if (this.enableFeatureSelectionFieldSet)
4370
+ {
4371
+ if ((this.enableFeatureSelectionField == YesNoType.no))
4372
+ {
4373
+ writer.WriteAttributeString("EnableFeatureSelection", "no");
4374
+ }
4375
+ if ((this.enableFeatureSelectionField == YesNoType.yes))
4376
+ {
4377
+ writer.WriteAttributeString("EnableFeatureSelection", "yes");
4378
+ }
4379
+ }
4380
+ if (this.forcePerMachineFieldSet)
4381
+ {
4382
+ if ((this.forcePerMachineField == YesNoType.no))
4383
+ {
4384
+ writer.WriteAttributeString("ForcePerMachine", "no");
4385
+ }
4386
+ if ((this.forcePerMachineField == YesNoType.yes))
4387
+ {
4388
+ writer.WriteAttributeString("ForcePerMachine", "yes");
4389
+ }
4390
+ }
4391
+ if (this.suppressLooseFilePayloadGenerationFieldSet)
4392
+ {
4393
+ if ((this.suppressLooseFilePayloadGenerationField == YesNoType.no))
4394
+ {
4395
+ writer.WriteAttributeString("SuppressLooseFilePayloadGeneration", "no");
4396
+ }
4397
+ if ((this.suppressLooseFilePayloadGenerationField == YesNoType.yes))
4398
+ {
4399
+ writer.WriteAttributeString("SuppressLooseFilePayloadGeneration", "yes");
4400
+ }
4401
+ }
4402
+ if (this.visibleFieldSet)
4403
+ {
4404
+ if ((this.visibleField == YesNoType.no))
4405
+ {
4406
+ writer.WriteAttributeString("Visible", "no");
4407
+ }
4408
+ if ((this.visibleField == YesNoType.yes))
4409
+ {
4410
+ writer.WriteAttributeString("Visible", "yes");
4411
+ }
4412
+ }
4413
+ for (IEnumerator enumerator = this.children.GetEnumerator(); enumerator.MoveNext(); )
4414
+ {
4415
+ ISchemaElement childElement = ((ISchemaElement)(enumerator.Current));
4416
+ childElement.OutputXml(writer);
4417
+ }
4418
+ writer.WriteEndElement();
4419
+ }
4420
+
4421
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
4422
+ [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
4423
+ void ISetAttributes.SetAttribute(string name, string value)
4424
+ {
4425
+ if (String.IsNullOrEmpty(name))
4426
+ {
4427
+ throw new ArgumentNullException("name");
4428
+ }
4429
+ if (("SourceFile" == name))
4430
+ {
4431
+ this.sourceFileField = value;
4432
+ this.sourceFileFieldSet = true;
4433
+ }
4434
+ if (("Name" == name))
4435
+ {
4436
+ this.nameField = value;
4437
+ this.nameFieldSet = true;
4438
+ }
4439
+ if (("DownloadUrl" == name))
4440
+ {
4441
+ this.downloadUrlField = value;
4442
+ this.downloadUrlFieldSet = true;
4443
+ }
4444
+ if (("Id" == name))
4445
+ {
4446
+ this.idField = value;
4447
+ this.idFieldSet = true;
4448
+ }
4449
+ if (("After" == name))
4450
+ {
4451
+ this.afterField = value;
4452
+ this.afterFieldSet = true;
4453
+ }
4454
+ if (("InstallSize" == name))
4455
+ {
4456
+ this.installSizeField = value;
4457
+ this.installSizeFieldSet = true;
4458
+ }
4459
+ if (("InstallCondition" == name))
4460
+ {
4461
+ this.installConditionField = value;
4462
+ this.installConditionFieldSet = true;
4463
+ }
4464
+ if (("Cache" == name))
4465
+ {
4466
+ this.cacheField = Enums.ParseYesNoAlwaysType(value);
4467
+ this.cacheFieldSet = true;
4468
+ }
4469
+ if (("CacheId" == name))
4470
+ {
4471
+ this.cacheIdField = value;
4472
+ this.cacheIdFieldSet = true;
4473
+ }
4474
+ if (("DisplayName" == name))
4475
+ {
4476
+ this.displayNameField = value;
4477
+ this.displayNameFieldSet = true;
4478
+ }
4479
+ if (("Description" == name))
4480
+ {
4481
+ this.descriptionField = value;
4482
+ this.descriptionFieldSet = true;
4483
+ }
4484
+ if (("LogPathVariable" == name))
4485
+ {
4486
+ this.logPathVariableField = value;
4487
+ this.logPathVariableFieldSet = true;
4488
+ }
4489
+ if (("RollbackLogPathVariable" == name))
4490
+ {
4491
+ this.rollbackLogPathVariableField = value;
4492
+ this.rollbackLogPathVariableFieldSet = true;
4493
+ }
4494
+ if (("Permanent" == name))
4495
+ {
4496
+ this.permanentField = Enums.ParseYesNoType(value);
4497
+ this.permanentFieldSet = true;
4498
+ }
4499
+ if (("Vital" == name))
4500
+ {
4501
+ this.vitalField = Enums.ParseYesNoType(value);
4502
+ this.vitalFieldSet = true;
4503
+ }
4504
+ if (("Compressed" == name))
4505
+ {
4506
+ this.compressedField = Enums.ParseYesNoDefaultType(value);
4507
+ this.compressedFieldSet = true;
4508
+ }
4509
+ if (("EnableSignatureVerification" == name))
4510
+ {
4511
+ this.enableSignatureVerificationField = Enums.ParseYesNoType(value);
4512
+ this.enableSignatureVerificationFieldSet = true;
4513
+ }
4514
+ if (("EnableFeatureSelection" == name))
4515
+ {
4516
+ this.enableFeatureSelectionField = Enums.ParseYesNoType(value);
4517
+ this.enableFeatureSelectionFieldSet = true;
4518
+ }
4519
+ if (("ForcePerMachine" == name))
4520
+ {
4521
+ this.forcePerMachineField = Enums.ParseYesNoType(value);
4522
+ this.forcePerMachineFieldSet = true;
4523
+ }
4524
+ if (("SuppressLooseFilePayloadGeneration" == name))
4525
+ {
4526
+ this.suppressLooseFilePayloadGenerationField = Enums.ParseYesNoType(value);
4527
+ this.suppressLooseFilePayloadGenerationFieldSet = true;
4528
+ }
4529
+ if (("Visible" == name))
4530
+ {
4531
+ this.visibleField = Enums.ParseYesNoType(value);
4532
+ this.visibleFieldSet = true;
4533
+ }
4534
+ }
4535
+ }
4536
+
4537
+ /// <summary>
4538
+ /// Describes a single msp package to install.
4539
+ /// </summary>
4540
+ [GeneratedCode("WixBuildTools.XsdGen", "4.0.0.0")]
4541
+ public class MspPackage : IParentElement, ICreateChildren, ISchemaElement, ISetAttributes
4542
+ {
4543
+
4544
+ private ElementCollection children;
4545
+
4546
+ private string sourceFileField;
4547
+
4548
+ private bool sourceFileFieldSet;
4549
+
4550
+ private string nameField;
4551
+
4552
+ private bool nameFieldSet;
4553
+
4554
+ private string downloadUrlField;
4555
+
4556
+ private bool downloadUrlFieldSet;
4557
+
4558
+ private string idField;
4559
+
4560
+ private bool idFieldSet;
4561
+
4562
+ private string afterField;
4563
+
4564
+ private bool afterFieldSet;
4565
+
4566
+ private string installSizeField;
4567
+
4568
+ private bool installSizeFieldSet;
4569
+
4570
+ private string installConditionField;
4571
+
4572
+ private bool installConditionFieldSet;
4573
+
4574
+ private YesNoAlwaysType cacheField;
4575
+
4576
+ private bool cacheFieldSet;
4577
+
4578
+ private string cacheIdField;
4579
+
4580
+ private bool cacheIdFieldSet;
4581
+
4582
+ private string displayNameField;
4583
+
4584
+ private bool displayNameFieldSet;
4585
+
4586
+ private string descriptionField;
4587
+
4588
+ private bool descriptionFieldSet;
4589
+
4590
+ private string logPathVariableField;
4591
+
4592
+ private bool logPathVariableFieldSet;
4593
+
4594
+ private string rollbackLogPathVariableField;
4595
+
4596
+ private bool rollbackLogPathVariableFieldSet;
4597
+
4598
+ private YesNoType permanentField;
4599
+
4600
+ private bool permanentFieldSet;
4601
+
4602
+ private YesNoType vitalField;
4603
+
4604
+ private bool vitalFieldSet;
4605
+
4606
+ private YesNoDefaultType compressedField;
4607
+
4608
+ private bool compressedFieldSet;
4609
+
4610
+ private YesNoType enableSignatureVerificationField;
4611
+
4612
+ private bool enableSignatureVerificationFieldSet;
4613
+
4614
+ private YesNoDefaultType perMachineField;
4615
+
4616
+ private bool perMachineFieldSet;
4617
+
4618
+ private YesNoType slipstreamField;
4619
+
4620
+ private bool slipstreamFieldSet;
4621
+
4622
+ private ISchemaElement parentElement;
4623
+
4624
+ public MspPackage()
4625
+ {
4626
+ ElementCollection childCollection0 = new ElementCollection(ElementCollection.CollectionType.Choice);
4627
+ childCollection0.AddItem(new ElementCollection.ChoiceItem(typeof(MsiProperty)));
4628
+ childCollection0.AddItem(new ElementCollection.ChoiceItem(typeof(Payload)));
4629
+ childCollection0.AddItem(new ElementCollection.ChoiceItem(typeof(PayloadGroupRef)));
4630
+ childCollection0.AddItem(new ElementCollection.ChoiceItem(typeof(ISchemaElement)));
4631
+ this.children = childCollection0;
4632
+ }
4633
+
4634
+ public virtual IEnumerable Children
4635
+ {
4636
+ get
4637
+ {
4638
+ return this.children;
4639
+ }
4640
+ }
4641
+
4642
+ [SuppressMessage("Microsoft.Design", "CA1043:UseIntegralOrStringArgumentForIndexers")]
4643
+ public virtual IEnumerable this[System.Type childType]
4644
+ {
4645
+ get
4646
+ {
4647
+ return this.children.Filter(childType);
4648
+ }
4649
+ }
4650
+
4651
+ /// <summary>
4652
+ /// Location of the package to add to the bundle. The default value is the Name attribute, if provided.
4653
+ /// At a minimum, the SourceFile or Name attribute must be specified.
4654
+ /// </summary>
4655
+ public string SourceFile
4656
+ {
4657
+ get
4658
+ {
4659
+ return this.sourceFileField;
4660
+ }
4661
+ set
4662
+ {
4663
+ this.sourceFileFieldSet = true;
4664
+ this.sourceFileField = value;
4665
+ }
4666
+ }
4667
+
4668
+ /// <summary>
4669
+ /// The destination path and file name for this chain payload. Use this attribute to rename the
4670
+ /// chain entry point or extract it into a subfolder. The default value is the file name from the
4671
+ /// SourceFile attribute, if provided. At a minimum, the Name or SourceFile attribute must be specified.
4672
+ /// The use of '..' directories is not allowed.
4673
+ /// </summary>
4674
+ public string Name
4675
+ {
4676
+ get
4677
+ {
4678
+ return this.nameField;
4679
+ }
4680
+ set
4681
+ {
4682
+ this.nameFieldSet = true;
4683
+ this.nameField = value;
4684
+ }
4685
+ }
4686
+
4687
+ public string DownloadUrl
4688
+ {
4689
+ get
4690
+ {
4691
+ return this.downloadUrlField;
4692
+ }
4693
+ set
4694
+ {
4695
+ this.downloadUrlFieldSet = true;
4696
+ this.downloadUrlField = value;
4697
+ }
4698
+ }
4699
+
4700
+ /// <summary>
4701
+ /// Identifier for this package, for ordering and cross-referencing. The default is the Name attribute
4702
+ /// modified to be suitable as an identifier (i.e. invalid characters are replaced with underscores).
4703
+ /// </summary>
4704
+ public string Id
4705
+ {
4706
+ get
4707
+ {
4708
+ return this.idField;
4709
+ }
4710
+ set
4711
+ {
4712
+ this.idFieldSet = true;
4713
+ this.idField = value;
4714
+ }
4715
+ }
4716
+
4717
+ /// <summary>
4718
+ /// The identifier of another package that this one should be installed after. By default the After
4719
+ /// attribute is set to the previous sibling package in the Chain or PackageGroup element. If this
4720
+ /// attribute is specified ensure that a cycle is not created explicitly or implicitly.
4721
+ /// </summary>
4722
+ public string After
4723
+ {
4724
+ get
4725
+ {
4726
+ return this.afterField;
4727
+ }
4728
+ set
4729
+ {
4730
+ this.afterFieldSet = true;
4731
+ this.afterField = value;
4732
+ }
4733
+ }
4734
+
4735
+ /// <summary>
4736
+ /// The size this package will take on disk in bytes after it is installed. By default, the binder will
4737
+ /// calculate the install size by scanning the package (File table for MSIs, Payloads for EXEs)
4738
+ /// and use the total for the install size of the package.
4739
+ /// </summary>
4740
+ public string InstallSize
4741
+ {
4742
+ get
4743
+ {
4744
+ return this.installSizeField;
4745
+ }
4746
+ set
4747
+ {
4748
+ this.installSizeFieldSet = true;
4749
+ this.installSizeField = value;
4750
+ }
4751
+ }
4752
+
4753
+ /// <summary>
4754
+ /// A condition to evaluate before installing the package. The package will only be installed if the condition evaluates to true. If the condition evaluates to false and the bundle is being installed, repaired, or modified, the package will be uninstalled.
4755
+ /// </summary>
4756
+ public string InstallCondition
4757
+ {
4758
+ get
4759
+ {
4760
+ return this.installConditionField;
4761
+ }
4762
+ set
4763
+ {
4764
+ this.installConditionFieldSet = true;
4765
+ this.installConditionField = value;
4766
+ }
4767
+ }
4768
+
4769
+ /// <summary>
4770
+ /// Whether to cache the package. The default is "yes".
4771
+ /// </summary>
4772
+ public YesNoAlwaysType Cache
4773
+ {
4774
+ get
4775
+ {
4776
+ return this.cacheField;
4777
+ }
4778
+ set
4779
+ {
4780
+ this.cacheFieldSet = true;
4781
+ this.cacheField = value;
4782
+ }
4783
+ }
4784
+
4785
+ /// <summary>
4786
+ /// The identifier to use when caching the package.
4787
+ /// </summary>
4788
+ public string CacheId
4789
+ {
4790
+ get
4791
+ {
4792
+ return this.cacheIdField;
4793
+ }
4794
+ set
4795
+ {
4796
+ this.cacheIdFieldSet = true;
4797
+ this.cacheIdField = value;
4798
+ }
4799
+ }
4800
+
4801
+ /// <summary>
4802
+ /// Specifies the display name to place in the bootstrapper application data manifest for the package. By default, ExePackages
4803
+ /// use the ProductName field from the version information, MsiPackages use the ProductName property, and MspPackages use
4804
+ /// the DisplayName patch metadata property. Other package types must use this attribute to define a display name in the
4805
+ /// bootstrapper application data manifest.
4806
+ /// </summary>
4807
+ public string DisplayName
4808
+ {
4809
+ get
4810
+ {
4811
+ return this.displayNameField;
4812
+ }
4813
+ set
4814
+ {
4815
+ this.displayNameFieldSet = true;
4816
+ this.displayNameField = value;
4817
+ }
4818
+ }
4819
+
4820
+ /// <summary>
4821
+ /// Specifies the description to place in the bootstrapper application data manifest for the package. By default, ExePackages
4822
+ /// use the FileName field from the version information, MsiPackages use the ARPCOMMENTS property, and MspPackages use
4823
+ /// the Description patch metadata property. Other package types must use this attribute to define a description in the
4824
+ /// bootstrapper application data manifest.
4825
+ /// </summary>
4826
+ public string Description
4827
+ {
4828
+ get
4829
+ {
4830
+ return this.descriptionField;
4831
+ }
4832
+ set
4833
+ {
4834
+ this.descriptionFieldSet = true;
4835
+ this.descriptionField = value;
4836
+ }
4837
+ }
4838
+
4839
+ /// <summary>
4840
+ /// Name of a Variable that will hold the path to the log file. An empty value will cause the variable to not
4841
+ /// be set. The default is "WixBundleLog_[PackageId]" except for MSU packages which default to no logging.
4842
+ /// </summary>
4843
+ public string LogPathVariable
4844
+ {
4845
+ get
4846
+ {
4847
+ return this.logPathVariableField;
4848
+ }
4849
+ set
4850
+ {
4851
+ this.logPathVariableFieldSet = true;
4852
+ this.logPathVariableField = value;
4853
+ }
4854
+ }
4855
+
4856
+ /// <summary>
4857
+ /// Name of a Variable that will hold the path to the log file used during rollback. An empty value will cause
4858
+ /// the variable to not be set. The default is "WixBundleRollbackLog_[PackageId]" except for MSU packages which
4859
+ /// default to no logging.
4860
+ /// </summary>
4861
+ public string RollbackLogPathVariable
4862
+ {
4863
+ get
4864
+ {
4865
+ return this.rollbackLogPathVariableField;
4866
+ }
4867
+ set
4868
+ {
4869
+ this.rollbackLogPathVariableFieldSet = true;
4870
+ this.rollbackLogPathVariableField = value;
4871
+ }
4872
+ }
4873
+
4874
+ /// <summary>
4875
+ /// Specifies whether the package can be uninstalled. The default is "no".
4876
+ /// </summary>
4877
+ public YesNoType Permanent
4878
+ {
4879
+ get
4880
+ {
4881
+ return this.permanentField;
4882
+ }
4883
+ set
4884
+ {
4885
+ this.permanentFieldSet = true;
4886
+ this.permanentField = value;
4887
+ }
4888
+ }
4889
+
4890
+ /// <summary>
4891
+ /// Specifies whether the package must succeed for the chain to continue. The default "yes"
4892
+ /// indicates that if the package fails then the chain will fail and rollback or stop. If
4893
+ /// "no" is specified then the chain will continue even if the package reports failure.
4894
+ /// </summary>
4895
+ public YesNoType Vital
4896
+ {
4897
+ get
4898
+ {
4899
+ return this.vitalField;
4900
+ }
4901
+ set
4902
+ {
4903
+ this.vitalFieldSet = true;
4904
+ this.vitalField = value;
4905
+ }
4906
+ }
4907
+
4908
+ /// <summary>
4909
+ /// Whether the package payload should be embedded in a container or left as an external payload.
4910
+ /// </summary>
4911
+ public YesNoDefaultType Compressed
4912
+ {
4913
+ get
4914
+ {
4915
+ return this.compressedField;
4916
+ }
4917
+ set
4918
+ {
4919
+ this.compressedFieldSet = true;
4920
+ this.compressedField = value;
4921
+ }
4922
+ }
4923
+
4924
+ /// <summary>
4925
+ /// By default, a Bundle will use the hash of a package to verify its contents. If this attribute is set to "yes"
4926
+ /// and the package is signed with an Authenticode signature the Bundle will verify the contents of the package using the
4927
+ /// signature instead. Beware that there are many real world issues with Windows verifying Authenticode signatures.
4928
+ /// Since the Authenticode signatures are no more secure than hashing the packages directly, the default is "no".
4929
+ /// </summary>
4930
+ public YesNoType EnableSignatureVerification
4931
+ {
4932
+ get
4933
+ {
4934
+ return this.enableSignatureVerificationField;
4935
+ }
4936
+ set
4937
+ {
4938
+ this.enableSignatureVerificationFieldSet = true;
4939
+ this.enableSignatureVerificationField = value;
4940
+ }
4941
+ }
4942
+
4943
+ /// <summary>
4944
+ /// Indicates the package must be executed elevated. The default is "no".
4945
+ /// </summary>
4946
+ public YesNoDefaultType PerMachine
4947
+ {
4948
+ get
4949
+ {
4950
+ return this.perMachineField;
4951
+ }
4952
+ set
4953
+ {
4954
+ this.perMachineFieldSet = true;
4955
+ this.perMachineField = value;
4956
+ }
4957
+ }
4958
+
4959
+ /// <summary>
4960
+ /// Specifies whether to automatically slipstream the patch for any target msi packages in the chain. The default is "no".
4961
+ /// Even when the value is "no", you can still author the SlipstreamMsp element under MsiPackage elements as desired.
4962
+ /// </summary>
4963
+ public YesNoType Slipstream
4964
+ {
4965
+ get
4966
+ {
4967
+ return this.slipstreamField;
4968
+ }
4969
+ set
4970
+ {
4971
+ this.slipstreamFieldSet = true;
4972
+ this.slipstreamField = value;
4973
+ }
4974
+ }
4975
+
4976
+ public virtual ISchemaElement ParentElement
4977
+ {
4978
+ get
4979
+ {
4980
+ return this.parentElement;
4981
+ }
4982
+ set
4983
+ {
4984
+ this.parentElement = value;
4985
+ }
4986
+ }
4987
+
4988
+ public virtual void AddChild(ISchemaElement child)
4989
+ {
4990
+ if ((null == child))
4991
+ {
4992
+ throw new ArgumentNullException("child");
4993
+ }
4994
+ this.children.AddElement(child);
4995
+ child.ParentElement = this;
4996
+ }
4997
+
4998
+ public virtual void RemoveChild(ISchemaElement child)
4999
+ {
This file is too large to show in full.
src/heat/TypeLibraryHarvester.cs
new
+93
@@ -0,0 +1,93 @@
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.Harvesters
4
+{
5
+ using System;
6
+ using System.Globalization;
7
+ using System.Runtime.InteropServices;
8
+ using Wix = WixToolset.Harvesters.Serialize;
9
+
10
+ /// <summary>
11
+ /// Harvest WiX authoring from a type library file.
12
+ /// </summary>
13
+ internal class TypeLibraryHarvester
14
+ {
15
+ /// <summary>
16
+ /// Harvest the registry values written by RegisterTypeLib.
17
+ /// </summary>
18
+ /// <param name="path">The file to harvest registry values from.</param>
19
+ /// <returns>The harvested registry values.</returns>
20
+ public Wix.RegistryValue[] HarvestRegistryValues(string path)
21
+ {
22
+ using (RegistryHarvester registryHarvester = new RegistryHarvester(true))
23
+ {
24
+ NativeMethods.RegisterTypeLibrary(path);
25
+
26
+ return registryHarvester.HarvestRegistry();
27
+ }
28
+ }
29
+
30
+ /// <summary>
31
+ /// Parses a hexadecimal version string into a Version object.
32
+ /// </summary>
33
+ /// <param name="versionString">Hexadecimal version string, for example "1.A.3C.F241"</param>
34
+ /// <returns>Version object, or null if versionString is not a valid hex version.</returns>
35
+ public static Version ParseHexVersion(string versionString)
36
+ {
37
+ if (String.IsNullOrEmpty(versionString))
38
+ {
39
+ return null;
40
+ }
41
+
42
+ int[] versionNumbers = new int[4];
43
+ string[] versionNumberStrings = versionString.Split('.');
44
+
45
+ for (int i = 0; i < versionNumbers.Length && i < versionNumberStrings.Length; i++)
46
+ {
47
+ if (!Int32.TryParse(versionNumberStrings[i], NumberStyles.HexNumber, CultureInfo.InvariantCulture, out versionNumbers[i]))
48
+ {
49
+ return null;
50
+ }
51
+ }
52
+
53
+ return new Version(versionNumbers[0], versionNumbers[1], versionNumbers[2], versionNumbers[3]);
54
+ }
55
+
56
+ /// <summary>
57
+ /// Native methods for registering type libraries.
58
+ /// </summary>
59
+ private sealed class NativeMethods
60
+ {
61
+ /// <summary>
62
+ /// Registers a type library.
63
+ /// </summary>
64
+ /// <param name="typeLibraryFile">The type library file to register.</param>
65
+ internal static void RegisterTypeLibrary(string typeLibraryFile)
66
+ {
67
+ IntPtr ptlib;
68
+
69
+ LoadTypeLib(typeLibraryFile, out ptlib);
70
+
71
+ RegisterTypeLib(ptlib, typeLibraryFile, null);
72
+ }
73
+
74
+ /// <summary>
75
+ /// Loads and registers a type library.
76
+ /// </summary>
77
+ /// <param name="szFile">Contains the name of the file from which LoadTypeLib should attempt to load a type library.</param>
78
+ /// <param name="pptlib">On return, contains a pointer to a pointer to the loaded type library.</param>
79
+ /// <remarks>LoadTypeLib will not register the type library if the path of the type library is specified.</remarks>
80
+ [DllImport("oleaut32.dll", PreserveSig = false)]
81
+ private static extern void LoadTypeLib([MarshalAs(UnmanagedType.BStr)] string szFile, out IntPtr pptlib);
82
+
83
+ /// <summary>
84
+ /// Adds information about a type library to the system registry.
85
+ /// </summary>
86
+ /// <param name="ptlib">Pointer to the type library being registered.</param>
87
+ /// <param name="szFullPath">Fully qualified path specification for the type library being registered.</param>
88
+ /// <param name="szHelpDir">Directory in which the Help file for the library being registered can be found. Can be Null.</param>
89
+ [DllImport("oleaut32.dll", PreserveSig = false)]
90
+ private static extern void RegisterTypeLib(IntPtr ptlib, [MarshalAs(UnmanagedType.BStr)] string szFullPath, [MarshalAs(UnmanagedType.BStr)] string szHelpDir);
91
+ }
92
+ }
93
+}
src/heat/UtilFinalizeHarvesterMutator.cs
new
+1185
@@ -0,0 +1,1185 @@
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.Harvesters
4
+{
5
+ using System;
6
+ using System.Collections;
7
+ using System.Collections.Generic;
8
+ using System.Collections.Specialized;
9
+ using System.Globalization;
10
+ using System.IO;
11
+ using System.Runtime.InteropServices;
12
+ using System.Text;
13
+ using WixToolset.Harvesters.Data;
14
+ using WixToolset.Harvesters.Extensibility;
15
+ using Wix = WixToolset.Harvesters.Serialize;
16
+
17
+ /// <summary>
18
+ /// The finalize harvester mutator for the WiX Toolset Utility Extension.
19
+ /// </summary>
20
+ internal class UtilFinalizeHarvesterMutator : BaseMutatorExtension
21
+ {
22
+ private ArrayList components;
23
+ private ArrayList directories;
24
+ private SortedList directoryPaths;
25
+ private Hashtable filePaths;
26
+ private ArrayList files;
27
+ private ArrayList registryValues;
28
+ private bool suppressCOMElements;
29
+ private bool suppressVB6COMElements;
30
+ private string preprocessorVariable;
31
+
32
+ /// <summary>
33
+ /// Instantiate a new UtilFinalizeHarvesterMutator.
34
+ /// </summary>
35
+ public UtilFinalizeHarvesterMutator()
36
+ {
37
+ this.components = new ArrayList();
38
+ this.directories = new ArrayList();
39
+ this.directoryPaths = new SortedList();
40
+ this.filePaths = new Hashtable();
41
+ this.files = new ArrayList();
42
+ this.registryValues = new ArrayList();
43
+ }
44
+
45
+ /// <summary>
46
+ /// Gets or sets the preprocessor variable for substitution.
47
+ /// </summary>
48
+ /// <value>The preprocessor variable for substitution.</value>
49
+ public string PreprocessorVariable
50
+ {
51
+ get { return this.preprocessorVariable; }
52
+ set { this.preprocessorVariable = value; }
53
+ }
54
+
55
+ /// <summary>
56
+ /// Gets the sequence of the extension.
57
+ /// </summary>
58
+ /// <value>The sequence of the extension.</value>
59
+ public override int Sequence
60
+ {
61
+ get { return 2000; }
62
+ }
63
+
64
+ /// <summary>
65
+ /// Gets or sets the option to suppress COM elements.
66
+ /// </summary>
67
+ /// <value>The option to suppress COM elements.</value>
68
+ public bool SuppressCOMElements
69
+ {
70
+ get { return this.suppressCOMElements; }
71
+ set { this.suppressCOMElements = value; }
72
+ }
73
+
74
+ /// <summary>
75
+ /// Gets or sets the option to suppress VB6 COM elements.
76
+ /// </summary>
77
+ /// <value>The option to suppress VB6 COM elements.</value>
78
+ public bool SuppressVB6COMElements
79
+ {
80
+ get { return this.suppressVB6COMElements; }
81
+ set { this.suppressVB6COMElements = value; }
82
+ }
83
+
84
+ /// <summary>
85
+ /// Mutate a WiX document.
86
+ /// </summary>
87
+ /// <param name="wix">The Wix document element.</param>
88
+ public override void Mutate(Wix.Wix wix)
89
+ {
90
+ this.components.Clear();
91
+ this.directories.Clear();
92
+ this.directoryPaths.Clear();
93
+ this.filePaths.Clear();
94
+ this.files.Clear();
95
+ this.registryValues.Clear();
96
+
97
+ // index elements in this wix document
98
+ this.IndexElement(wix);
99
+
100
+ this.MutateDirectories();
101
+ this.MutateFiles();
102
+ this.MutateRegistryValues();
103
+
104
+ // must occur after all the registry values have been formatted
105
+ this.MutateComponents();
106
+ }
107
+
108
+ /// <summary>
109
+ /// Index an element.
110
+ /// </summary>
111
+ /// <param name="element">The element to index.</param>
112
+ private void IndexElement(Wix.ISchemaElement element)
113
+ {
114
+ if (element is Wix.Component)
115
+ {
116
+ // Component elements only need to be indexed if COM registry values will be strongly typed
117
+ if (!this.suppressCOMElements)
118
+ {
119
+ this.components.Add(element);
120
+ }
121
+ }
122
+ else if (element is Wix.Directory)
123
+ {
124
+ this.directories.Add(element);
125
+ }
126
+ else if (element is Wix.File)
127
+ {
128
+ this.files.Add(element);
129
+ }
130
+ else if (element is Wix.RegistryValue)
131
+ {
132
+ this.registryValues.Add(element);
133
+ }
134
+
135
+ // index the child elements
136
+ if (element is Wix.IParentElement)
137
+ {
138
+ foreach (Wix.ISchemaElement childElement in ((Wix.IParentElement)element).Children)
139
+ {
140
+ this.IndexElement(childElement);
141
+ }
142
+ }
143
+ }
144
+
145
+ /// <summary>
146
+ /// Mutate the components.
147
+ /// </summary>
148
+ private void MutateComponents()
149
+ {
150
+ if (this.suppressVB6COMElements)
151
+ {
152
+ // Search for VB6 specific COM registrations
153
+ foreach (Wix.Component component in this.components)
154
+ {
155
+ ArrayList vb6RegistryValues = new ArrayList();
156
+
157
+ foreach (Wix.RegistryValue registryValue in component[typeof(Wix.RegistryValue)])
158
+ {
159
+ if (Wix.RegistryValue.ActionType.write == registryValue.Action && Wix.RegistryRootType.HKCR == registryValue.Root)
160
+ {
161
+ string[] parts = registryValue.Key.Split('\\');
162
+
163
+ if (String.Equals(parts[0], "CLSID", StringComparison.OrdinalIgnoreCase))
164
+ {
165
+ // Search for the VB6 CLSID {D5DE8D20-5BB8-11D1-A1E3-00A0C90F2731}
166
+ if (2 <= parts.Length)
167
+ {
168
+ if (String.Equals(parts[1], "{D5DE8D20-5BB8-11D1-A1E3-00A0C90F2731}", StringComparison.OrdinalIgnoreCase))
169
+ {
170
+ if (!vb6RegistryValues.Contains(registryValue))
171
+ {
172
+ vb6RegistryValues.Add(registryValue);
173
+ }
174
+ }
175
+ }
176
+ }
177
+ else if (String.Equals(parts[0], "TypeLib", StringComparison.OrdinalIgnoreCase))
178
+ {
179
+ // Search for the VB6 TypeLibs {EA544A21-C82D-11D1-A3E4-00A0C90AEA82} or {000204EF-0000-0000-C000-000000000046}
180
+ if (2 <= parts.Length)
181
+ {
182
+ if (String.Equals(parts[1], "{EA544A21-C82D-11D1-A3E4-00A0C90AEA82}", StringComparison.OrdinalIgnoreCase) ||
183
+ String.Equals(parts[1], "{000204EF-0000-0000-C000-000000000046}", StringComparison.OrdinalIgnoreCase))
184
+ {
185
+ if (!vb6RegistryValues.Contains(registryValue))
186
+ {
187
+ vb6RegistryValues.Add(registryValue);
188
+ }
189
+ }
190
+ }
191
+ }
192
+ else if (String.Equals(parts[0], "Interface", StringComparison.OrdinalIgnoreCase))
193
+ {
194
+ // Search for any Interfaces that reference the VB6 TypeLibs {EA544A21-C82D-11D1-A3E4-00A0C90AEA82} or {000204EF-0000-0000-C000-000000000046}
195
+ if (3 <= parts.Length)
196
+ {
197
+ if (String.Equals(parts[2], "TypeLib", StringComparison.OrdinalIgnoreCase))
198
+ {
199
+ if (String.Equals(registryValue.Value, "{EA544A21-C82D-11D1-A3E4-00A0C90AEA82}", StringComparison.OrdinalIgnoreCase) ||
200
+ String.Equals(registryValue.Value, "{000204EF-0000-0000-C000-000000000046}", StringComparison.OrdinalIgnoreCase))
201
+ {
202
+ // Having found a match we have to loop through again finding the matching Interface entries
203
+ foreach (Wix.RegistryValue regValue in component[typeof(Wix.RegistryValue)])
204
+ {
205
+ if (Wix.RegistryValue.ActionType.write == regValue.Action && Wix.RegistryRootType.HKCR == regValue.Root)
206
+ {
207
+ string[] rvparts = regValue.Key.Split('\\');
208
+ if (String.Equals(rvparts[0], "Interface", StringComparison.OrdinalIgnoreCase))
209
+ {
210
+ if (2 <= rvparts.Length)
211
+ {
212
+ if (String.Equals(rvparts[1], parts[1], StringComparison.OrdinalIgnoreCase))
213
+ {
214
+ if (!vb6RegistryValues.Contains(regValue))
215
+ {
216
+ vb6RegistryValues.Add(regValue);
217
+ }
218
+ }
219
+ }
220
+ }
221
+ }
222
+ }
223
+ }
224
+ }
225
+ }
226
+ }
227
+ }
228
+ }
229
+
230
+ // Remove all the VB6 specific COM registry values
231
+ foreach (Object entry in vb6RegistryValues)
232
+ {
233
+ component.RemoveChild((Wix.RegistryValue)entry);
234
+ }
235
+ }
236
+ }
237
+
238
+ foreach (Wix.Component component in this.components)
239
+ {
240
+ SortedList indexedElements = CollectionsUtil.CreateCaseInsensitiveSortedList();
241
+ SortedList indexedRegistryValues = CollectionsUtil.CreateCaseInsensitiveSortedList();
242
+ List<Wix.RegistryValue> duplicateRegistryValues = new List<Wix.RegistryValue>();
243
+
244
+ // index all the File elements
245
+ foreach (Wix.File file in component[typeof(Wix.File)])
246
+ {
247
+ indexedElements.Add(String.Concat("file/", file.Id), file);
248
+ }
249
+
250
+ // group all the registry values by the COM element they would correspond to and
251
+ // create a COM element for each group
252
+ foreach (Wix.RegistryValue registryValue in component[typeof(Wix.RegistryValue)])
253
+ {
254
+ if (!String.IsNullOrEmpty(registryValue.Key) && Wix.RegistryValue.ActionType.write == registryValue.Action && Wix.RegistryRootType.HKCR == registryValue.Root && Wix.RegistryValue.TypeType.@string == registryValue.Type)
255
+ {
256
+ string index = null;
257
+ string[] parts = registryValue.Key.Split('\\');
258
+
259
+ // create a COM element for COM registration and index it
260
+ if (1 <= parts.Length)
261
+ {
262
+ if (String.Equals(parts[0], "AppID", StringComparison.OrdinalIgnoreCase))
263
+ {
264
+ // only work with GUID AppIds here
265
+ if (2 <= parts.Length && parts[1].StartsWith("{", StringComparison.Ordinal) && parts[1].EndsWith("}", StringComparison.Ordinal))
266
+ {
267
+ index = String.Concat(parts[0], '/', parts[1]);
268
+
269
+ if (!indexedElements.Contains(index))
270
+ {
271
+ Wix.AppId appId = new Wix.AppId();
272
+ appId.Id = parts[1].ToUpper(CultureInfo.InvariantCulture);
273
+ indexedElements.Add(index, appId);
274
+ }
275
+ }
276
+ }
277
+ else if (String.Equals(parts[0], "CLSID", StringComparison.OrdinalIgnoreCase))
278
+ {
279
+ if (2 <= parts.Length)
280
+ {
281
+ index = String.Concat(parts[0], '/', parts[1]);
282
+
283
+ if (!indexedElements.Contains(index))
284
+ {
285
+ Wix.Class wixClass = new Wix.Class();
286
+ wixClass.Id = parts[1].ToUpper(CultureInfo.InvariantCulture);
287
+ indexedElements.Add(index, wixClass);
288
+ }
289
+ }
290
+ }
291
+ else if (String.Equals(parts[0], "Component Categories", StringComparison.OrdinalIgnoreCase))
292
+ {
293
+ // If this is the .NET Component Category it should not end up in the authoring. Therefore, add
294
+ // the registry key to the duplicate list to ensure it gets removed later.
295
+ if (String.Equals(parts[1], "{62C8FE65-4EBB-45e7-B440-6E39B2CDBF29}", StringComparison.OrdinalIgnoreCase))
296
+ {
297
+ duplicateRegistryValues.Add(registryValue);
298
+ }
299
+ else
300
+ {
301
+ // TODO: add support for Component Categories to the compiler.
302
+ }
303
+ }
304
+ else if (String.Equals(parts[0], "Interface", StringComparison.OrdinalIgnoreCase))
305
+ {
306
+ if (2 <= parts.Length)
307
+ {
308
+ index = String.Concat(parts[0], '/', parts[1]);
309
+
310
+ if (!indexedElements.Contains(index))
311
+ {
312
+ Wix.Interface wixInterface = new Wix.Interface();
313
+ wixInterface.Id = parts[1].ToUpper(CultureInfo.InvariantCulture);
314
+ indexedElements.Add(index, wixInterface);
315
+ }
316
+ }
317
+ }
318
+ else if (String.Equals(parts[0], "TypeLib", StringComparison.Ordinal))
319
+ {
320
+ if (3 <= parts.Length)
321
+ {
322
+ // use a special index to ensure progIds are processed before classes
323
+ index = String.Concat(".typelib/", parts[1], '/', parts[2]);
324
+
325
+ if (!indexedElements.Contains(index))
326
+ {
327
+ Version version = TypeLibraryHarvester.ParseHexVersion(parts[2]);
328
+ if (version != null)
329
+ {
330
+ Wix.TypeLib typeLib = new Wix.TypeLib();
331
+ typeLib.Id = parts[1].ToUpper(CultureInfo.InvariantCulture);
332
+ typeLib.MajorVersion = version.Major;
333
+ typeLib.MinorVersion = version.Minor;
334
+ indexedElements.Add(index, typeLib);
335
+ }
336
+ else // not a valid type library registry value
337
+ {
338
+ index = null;
339
+ }
340
+ }
341
+ }
342
+ }
343
+ else if (parts[0].StartsWith(".", StringComparison.Ordinal))
344
+ {
345
+ // extension
346
+ }
347
+ else // ProgId (hopefully)
348
+ {
349
+ // use a special index to ensure progIds are processed before classes
350
+ index = String.Concat(".progid/", parts[0]);
351
+
352
+ if (!indexedElements.Contains(index))
353
+ {
354
+ Wix.ProgId progId = new Wix.ProgId();
355
+ progId.Id = parts[0];
356
+ indexedElements.Add(index, progId);
357
+ }
358
+ }
359
+ }
360
+
361
+ // index the RegistryValue element according to the COM element it corresponds to
362
+ if (null != index)
363
+ {
364
+ SortedList registryValues = (SortedList)indexedRegistryValues[index];
365
+
366
+ if (null == registryValues)
367
+ {
368
+ registryValues = CollectionsUtil.CreateCaseInsensitiveSortedList();
369
+ indexedRegistryValues.Add(index, registryValues);
370
+ }
371
+
372
+ try
373
+ {
374
+ registryValues.Add(String.Concat(registryValue.Key, '/', registryValue.Name), registryValue);
375
+ }
376
+ catch (ArgumentException)
377
+ {
378
+ duplicateRegistryValues.Add(registryValue);
379
+
380
+ if (String.IsNullOrEmpty(registryValue.Value))
381
+ {
382
+ this.Core.Messaging.Write(HarvesterWarnings.DuplicateDllRegistryEntry(String.Concat(registryValue.Key, '/', registryValue.Name), component.Id));
383
+ }
384
+ else
385
+ {
386
+ this.Core.Messaging.Write(HarvesterWarnings.DuplicateDllRegistryEntry(String.Concat(registryValue.Key, '/', registryValue.Name), registryValue.Value, component.Id));
387
+ }
388
+ }
389
+ }
390
+ }
391
+ }
392
+
393
+ foreach (Wix.RegistryValue removeRegistryEntry in duplicateRegistryValues)
394
+ {
395
+ component.RemoveChild(removeRegistryEntry);
396
+ }
397
+
398
+ // set various values on the COM elements from their corresponding registry values
399
+ Hashtable indexedProcessedRegistryValues = new Hashtable();
400
+ foreach (DictionaryEntry entry in indexedRegistryValues)
401
+ {
402
+ Wix.ISchemaElement element = (Wix.ISchemaElement)indexedElements[entry.Key];
403
+ string parentIndex = null;
404
+ SortedList registryValues = (SortedList)entry.Value;
405
+
406
+ // element-specific variables (for really tough situations)
407
+ string classAppId = null;
408
+ bool threadingModelSet = false;
409
+
410
+ foreach (Wix.RegistryValue registryValue in registryValues.Values)
411
+ {
412
+ string[] parts = registryValue.Key.ToLower(CultureInfo.InvariantCulture).Split('\\');
413
+ bool processed = false;
414
+
415
+ if (element is Wix.AppId)
416
+ {
417
+ Wix.AppId appId = (Wix.AppId)element;
418
+
419
+ if (2 == parts.Length)
420
+ {
421
+ if (null == registryValue.Name)
422
+ {
423
+ appId.Description = registryValue.Value;
424
+ processed = true;
425
+ }
426
+ }
427
+ }
428
+ else if (element is Wix.Class)
429
+ {
430
+ Wix.Class wixClass = (Wix.Class)element;
431
+
432
+ if (2 == parts.Length)
433
+ {
434
+ if (null == registryValue.Name)
435
+ {
436
+ wixClass.Description = registryValue.Value;
437
+ processed = true;
438
+ }
439
+ else if (String.Equals(registryValue.Name, "AppID", StringComparison.OrdinalIgnoreCase))
440
+ {
441
+ classAppId = registryValue.Value;
442
+ processed = true;
443
+ }
444
+ }
445
+ else if (3 == parts.Length)
446
+ {
447
+ Wix.Class.ContextType contextType = Wix.Class.ContextType.None;
448
+
449
+ switch (parts[2])
450
+ {
451
+ case "control":
452
+ wixClass.Control = Wix.YesNoType.yes;
453
+ processed = true;
454
+ break;
455
+ case "inprochandler":
456
+ if (null == registryValue.Name)
457
+ {
458
+ if (null == wixClass.Handler)
459
+ {
460
+ wixClass.Handler = "1";
461
+ processed = true;
462
+ }
463
+ else if ("2" == wixClass.Handler)
464
+ {
465
+ wixClass.Handler = "3";
466
+ processed = true;
467
+ }
468
+ }
469
+ break;
470
+ case "inprochandler32":
471
+ if (null == registryValue.Name)
472
+ {
473
+ if (null == wixClass.Handler)
474
+ {
475
+ wixClass.Handler = "2";
476
+ processed = true;
477
+ }
478
+ else if ("1" == wixClass.Handler)
479
+ {
480
+ wixClass.Handler = "3";
481
+ processed = true;
482
+ }
483
+ }
484
+ break;
485
+ case "inprocserver":
486
+ contextType = Wix.Class.ContextType.InprocServer;
487
+ break;
488
+ case "inprocserver32":
489
+ contextType = Wix.Class.ContextType.InprocServer32;
490
+ break;
491
+ case "insertable":
492
+ wixClass.Insertable = Wix.YesNoType.yes;
493
+ processed = true;
494
+ break;
495
+ case "localserver":
496
+ contextType = Wix.Class.ContextType.LocalServer;
497
+ break;
498
+ case "localserver32":
499
+ contextType = Wix.Class.ContextType.LocalServer32;
500
+ break;
501
+ case "progid":
502
+ if (null == registryValue.Name)
503
+ {
504
+ Wix.ProgId progId = (Wix.ProgId)indexedElements[String.Concat(".progid/", registryValue.Value)];
505
+
506
+ // verify that the versioned ProgId appears under this Class element
507
+ // if not, toss the entire element
508
+ if (null == progId || wixClass != progId.ParentElement)
509
+ {
510
+ element = null;
511
+ }
512
+ else
513
+ {
514
+ processed = true;
515
+ }
516
+ }
517
+ break;
518
+ case "programmable":
519
+ wixClass.Programmable = Wix.YesNoType.yes;
520
+ processed = true;
521
+ break;
522
+ case "typelib":
523
+ if (null == registryValue.Name)
524
+ {
525
+ foreach (DictionaryEntry indexedEntry in indexedElements)
526
+ {
527
+ string key = (string)indexedEntry.Key;
528
+ Wix.ISchemaElement possibleTypeLib = (Wix.ISchemaElement)indexedEntry.Value;
529
+
530
+ if (key.StartsWith(".typelib/", StringComparison.Ordinal) &&
531
+ 0 == String.Compare(key, 9, registryValue.Value, 0, registryValue.Value.Length, StringComparison.OrdinalIgnoreCase))
532
+ {
533
+ // ensure the TypeLib is nested under the same thing we want the Class under
534
+ if (null == parentIndex || indexedElements[parentIndex] == possibleTypeLib.ParentElement)
535
+ {
536
+ parentIndex = key;
537
+ processed = true;
538
+ }
539
+ }
540
+ }
541
+ }
542
+ break;
543
+ case "version":
544
+ if (null == registryValue.Name)
545
+ {
546
+ wixClass.Version = registryValue.Value;
547
+ processed = true;
548
+ }
549
+ break;
550
+ case "versionindependentprogid":
551
+ if (null == registryValue.Name)
552
+ {
553
+ Wix.ProgId progId = (Wix.ProgId)indexedElements[String.Concat(".progid/", registryValue.Value)];
554
+
555
+ // verify that the version independent ProgId appears somewhere
556
+ // under this Class element - if not, toss the entire element
557
+ if (null == progId || wixClass != progId.ParentElement)
558
+ {
559
+ // check the parent of the parent
560
+ if (null == progId || null == progId.ParentElement || wixClass != progId.ParentElement.ParentElement)
561
+ {
562
+ element = null;
563
+ }
564
+ }
565
+
566
+ processed = true;
567
+ }
568
+ break;
569
+ }
570
+
571
+ if (Wix.Class.ContextType.None != contextType)
572
+ {
573
+ wixClass.Context |= contextType;
574
+
575
+ if (null == registryValue.Name)
576
+ {
577
+ if ((registryValue.Value.StartsWith("[!", StringComparison.Ordinal) || registryValue.Value.StartsWith("[#", StringComparison.Ordinal))
578
+ && registryValue.Value.EndsWith("]", StringComparison.Ordinal))
579
+ {
580
+ parentIndex = String.Concat("file/", registryValue.Value.Substring(2, registryValue.Value.Length - 3));
581
+ processed = true;
582
+ }
583
+ else if (String.Equals(Path.GetFileName(registryValue.Value), "mscoree.dll", StringComparison.OrdinalIgnoreCase))
584
+ {
585
+ wixClass.ForeignServer = "mscoree.dll";
586
+ processed = true;
587
+ }
588
+ else if (String.Equals(Path.GetFileName(registryValue.Value), "msvbvm60.dll", StringComparison.OrdinalIgnoreCase))
589
+ {
590
+ wixClass.ForeignServer = "msvbvm60.dll";
591
+ processed = true;
592
+ }
593
+ else
594
+ {
595
+ // Some servers are specifying relative paths (which the above code doesn't find)
596
+ // If there's any ambiguity leave it alone and let the developer figure it out when it breaks in the compiler
597
+
598
+ bool possibleDuplicate = false;
599
+ string possibleParentIndex = null;
600
+
601
+ foreach (Wix.File file in this.files)
602
+ {
603
+ if (String.Equals(registryValue.Value, Path.GetFileName(file.Source), StringComparison.OrdinalIgnoreCase))
604
+ {
605
+ if (null == possibleParentIndex)
606
+ {
607
+ possibleParentIndex = String.Concat("file/", file.Id);
608
+ }
609
+ else
610
+ {
611
+ possibleDuplicate = true;
612
+ break;
613
+ }
614
+ }
615
+ }
616
+
617
+ if (!possibleDuplicate)
618
+ {
619
+ if (null == possibleParentIndex)
620
+ {
621
+ wixClass.ForeignServer = registryValue.Value;
622
+ processed = true;
623
+ }
624
+ else
625
+ {
626
+ parentIndex = possibleParentIndex;
627
+ wixClass.RelativePath = Wix.YesNoType.yes;
628
+ processed = true;
629
+ }
630
+ }
631
+ }
632
+ }
633
+ else if (String.Equals(registryValue.Name, "ThreadingModel", StringComparison.OrdinalIgnoreCase))
634
+ {
635
+ Wix.Class.ThreadingModelType threadingModel;
636
+
637
+ if (String.Equals(registryValue.Value, "apartment", StringComparison.OrdinalIgnoreCase))
638
+ {
639
+ threadingModel = Wix.Class.ThreadingModelType.apartment;
640
+ processed = true;
641
+ }
642
+ else if (String.Equals(registryValue.Value, "both", StringComparison.OrdinalIgnoreCase))
643
+ {
644
+ threadingModel = Wix.Class.ThreadingModelType.both;
645
+ processed = true;
646
+ }
647
+ else if (String.Equals(registryValue.Value, "free", StringComparison.OrdinalIgnoreCase))
648
+ {
649
+ threadingModel = Wix.Class.ThreadingModelType.free;
650
+ processed = true;
651
+ }
652
+ else if (String.Equals(registryValue.Value, "neutral", StringComparison.OrdinalIgnoreCase))
653
+ {
654
+ threadingModel = Wix.Class.ThreadingModelType.neutral;
655
+ processed = true;
656
+ }
657
+ else if (String.Equals(registryValue.Value, "rental", StringComparison.OrdinalIgnoreCase))
658
+ {
659
+ threadingModel = Wix.Class.ThreadingModelType.rental;
660
+ processed = true;
661
+ }
662
+ else if (String.Equals(registryValue.Value, "single", StringComparison.OrdinalIgnoreCase))
663
+ {
664
+ threadingModel = Wix.Class.ThreadingModelType.single;
665
+ processed = true;
666
+ }
667
+ else
668
+ {
669
+ continue;
670
+ }
671
+
672
+ if (!threadingModelSet || wixClass.ThreadingModel == threadingModel)
673
+ {
674
+ wixClass.ThreadingModel = threadingModel;
675
+ threadingModelSet = true;
676
+ }
677
+ else
678
+ {
679
+ element = null;
680
+ break;
681
+ }
682
+ }
683
+ }
684
+ }
685
+ else if (4 == parts.Length)
686
+ {
687
+ if (String.Equals(parts[2], "implemented categories", StringComparison.Ordinal))
688
+ {
689
+ switch (parts[3])
690
+ {
691
+ case "{7dd95801-9882-11cf-9fa9-00aa006c42c4}":
692
+ wixClass.SafeForScripting = Wix.YesNoType.yes;
693
+ processed = true;
694
+ break;
695
+ case "{7dd95802-9882-11cf-9fa9-00aa006c42c4}":
696
+ wixClass.SafeForInitializing = Wix.YesNoType.yes;
697
+ processed = true;
698
+ break;
699
+ }
700
+ }
701
+ }
702
+ }
703
+ else if (element is Wix.Interface)
704
+ {
705
+ Wix.Interface wixInterface = (Wix.Interface)element;
706
+
707
+ if (2 == parts.Length && null == registryValue.Name)
708
+ {
709
+ wixInterface.Name = registryValue.Value;
710
+ processed = true;
711
+ }
712
+ else if (3 == parts.Length)
713
+ {
714
+ switch (parts[2])
715
+ {
716
+ case "proxystubclsid":
717
+ if (null == registryValue.Name)
718
+ {
719
+ wixInterface.ProxyStubClassId = registryValue.Value.ToUpper(CultureInfo.InvariantCulture);
720
+ processed = true;
721
+ }
722
+ break;
723
+ case "proxystubclsid32":
724
+ if (null == registryValue.Name)
725
+ {
726
+ wixInterface.ProxyStubClassId32 = registryValue.Value.ToUpper(CultureInfo.InvariantCulture);
727
+ processed = true;
728
+ }
729
+ break;
730
+ case "nummethods":
731
+ if (null == registryValue.Name)
732
+ {
733
+ wixInterface.NumMethods = Convert.ToInt32(registryValue.Value, CultureInfo.InvariantCulture);
734
+ processed = true;
735
+ }
736
+ break;
737
+ case "typelib":
738
+ if (String.Equals("Version", registryValue.Name, StringComparison.OrdinalIgnoreCase))
739
+ {
740
+ parentIndex = String.Concat(parentIndex, registryValue.Value);
741
+ processed = true;
742
+ }
743
+ else if (null == registryValue.Name) // TypeLib guid
744
+ {
745
+ parentIndex = String.Concat(".typelib/", registryValue.Value, '/', parentIndex);
746
+ processed = true;
747
+ }
748
+ break;
749
+ }
750
+ }
751
+ }
752
+ else if (element is Wix.ProgId)
753
+ {
754
+ Wix.ProgId progId = (Wix.ProgId)element;
755
+
756
+ if (null == registryValue.Name)
757
+ {
758
+ if (1 == parts.Length)
759
+ {
760
+ progId.Description = registryValue.Value;
761
+ processed = true;
762
+ }
763
+ else if (2 == parts.Length)
764
+ {
765
+ if (String.Equals(parts[1], "CLSID", StringComparison.OrdinalIgnoreCase))
766
+ {
767
+ parentIndex = String.Concat("CLSID/", registryValue.Value);
768
+ processed = true;
769
+ }
770
+ else if (String.Equals(parts[1], "CurVer", StringComparison.OrdinalIgnoreCase))
771
+ {
772
+ // If a progId points to its own ProgId with CurVer, it isn't meaningful, so ignore it
773
+ if (!String.Equals(progId.Id, registryValue.Value, StringComparison.OrdinalIgnoreCase))
774
+ {
775
+ // this registry value should usually be processed second so the
776
+ // version independent ProgId should be under the versioned one
777
+ parentIndex = String.Concat(".progid/", registryValue.Value);
778
+ processed = true;
779
+ }
780
+ }
781
+ }
782
+ }
783
+ }
784
+ else if (element is Wix.TypeLib)
785
+ {
786
+ Wix.TypeLib typeLib = (Wix.TypeLib)element;
787
+
788
+ if (null == registryValue.Name)
789
+ {
790
+ if (3 == parts.Length)
791
+ {
792
+ typeLib.Description = registryValue.Value;
793
+ processed = true;
794
+ }
795
+ else if (4 == parts.Length)
796
+ {
797
+ if (String.Equals(parts[3], "flags", StringComparison.OrdinalIgnoreCase))
798
+ {
799
+ int flags = Convert.ToInt32(registryValue.Value, CultureInfo.InvariantCulture);
800
+
801
+ if (0x1 == (flags & 0x1))
802
+ {
803
+ typeLib.Restricted = Wix.YesNoType.yes;
804
+ }
805
+
806
+ if (0x2 == (flags & 0x2))
807
+ {
808
+ typeLib.Control = Wix.YesNoType.yes;
809
+ }
810
+
811
+ if (0x4 == (flags & 0x4))
812
+ {
813
+ typeLib.Hidden = Wix.YesNoType.yes;
814
+ }
815
+
816
+ if (0x8 == (flags & 0x8))
817
+ {
818
+ typeLib.HasDiskImage = Wix.YesNoType.yes;
819
+ }
820
+
821
+ processed = true;
822
+ }
823
+ else if (String.Equals(parts[3], "helpdir", StringComparison.OrdinalIgnoreCase))
824
+ {
825
+ if (registryValue.Value.StartsWith("[", StringComparison.Ordinal) && (registryValue.Value.EndsWith("]", StringComparison.Ordinal)
826
+ || registryValue.Value.EndsWith("]\\", StringComparison.Ordinal)))
827
+ {
828
+ typeLib.HelpDirectory = registryValue.Value.Substring(1, registryValue.Value.LastIndexOf(']') - 1);
829
+ }
830
+ else if (0 == String.Compare(registryValue.Value, Environment.SystemDirectory, StringComparison.OrdinalIgnoreCase)) // VB6 DLLs register their help directory as SystemFolder
831
+ {
832
+ typeLib.HelpDirectory = "SystemFolder";
833
+ }
834
+ else if (null != component.Directory) // -sfrag has not been specified
835
+ {
836
+ typeLib.HelpDirectory = component.Directory;
837
+ }
838
+ else if (component.ParentElement is Wix.Directory) // -sfrag has been specified
839
+ {
840
+ typeLib.HelpDirectory = ((Wix.Directory)component.ParentElement).Id;
841
+ }
842
+ else if (component.ParentElement is Wix.DirectoryRef) // -sfrag has been specified
843
+ {
844
+ typeLib.HelpDirectory = ((Wix.DirectoryRef)component.ParentElement).Id;
845
+ }
846
+
847
+ //If the helpdir has not matched a known directory, drop it because it cannot be resolved.
848
+ processed = true;
849
+ }
850
+ }
851
+ else if (5 == parts.Length && String.Equals("win32", parts[4], StringComparison.OrdinalIgnoreCase))
852
+ {
853
+ typeLib.Language = Convert.ToInt32(parts[3], CultureInfo.InvariantCulture);
854
+
855
+ if ((registryValue.Value.StartsWith("[!", StringComparison.Ordinal) || registryValue.Value.StartsWith("[#", StringComparison.Ordinal))
856
+ && registryValue.Value.EndsWith("]", StringComparison.Ordinal))
857
+ {
858
+ parentIndex = String.Concat("file/", registryValue.Value.Substring(2, registryValue.Value.Length - 3));
859
+ }
860
+
861
+ processed = true;
862
+ }
863
+ }
864
+ }
865
+
866
+ // index the processed registry values by their corresponding COM element
867
+ if (processed)
868
+ {
869
+ indexedProcessedRegistryValues.Add(registryValue, element);
870
+ }
871
+ }
872
+
873
+ // parent the COM element
874
+ if (null != element)
875
+ {
876
+ if (null != parentIndex)
877
+ {
878
+ Wix.IParentElement parentElement = (Wix.IParentElement)indexedElements[parentIndex];
879
+
880
+ if (null != parentElement)
881
+ {
882
+ parentElement.AddChild(element);
883
+ }
884
+ }
885
+ else if (0 < indexedProcessedRegistryValues.Count)
886
+ {
887
+ component.AddChild(element);
888
+ }
889
+
890
+ // special handling for AppID since it doesn't fit the general model
891
+ if (null != classAppId)
892
+ {
893
+ Wix.AppId appId = (Wix.AppId)indexedElements[String.Concat("AppID/", classAppId)];
894
+
895
+ // move the Class element under the AppId (and put the AppId under its old parent)
896
+ if (null != appId)
897
+ {
898
+ // move the AppId element
899
+ ((Wix.IParentElement)appId.ParentElement).RemoveChild(appId);
900
+ ((Wix.IParentElement)element.ParentElement).AddChild(appId);
901
+
902
+ // move the Class element
903
+ ((Wix.IParentElement)element.ParentElement).RemoveChild(element);
904
+ appId.AddChild(element);
905
+ }
906
+ }
907
+ }
908
+ }
909
+
910
+ // remove the RegistryValue elements which were converted into COM elements
911
+ // that were successfully nested under the Component element
912
+ foreach (DictionaryEntry entry in indexedProcessedRegistryValues)
913
+ {
914
+ Wix.ISchemaElement element = (Wix.ISchemaElement)entry.Value;
915
+ Wix.RegistryValue registryValue = (Wix.RegistryValue)entry.Key;
916
+
917
+ while (null != element)
918
+ {
919
+ if (element == component)
920
+ {
921
+ ((Wix.IParentElement)registryValue.ParentElement).RemoveChild(registryValue);
922
+ break;
923
+ }
924
+
925
+ element = element.ParentElement;
926
+ }
927
+ }
928
+ }
929
+ }
930
+
931
+ /// <summary>
932
+ /// Mutate the directories.
933
+ /// </summary>
934
+ private void MutateDirectories()
935
+ {
936
+ foreach (Wix.Directory directory in this.directories)
937
+ {
938
+ string path = directory.FileSource;
939
+
940
+ // create a new directory element without the FileSource attribute
941
+ if (null != path)
942
+ {
943
+ Wix.Directory newDirectory = new Wix.Directory();
944
+
945
+ newDirectory.Id = directory.Id;
946
+ newDirectory.Name = directory.Name;
947
+
948
+ foreach (Wix.ISchemaElement element in directory.Children)
949
+ {
950
+ newDirectory.AddChild(element);
951
+ }
952
+
953
+ ((Wix.IParentElement)directory.ParentElement).AddChild(newDirectory);
954
+ ((Wix.IParentElement)directory.ParentElement).RemoveChild(directory);
955
+
956
+ if (null != newDirectory.Id)
957
+ {
958
+ this.directoryPaths[path.ToLower(CultureInfo.InvariantCulture)] = String.Concat("[", newDirectory.Id, "]");
959
+ }
960
+ }
961
+ }
962
+ }
963
+
964
+ /// <summary>
965
+ /// Mutate the files.
966
+ /// </summary>
967
+ private void MutateFiles()
968
+ {
969
+ string sourceDirSubstitution = this.preprocessorVariable;
970
+ if (sourceDirSubstitution != null)
971
+ {
972
+ string prefix = "$(";
973
+ if (sourceDirSubstitution.StartsWith("wix.", StringComparison.Ordinal))
974
+ {
975
+ prefix = "!(";
976
+ }
977
+ sourceDirSubstitution = String.Concat(prefix, sourceDirSubstitution, ")");
978
+ }
979
+
980
+ foreach (Wix.File file in this.files)
981
+ {
982
+ if (null != file.Id && null != file.Source)
983
+ {
984
+ string fileSource = this.Core.ResolveFilePath(file.Source);
985
+
986
+ // index the long path
987
+ this.filePaths[fileSource.ToLower(CultureInfo.InvariantCulture)] = String.Concat("[#", file.Id, "]");
988
+
989
+ // index the long path as a URL for assembly harvesting
990
+ Uri fileUri = new Uri(fileSource);
991
+ this.filePaths[fileUri.ToString().ToLower(CultureInfo.InvariantCulture)] = String.Concat("file:///[#", file.Id, "]");
992
+
993
+ // index the short path
994
+ string shortPath = NativeMethods.GetShortPathName(fileSource);
995
+ this.filePaths[shortPath.ToLower(CultureInfo.InvariantCulture)] = String.Concat("[!", file.Id, "]");
996
+
997
+ // escape literal $ characters
998
+ file.Source = file.Source.Replace("$", "$$");
999
+
1000
+ if (null != sourceDirSubstitution && file.Source.StartsWith("SourceDir\\", StringComparison.Ordinal))
1001
+ {
1002
+ file.Source = file.Source.Substring(9).Insert(0, sourceDirSubstitution);
1003
+ }
1004
+ }
1005
+ }
1006
+ }
1007
+
1008
+ /// <summary>
1009
+ /// Mutate an individual registry string, according to a collection of replacement items.
1010
+ /// </summary>
1011
+ /// <param name="value">The string to mutate.</param>
1012
+ /// <param name="replace">The collection of items to replace within the string.</param>
1013
+ /// <value>The mutated registry string.</value>
1014
+ private string MutateRegistryString(string value, ICollection replace)
1015
+ {
1016
+ int index;
1017
+ string lowercaseValue = value.ToLower(CultureInfo.InvariantCulture);
1018
+
1019
+ foreach (DictionaryEntry entry in replace)
1020
+ {
1021
+ while (0 <= (index = lowercaseValue.IndexOf((string)entry.Key, StringComparison.Ordinal)))
1022
+ {
1023
+ value = value.Remove(index, ((string)entry.Key).Length);
1024
+ value = value.Insert(index, (string)entry.Value);
1025
+ lowercaseValue = value.ToLower(CultureInfo.InvariantCulture);
1026
+ }
1027
+ }
1028
+
1029
+ return value;
1030
+ }
1031
+
1032
+ /// <summary>
1033
+ /// Mutate the registry values.
1034
+ /// </summary>
1035
+ private void MutateRegistryValues()
1036
+ {
1037
+ if (this.SuppressVB6COMElements && this.SuppressCOMElements)
1038
+ {
1039
+ var vb6RegistryValues = new List<Wix.RegistryValue>();
1040
+ foreach (Wix.RegistryValue registryValue in this.registryValues)
1041
+ {
1042
+ if (IsVb6RegistryValue(registryValue))
1043
+ {
1044
+ if (!vb6RegistryValues.Contains(registryValue))
1045
+ {
1046
+ vb6RegistryValues.Add(registryValue);
1047
+ }
1048
+ }
1049
+ }
1050
+
1051
+ // Remove all the VB6 specific COM registry values
1052
+ foreach (var reg in vb6RegistryValues)
1053
+ {
1054
+ if (reg.ParentElement is Wix.Component component)
1055
+ {
1056
+ component.RemoveChild(reg);
1057
+ }
1058
+ this.registryValues.Remove(reg);
1059
+ }
1060
+ }
1061
+
1062
+
1063
+ ArrayList reversedDirectoryPaths = new ArrayList();
1064
+
1065
+ // reverse the indexed directory paths to ensure the longest paths are found first
1066
+ foreach (DictionaryEntry entry in this.directoryPaths)
1067
+ {
1068
+ reversedDirectoryPaths.Insert(0, entry);
1069
+ }
1070
+
1071
+ foreach (Wix.RegistryValue registryValue in this.registryValues)
1072
+ {
1073
+ // Multi-string values are stored as children - their "Value" member is null
1074
+ if (Wix.RegistryValue.TypeType.multiString == registryValue.Type)
1075
+ {
1076
+ foreach (Wix.MultiStringValue multiStringValue in registryValue.Children)
1077
+ {
1078
+ // first replace file paths with their MSI tokens
1079
+ multiStringValue.Content = this.MutateRegistryString(multiStringValue.Content, (ICollection)this.filePaths);
1080
+ // next replace directory paths with their MSI tokens
1081
+ multiStringValue.Content = this.MutateRegistryString(multiStringValue.Content, (ICollection)reversedDirectoryPaths);
1082
+ }
1083
+ }
1084
+ else
1085
+ {
1086
+ // first replace file paths with their MSI tokens
1087
+ registryValue.Value = this.MutateRegistryString(registryValue.Value, (ICollection)this.filePaths);
1088
+ // next replace directory paths with their MSI tokens
1089
+ registryValue.Value = this.MutateRegistryString(registryValue.Value, (ICollection)reversedDirectoryPaths);
1090
+ }
1091
+ }
1092
+ }
1093
+
1094
+ private static bool IsVb6RegistryValue(Wix.RegistryValue registryValue)
1095
+ {
1096
+ if (Wix.RegistryValue.ActionType.write == registryValue.Action && Wix.RegistryRootType.HKCR == registryValue.Root)
1097
+ {
1098
+ string[] parts = registryValue.Key.Split('\\');
1099
+ if (String.Equals(parts[0], "CLSID", StringComparison.OrdinalIgnoreCase))
1100
+ {
1101
+ // Search for the VB6 CLSID {D5DE8D20-5BB8-11D1-A1E3-00A0C90F2731}
1102
+ if (2 <= parts.Length)
1103
+ {
1104
+ if (String.Equals(parts[1], "{D5DE8D20-5BB8-11D1-A1E3-00A0C90F2731}", StringComparison.OrdinalIgnoreCase))
1105
+ {
1106
+ return true;
1107
+ }
1108
+ }
1109
+ }
1110
+ else if (String.Equals(parts[0], "TypeLib", StringComparison.OrdinalIgnoreCase))
1111
+ {
1112
+ // Search for the VB6 TypeLibs {EA544A21-C82D-11D1-A3E4-00A0C90AEA82} or {000204EF-0000-0000-C000-000000000046}
1113
+ if (2 <= parts.Length)
1114
+ {
1115
+ if (String.Equals(parts[1], "{EA544A21-C82D-11D1-A3E4-00A0C90AEA82}", StringComparison.OrdinalIgnoreCase) ||
1116
+ String.Equals(parts[1], "{000204EF-0000-0000-C000-000000000046}", StringComparison.OrdinalIgnoreCase))
1117
+ {
1118
+ return true;
1119
+ }
1120
+ }
1121
+ }
1122
+ else if (String.Equals(parts[0], "Interface", StringComparison.OrdinalIgnoreCase))
1123
+ {
1124
+ // Search for any Interfaces that reference the VB6 TypeLibs {EA544A21-C82D-11D1-A3E4-00A0C90AEA82} or {000204EF-0000-0000-C000-000000000046}
1125
+ if (3 <= parts.Length)
1126
+ {
1127
+ if (String.Equals(parts[2], "TypeLib", StringComparison.OrdinalIgnoreCase))
1128
+ {
1129
+ if (String.Equals(registryValue.Value, "{EA544A21-C82D-11D1-A3E4-00A0C90AEA82}", StringComparison.OrdinalIgnoreCase) ||
1130
+ String.Equals(registryValue.Value, "{000204EF-0000-0000-C000-000000000046}", StringComparison.OrdinalIgnoreCase))
1131
+ {
1132
+ return true;
1133
+ }
1134
+ }
1135
+ }
1136
+ }
1137
+ }
1138
+ return false;
1139
+ }
1140
+
1141
+ /// <summary>
1142
+ /// The native methods for grabbing machine-specific short file paths.
1143
+ /// </summary>
1144
+ private class NativeMethods
1145
+ {
1146
+ /// <summary>
1147
+ /// Gets the short name for a file.
1148
+ /// </summary>
1149
+ /// <param name="fullPath">Fullpath to file on disk.</param>
1150
+ /// <returns>Short name for file.</returns>
1151
+ internal static string GetShortPathName(string fullPath)
1152
+ {
1153
+ var bufferSize = (int)GetShortPathName(fullPath, null, 0);
1154
+ if (0 == bufferSize)
1155
+ {
1156
+ int err = System.Runtime.InteropServices.Marshal.GetLastWin32Error();
1157
+ throw new System.Runtime.InteropServices.COMException(String.Concat("Failed to get short path buffer size for file: ", fullPath), err);
1158
+ }
1159
+
1160
+ bufferSize += 1;
1161
+ var shortPath = new StringBuilder(bufferSize, bufferSize);
1162
+
1163
+ uint result = GetShortPathName(fullPath, shortPath, bufferSize);
1164
+
1165
+ if (0 == result)
1166
+ {
1167
+ int err = System.Runtime.InteropServices.Marshal.GetLastWin32Error();
1168
+ throw new System.Runtime.InteropServices.COMException(String.Concat("Failed to get short path name for file: ", fullPath), err);
1169
+ }
1170
+
1171
+ return shortPath.ToString();
1172
+ }
1173
+
1174
+ /// <summary>
1175
+ /// Gets the short name for a file.
1176
+ /// </summary>
1177
+ /// <param name="longPath">Long path to convert to short path.</param>
1178
+ /// <param name="shortPath">Short path from long path.</param>
1179
+ /// <param name="buffer">Size of short path.</param>
1180
+ /// <returns>zero if success.</returns>
1181
+ [DllImport("kernel32.dll", EntryPoint = "GetShortPathNameW", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
1182
+ internal static extern uint GetShortPathName(string longPath, StringBuilder shortPath, [MarshalAs(UnmanagedType.U4)]int buffer);
1183
+ }
1184
+ }
1185
+}
src/heat/UtilHarvesterMutator.cs
new
+218
@@ -0,0 +1,218 @@
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.Harvesters
4
+{
5
+ using System;
6
+ using System.Collections;
7
+ using System.IO;
8
+ using System.Reflection;
9
+ using System.Runtime.InteropServices;
10
+ using WixToolset.Data;
11
+ using WixToolset.Harvesters.Data;
12
+ using WixToolset.Harvesters.Extensibility;
13
+ using Wix = WixToolset.Harvesters.Serialize;
14
+
15
+ /// <summary>
16
+ /// The WiX Toolset harvester mutator.
17
+ /// </summary>
18
+ internal class UtilHarvesterMutator : BaseMutatorExtension
19
+ {
20
+ // Flags for SetErrorMode() native method.
21
+ private const UInt32 SEM_FAILCRITICALERRORS = 0x0001;
22
+ private const UInt32 SEM_NOGPFAULTERRORBOX = 0x0002;
23
+ private const UInt32 SEM_NOALIGNMENTFAULTEXCEPT = 0x0004;
24
+ private const UInt32 SEM_NOOPENFILEERRORBOX = 0x8000;
25
+
26
+ // Remember whether we were able to call OaEnablePerUserTLibRegistration
27
+ private bool calledPerUserTLibReg;
28
+
29
+ /// <summary>
30
+ /// allow process to handle serious system errors.
31
+ /// </summary>
32
+ [DllImport("Kernel32.dll")]
33
+ private static extern void SetErrorMode(UInt32 uiMode);
34
+
35
+ /// <summary>
36
+ /// enable the RegisterTypeLib API to use the appropriate override mapping for non-admin users on Vista
37
+ /// </summary>
38
+ [DllImport("Oleaut32.dll")]
39
+ private static extern void OaEnablePerUserTLibRegistration();
40
+
41
+ public UtilHarvesterMutator()
42
+ {
43
+ this.calledPerUserTLibReg = false;
44
+
45
+ SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);
46
+
47
+ try
48
+ {
49
+ OaEnablePerUserTLibRegistration();
50
+ this.calledPerUserTLibReg = true;
51
+ }
52
+ catch (EntryPointNotFoundException)
53
+ {
54
+ }
55
+ }
56
+
57
+ /// <summary>
58
+ /// Gets the sequence of this mutator extension.
59
+ /// </summary>
60
+ /// <value>The sequence of this mutator extension.</value>
61
+ public override int Sequence
62
+ {
63
+ get { return 100; }
64
+ }
65
+
66
+ /// <summary>
67
+ /// Mutate a WiX document.
68
+ /// </summary>
69
+ /// <param name="wix">The Wix document element.</param>
70
+ public override void Mutate(Wix.Wix wix)
71
+ {
72
+ this.MutateElement(null, wix);
73
+ }
74
+
75
+ /// <summary>
76
+ /// Mutate an element.
77
+ /// </summary>
78
+ /// <param name="parentElement">The parent of the element to mutate.</param>
79
+ /// <param name="element">The element to mutate.</param>
80
+ private void MutateElement(Wix.IParentElement parentElement, Wix.ISchemaElement element)
81
+ {
82
+ if (element is Wix.File)
83
+ {
84
+ this.MutateFile(parentElement, (Wix.File)element);
85
+ }
86
+
87
+ // mutate the child elements
88
+ if (element is Wix.IParentElement)
89
+ {
90
+ ArrayList childElements = new ArrayList();
91
+
92
+ // copy the child elements to a temporary array (to allow them to be deleted/moved)
93
+ foreach (Wix.ISchemaElement childElement in ((Wix.IParentElement)element).Children)
94
+ {
95
+ childElements.Add(childElement);
96
+ }
97
+
98
+ foreach (Wix.ISchemaElement childElement in childElements)
99
+ {
100
+ this.MutateElement((Wix.IParentElement)element, childElement);
101
+ }
102
+ }
103
+ }
104
+
105
+ /// <summary>
106
+ /// Mutate a file.
107
+ /// </summary>
108
+ /// <param name="parentElement">The parent of the element to mutate.</param>
109
+ /// <param name="file">The file to mutate.</param>
110
+ private void MutateFile(Wix.IParentElement parentElement, Wix.File file)
111
+ {
112
+ if (null != file.Source)
113
+ {
114
+ string fileExtension = Path.GetExtension(file.Source);
115
+ string fileSource = this.Core.ResolveFilePath(file.Source);
116
+
117
+ if (String.Equals(".ax", fileExtension, StringComparison.OrdinalIgnoreCase) || // DirectShow filter
118
+ String.Equals(".dll", fileExtension, StringComparison.OrdinalIgnoreCase) ||
119
+ String.Equals(".exe", fileExtension, StringComparison.OrdinalIgnoreCase) ||
120
+ String.Equals(".ocx", fileExtension, StringComparison.OrdinalIgnoreCase)) // ActiveX
121
+ {
122
+ // try the assembly harvester
123
+ try
124
+ {
125
+ AssemblyHarvester assemblyHarvester = new AssemblyHarvester();
126
+
127
+ this.Core.Messaging.Write(HarvesterVerboses.HarvestingAssembly(fileSource));
128
+ Wix.RegistryValue[] registryValues = assemblyHarvester.HarvestRegistryValues(fileSource);
129
+
130
+ foreach (Wix.RegistryValue registryValue in registryValues)
131
+ {
132
+ parentElement.AddChild(registryValue);
133
+ }
134
+
135
+ // also try self-reg since we could have a mixed-mode assembly
136
+ this.HarvestSelfReg(parentElement, fileSource);
137
+ }
138
+ catch (BadImageFormatException) // not an assembly, try raw DLL.
139
+ {
140
+ this.HarvestSelfReg(parentElement, fileSource);
141
+ }
142
+ catch (Exception ex)
143
+ {
144
+ this.Core.Messaging.Write(HarvesterWarnings.AssemblyHarvestFailed(fileSource, ex.Message));
145
+ }
146
+ }
147
+ else if (String.Equals(".olb", fileExtension, StringComparison.OrdinalIgnoreCase) || // type library
148
+ String.Equals(".tlb", fileExtension, StringComparison.OrdinalIgnoreCase)) // type library
149
+ {
150
+ // try the type library harvester
151
+ try
152
+ {
153
+ TypeLibraryHarvester typeLibHarvester = new TypeLibraryHarvester();
154
+
155
+ this.Core.Messaging.Write(HarvesterVerboses.HarvestingTypeLib(fileSource));
156
+ Wix.RegistryValue[] registryValues = typeLibHarvester.HarvestRegistryValues(fileSource);
157
+
158
+ foreach (Wix.RegistryValue registryValue in registryValues)
159
+ {
160
+ parentElement.AddChild(registryValue);
161
+ }
162
+ }
163
+ catch (COMException ce)
164
+ {
165
+ // 0x8002801C (TYPE_E_REGISTRYACCESS)
166
+ // If we don't have permission to harvest typelibs, it's likely because we're on
167
+ // Vista or higher and aren't an Admin, or don't have the appropriate QFE installed.
168
+ if (!this.calledPerUserTLibReg && (0x8002801c == unchecked((uint)ce.ErrorCode)))
169
+ {
170
+ this.Core.Messaging.Write(WarningMessages.InsufficientPermissionHarvestTypeLib());
171
+ }
172
+ else if (0x80029C4A == unchecked((uint)ce.ErrorCode)) // generic can't load type library
173
+ {
174
+ this.Core.Messaging.Write(HarvesterWarnings.TypeLibLoadFailed(fileSource, ce.Message));
175
+ }
176
+ }
177
+ }
178
+ }
179
+ }
180
+
181
+ /// <summary>
182
+ /// Calls self-reg harvester.
183
+ /// </summary>
184
+ /// <param name="parentElement">The parent element.</param>
185
+ /// <param name="fileSource">The file source.</param>
186
+ private void HarvestSelfReg(Wix.IParentElement parentElement, string fileSource)
187
+ {
188
+ // try the self-reg harvester
189
+ try
190
+ {
191
+ DllHarvester dllHarvester = new DllHarvester();
192
+
193
+ this.Core.Messaging.Write(HarvesterVerboses.HarvestingSelfReg(fileSource));
194
+ Wix.RegistryValue[] registryValues = dllHarvester.HarvestRegistryValues(fileSource);
195
+
196
+ foreach (Wix.RegistryValue registryValue in registryValues)
197
+ {
198
+ parentElement.AddChild(registryValue);
199
+ }
200
+ }
201
+ catch (TargetInvocationException tie)
202
+ {
203
+ if (tie.InnerException is EntryPointNotFoundException)
204
+ {
205
+ // No DllRegisterServer(), which is fine by me.
206
+ }
207
+ else
208
+ {
209
+ this.Core.Messaging.Write(HarvesterWarnings.SelfRegHarvestFailed(fileSource, tie.Message));
210
+ }
211
+ }
212
+ catch (Exception ex)
213
+ {
214
+ this.Core.Messaging.Write(HarvesterWarnings.SelfRegHarvestFailed(fileSource, ex.Message));
215
+ }
216
+ }
217
+ }
218
+}
src/heat/UtilHeatExtension.cs
new
+405
@@ -0,0 +1,405 @@
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.Harvesters
4
+{
5
+ using System;
6
+ using System.Collections.Generic;
7
+ using System.IO;
8
+ using WixToolset.Core.Burn.Interfaces;
9
+ using WixToolset.Data;
10
+ using WixToolset.Data.Symbols;
11
+ using WixToolset.Extensibility.Services;
12
+ using WixToolset.Harvesters.Data;
13
+ using WixToolset.Harvesters.Extensibility;
14
+
15
+ /// <summary>
16
+ /// A utility heat extension for the WiX Toolset Harvester application.
17
+ /// </summary>
18
+ internal class UtilHeatExtension : BaseHeatExtension
19
+ {
20
+ public UtilHeatExtension(IServiceProvider serviceProvider)
21
+ {
22
+ this.PayloadHarvester = serviceProvider.GetService<IPayloadHarvester>();
23
+ }
24
+
25
+ private IPayloadHarvester PayloadHarvester { get; }
26
+
27
+ /// <summary>
28
+ /// Gets the supported command line types for this extension.
29
+ /// </summary>
30
+ /// <value>The supported command line types for this extension.</value>
31
+ public override HeatCommandLineOption[] CommandLineTypes
32
+ {
33
+ get
34
+ {
35
+ return new HeatCommandLineOption[]
36
+ {
37
+ new HeatCommandLineOption("dir", "harvest a directory"),
38
+ new HeatCommandLineOption("file", "harvest a file"),
39
+ new HeatCommandLineOption("exepackagepayload", "harvest a bundle payload as ExePackagePayload"),
40
+ new HeatCommandLineOption("msupackagepayload", "harvest a bundle payload as MsuPackagePayload"),
41
+ new HeatCommandLineOption("perf", "harvest performance counters"),
42
+ new HeatCommandLineOption("reg", "harvest a .reg file"),
43
+ new HeatCommandLineOption("-ag", "autogenerate component guids at compile time"),
44
+ new HeatCommandLineOption("-cg <ComponentGroupName>", "component group name (cannot contain spaces e.g -cg MyComponentGroup)"),
45
+ new HeatCommandLineOption("-dr <DirectoryName>", "directory reference to root directories (cannot contain spaces e.g. -dr MyAppDirRef)"),
46
+ new HeatCommandLineOption("-var <VariableName>", "substitute File/@Source=\"SourceDir\" with a preprocessor or a wix variable" + Environment.NewLine +
47
+ "(e.g. -var var.MySource will become File/@Source=\"$(var.MySource)\\myfile.txt\" and " + Environment.NewLine +
48
+ "-var wix.MySource will become File/@Source=\"!(wix.MySource)\\myfile.txt\""),
49
+ new HeatCommandLineOption("-gg", "generate guids now"),
50
+ new HeatCommandLineOption("-g1", "generated guids are not in brackets"),
51
+ new HeatCommandLineOption("-ke", "keep empty directories"),
52
+ new HeatCommandLineOption("-scom", "suppress COM elements"),
53
+ new HeatCommandLineOption("-sfrag", "suppress fragments"),
54
+ new HeatCommandLineOption("-srd", "suppress harvesting the root directory as an element"),
55
+ new HeatCommandLineOption("-svb6", "suppress VB6 COM elements"),
56
+ new HeatCommandLineOption("-sreg", "suppress registry harvesting"),
57
+ new HeatCommandLineOption("-suid", "suppress unique identifiers for files, components, & directories"),
58
+ new HeatCommandLineOption("-t", "transform harvested output with XSL file"),
59
+ new HeatCommandLineOption("-template", "use template, one of: fragment,module,product"),
60
+ };
61
+ }
62
+ }
63
+
64
+ /// <summary>
65
+ /// Parse the command line options for this extension.
66
+ /// </summary>
67
+ /// <param name="type">The active harvester type.</param>
68
+ /// <param name="args">The option arguments.</param>
69
+ public override void ParseOptions(string type, string[] args)
70
+ {
71
+ bool active = false;
72
+ IHarvesterExtension harvesterExtension = null;
73
+ bool suppressHarvestingRegistryValues = false;
74
+ UtilFinalizeHarvesterMutator utilFinalizeHarvesterMutator = new UtilFinalizeHarvesterMutator();
75
+ UtilMutator utilMutator = new UtilMutator();
76
+ List<UtilTransformMutator> transformMutators = new List<UtilTransformMutator>();
77
+ GenerateType generateType = GenerateType.Components;
78
+
79
+ // select the harvester
80
+ switch (type)
81
+ {
82
+ case "dir":
83
+ harvesterExtension = new DirectoryHarvester();
84
+ active = true;
85
+ break;
86
+ case "file":
87
+ harvesterExtension = new FileHarvester();
88
+ active = true;
89
+ break;
90
+ case "exepackagepayload":
91
+ harvesterExtension = new PayloadHarvester(this.PayloadHarvester, WixBundlePackageType.Exe);
92
+ active = true;
93
+ break;
94
+ case "msupackagepayload":
95
+ harvesterExtension = new PayloadHarvester(this.PayloadHarvester, WixBundlePackageType.Msu);
96
+ active = true;
97
+ break;
98
+ case "perf":
99
+ harvesterExtension = new PerformanceCategoryHarvester();
100
+ active = true;
101
+ break;
102
+ case "reg":
103
+ harvesterExtension = new RegFileHarvester();
104
+ active = true;
105
+ break;
106
+ }
107
+
108
+ // set default settings
109
+ utilMutator.CreateFragments = true;
110
+ utilMutator.SetUniqueIdentifiers = true;
111
+
112
+ // parse the options
113
+ for (int i = 0; i < args.Length; i++)
114
+ {
115
+ string commandSwitch = args[i];
116
+
117
+ if (null == commandSwitch || 0 == commandSwitch.Length) // skip blank arguments
118
+ {
119
+ continue;
120
+ }
121
+
122
+ if ('-' == commandSwitch[0] || '/' == commandSwitch[0])
123
+ {
124
+ string truncatedCommandSwitch = commandSwitch.Substring(1);
125
+
126
+ if ("ag" == truncatedCommandSwitch)
127
+ {
128
+ utilMutator.AutogenerateGuids = true;
129
+ }
130
+ else if ("cg" == truncatedCommandSwitch)
131
+ {
132
+ utilMutator.ComponentGroupName = this.GetArgumentParameter(args, i);
133
+
134
+ if (this.Core.Messaging.EncounteredError)
135
+ {
136
+ return;
137
+ }
138
+ }
139
+ else if ("dr" == truncatedCommandSwitch)
140
+ {
141
+ string dr = this.GetArgumentParameter(args, i);
142
+
143
+ if (this.Core.Messaging.EncounteredError)
144
+ {
145
+ return;
146
+ }
147
+
148
+ if (harvesterExtension is DirectoryHarvester)
149
+ {
150
+ ((DirectoryHarvester)harvesterExtension).RootedDirectoryRef = dr;
151
+ }
152
+ else if (harvesterExtension is FileHarvester)
153
+ {
154
+ ((FileHarvester)harvesterExtension).RootedDirectoryRef = dr;
155
+ }
156
+ }
157
+ else if ("gg" == truncatedCommandSwitch)
158
+ {
159
+ utilMutator.GenerateGuids = true;
160
+ }
161
+ else if ("g1" == truncatedCommandSwitch)
162
+ {
163
+ utilMutator.GuidFormat = "D";
164
+ }
165
+ else if ("ke" == truncatedCommandSwitch)
166
+ {
167
+ if (harvesterExtension is DirectoryHarvester)
168
+ {
169
+ ((DirectoryHarvester)harvesterExtension).KeepEmptyDirectories = true;
170
+ }
171
+ else if (active)
172
+ {
173
+ // TODO: error message - not applicable to file harvester
174
+ }
175
+ }
176
+ else if ("scom" == truncatedCommandSwitch)
177
+ {
178
+ if (active)
179
+ {
180
+ utilFinalizeHarvesterMutator.SuppressCOMElements = true;
181
+ }
182
+ else
183
+ {
184
+ // TODO: error message - not applicable
185
+ }
186
+ }
187
+ else if ("svb6" == truncatedCommandSwitch)
188
+ {
189
+ if (active)
190
+ {
191
+ utilFinalizeHarvesterMutator.SuppressVB6COMElements = true;
192
+ }
193
+ else
194
+ {
195
+ // TODO: error message - not applicable
196
+ }
197
+ }
198
+ else if ("sfrag" == truncatedCommandSwitch)
199
+ {
200
+ utilMutator.CreateFragments = false;
201
+ }
202
+ else if ("srd" == truncatedCommandSwitch)
203
+ {
204
+ if (harvesterExtension is DirectoryHarvester)
205
+ {
206
+ ((DirectoryHarvester)harvesterExtension).SuppressRootDirectory = true;
207
+ }
208
+ else if (harvesterExtension is FileHarvester)
209
+ {
210
+ ((FileHarvester)harvesterExtension).SuppressRootDirectory = true;
211
+ }
212
+ }
213
+ else if ("sreg" == truncatedCommandSwitch)
214
+ {
215
+ suppressHarvestingRegistryValues = true;
216
+ }
217
+ else if ("suid" == truncatedCommandSwitch)
218
+ {
219
+ utilMutator.SetUniqueIdentifiers = false;
220
+
221
+ if (harvesterExtension is DirectoryHarvester)
222
+ {
223
+ ((DirectoryHarvester)harvesterExtension).SetUniqueIdentifiers = false;
224
+ }
225
+ else if (harvesterExtension is FileHarvester)
226
+ {
227
+ ((FileHarvester)harvesterExtension).SetUniqueIdentifiers = false;
228
+ }
229
+ }
230
+ else if (truncatedCommandSwitch.StartsWith("t:", StringComparison.Ordinal) || "t" == truncatedCommandSwitch)
231
+ {
232
+ string xslFile;
233
+ if (truncatedCommandSwitch.StartsWith("t:", StringComparison.Ordinal))
234
+ {
235
+ this.Core.Messaging.Write(WarningMessages.DeprecatedCommandLineSwitch("t:", "t"));
236
+ xslFile = truncatedCommandSwitch.Substring(2);
237
+ }
238
+ else
239
+ {
240
+ xslFile = this.GetArgumentParameter(args, i, true);
241
+ }
242
+
243
+ if (0 <= xslFile.IndexOf('\"'))
244
+ {
245
+ this.Core.Messaging.Write(ErrorMessages.PathCannotContainQuote(xslFile));
246
+ return;
247
+ }
248
+
249
+ try
250
+ {
251
+ xslFile = Path.GetFullPath(xslFile);
252
+ }
253
+ catch (Exception e)
254
+ {
255
+ this.Core.Messaging.Write(ErrorMessages.InvalidCommandLineFileName(xslFile, e.Message));
256
+ return;
257
+ }
258
+
259
+ transformMutators.Add(new UtilTransformMutator(xslFile, transformMutators.Count));
260
+ }
261
+ else if (truncatedCommandSwitch.StartsWith("template:", StringComparison.Ordinal) || "template" == truncatedCommandSwitch)
262
+ {
263
+ string template;
264
+ if(truncatedCommandSwitch.StartsWith("template:", StringComparison.Ordinal))
265
+ {
266
+ this.Core.Messaging.Write(WarningMessages.DeprecatedCommandLineSwitch("template:", "template"));
267
+ template = truncatedCommandSwitch.Substring(9);
268
+ }
269
+ else
270
+ {
271
+ template = this.GetArgumentParameter(args, i);
272
+ }
273
+
274
+ switch (template)
275
+ {
276
+ case "fragment":
277
+ utilMutator.TemplateType = TemplateType.Fragment;
278
+ break;
279
+ case "module":
280
+ utilMutator.TemplateType = TemplateType.Module;
281
+ break;
282
+ case "product":
283
+ utilMutator.TemplateType = TemplateType.Package ;
284
+ break;
285
+ default:
286
+ // TODO: error
287
+ break;
288
+ }
289
+ }
290
+ else if ("var" == truncatedCommandSwitch)
291
+ {
292
+ if (active)
293
+ {
294
+ utilFinalizeHarvesterMutator.PreprocessorVariable = this.GetArgumentParameter(args, i);
295
+
296
+ if (this.Core.Messaging.EncounteredError)
297
+ {
298
+ return;
299
+ }
300
+ }
301
+ }
302
+ else if ("generate" == truncatedCommandSwitch)
303
+ {
304
+ if (harvesterExtension is DirectoryHarvester)
305
+ {
306
+ string genType = this.GetArgumentParameter(args, i).ToUpperInvariant();
307
+ switch (genType)
308
+ {
309
+ case "COMPONENTS":
310
+ generateType = GenerateType.Components;
311
+ break;
312
+ case "PAYLOADGROUP":
313
+ generateType = GenerateType.PayloadGroup;
314
+ break;
315
+ default:
316
+ throw new WixException(HarvesterErrors.InvalidDirectoryOutputType(genType));
317
+ }
318
+ }
319
+ else
320
+ {
321
+ // TODO: error message - not applicable
322
+ }
323
+ }
324
+ }
325
+ }
326
+
327
+ // set the appropriate harvester extension
328
+ if (active)
329
+ {
330
+ this.Core.Harvester.Extension = harvesterExtension;
331
+
332
+ if (!suppressHarvestingRegistryValues)
333
+ {
334
+ this.Core.Mutator.AddExtension(new UtilHarvesterMutator());
335
+ }
336
+
337
+ this.Core.Mutator.AddExtension(utilFinalizeHarvesterMutator);
338
+
339
+ if (harvesterExtension is DirectoryHarvester directoryHarvester)
340
+ {
341
+ directoryHarvester.GenerateType = generateType;
342
+ this.Core.Harvester.Core.RootDirectory = this.Core.Harvester.Core.ExtensionArgument;
343
+ }
344
+ else if (harvesterExtension is FileHarvester)
345
+ {
346
+ if (((FileHarvester)harvesterExtension).SuppressRootDirectory)
347
+ {
348
+ this.Core.Harvester.Core.RootDirectory = Path.GetDirectoryName(Path.GetFullPath(this.Core.Harvester.Core.ExtensionArgument));
349
+ }
350
+ else
351
+ {
352
+ this.Core.Harvester.Core.RootDirectory = Path.GetDirectoryName(Path.GetDirectoryName(Path.GetFullPath(this.Core.Harvester.Core.ExtensionArgument)));
353
+
354
+ // GetDirectoryName() returns null for root paths such as "c:\", so make sure to support that as well
355
+ if (null == this.Core.Harvester.Core.RootDirectory)
356
+ {
357
+ this.Core.Harvester.Core.RootDirectory = Path.GetPathRoot(Path.GetDirectoryName(Path.GetFullPath(this.Core.Harvester.Core.ExtensionArgument)));
358
+ }
359
+ }
360
+ }
361
+ }
362
+
363
+ // set the mutator
364
+ this.Core.Mutator.AddExtension(utilMutator);
365
+
366
+ // add the transforms
367
+ foreach (UtilTransformMutator transformMutator in transformMutators)
368
+ {
369
+ this.Core.Mutator.AddExtension(transformMutator);
370
+ }
371
+ }
372
+
373
+ private string GetArgumentParameter(string[] args, int index)
374
+ {
375
+ return this.GetArgumentParameter(args, index, false);
376
+ }
377
+
378
+ private string GetArgumentParameter(string[] args, int index, bool allowSpaces)
379
+ {
380
+ string truncatedCommandSwitch = args[index];
381
+ string commandSwitchValue = args[index + 1];
382
+
383
+ //increment the index to the switch value
384
+ index++;
385
+
386
+ if (IsValidArg(args, index) && !String.IsNullOrEmpty(commandSwitchValue.Trim()))
387
+ {
388
+ if (!allowSpaces && commandSwitchValue.Contains(" "))
389
+ {
390
+ this.Core.Messaging.Write(HarvesterErrors.SpacesNotAllowedInArgumentValue(truncatedCommandSwitch, commandSwitchValue));
391
+ }
392
+ else
393
+ {
394
+ return commandSwitchValue;
395
+ }
396
+ }
397
+ else
398
+ {
399
+ this.Core.Messaging.Write(HarvesterErrors.ArgumentRequiresValue(truncatedCommandSwitch));
400
+ }
401
+
402
+ return null;
403
+ }
404
+ }
405
+}
src/heat/UtilMutator.cs
new
+633
@@ -0,0 +1,633 @@
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.Harvesters
4
+{
5
+ using System;
6
+ using System.Collections;
7
+ using System.Diagnostics;
8
+ using System.Globalization;
9
+ using System.IO;
10
+ using WixToolset.Harvesters.Extensibility;
11
+ using Wix = WixToolset.Harvesters.Serialize;
12
+
13
+ /// <summary>
14
+ /// The template type.
15
+ /// </summary>
16
+ internal enum TemplateType
17
+ {
18
+ /// <summary>
19
+ /// A fragment template.
20
+ /// </summary>
21
+ Fragment,
22
+
23
+ /// <summary>
24
+ /// A module template.
25
+ /// </summary>
26
+ Module,
27
+
28
+ /// <summary>
29
+ /// A product template.
30
+ /// </summary>
31
+ Package
32
+ }
33
+
34
+ /// <summary>
35
+ /// The mutator for the WiX Toolset Internet Information Services Extension.
36
+ /// </summary>
37
+ internal class UtilMutator : BaseMutatorExtension
38
+ {
39
+ private ArrayList components;
40
+ private ArrayList componentGroups;
41
+ private string componentGroupName;
42
+ private bool createFragments;
43
+ private ArrayList directories;
44
+ private ArrayList directoryRefs;
45
+ private ArrayList files;
46
+ private ArrayList features;
47
+ private SortedList fragments;
48
+ private bool autogenerateGuids;
49
+ private bool generateGuids;
50
+ private string guidFormat = "B"; // Defaults to guid in {}
51
+ private Wix.IParentElement rootElement;
52
+ private bool setUniqueIdentifiers;
53
+ private TemplateType templateType;
54
+
55
+ /// <summary>
56
+ /// Instantiate a new UtilMutator.
57
+ /// </summary>
58
+ public UtilMutator()
59
+ {
60
+ this.components = new ArrayList();
61
+ this.componentGroups = new ArrayList();
62
+ this.directories = new ArrayList();
63
+ this.directoryRefs = new ArrayList();
64
+ this.features = new ArrayList();
65
+ this.files = new ArrayList();
66
+ this.fragments = new SortedList();
67
+ }
68
+
69
+ /// <summary>
70
+ /// Gets or sets the value of the component group name.
71
+ /// </summary>
72
+ /// <value>The component group name.</value>
73
+ public string ComponentGroupName
74
+ {
75
+ get { return this.componentGroupName; }
76
+ set { this.componentGroupName = value; }
77
+ }
78
+
79
+ /// <summary>
80
+ /// Gets or sets the option to create fragments.
81
+ /// </summary>
82
+ /// <value>The option to create fragments.</value>
83
+ public bool CreateFragments
84
+ {
85
+ get { return this.createFragments; }
86
+ set { this.createFragments = value; }
87
+ }
88
+
89
+ /// <summary>
90
+ /// Gets or sets the option to autogenerate component guids at compile time.
91
+ /// </summary>
92
+ /// <value>The option to autogenerate component guids.</value>
93
+ public bool AutogenerateGuids
94
+ {
95
+ get { return this.autogenerateGuids; }
96
+ set { this.autogenerateGuids = value; }
97
+ }
98
+
99
+ /// <summary>
100
+ /// Gets or sets the option to generate missing guids.
101
+ /// </summary>
102
+ /// <value>The option to generate missing guids.</value>
103
+ public bool GenerateGuids
104
+ {
105
+ get { return this.generateGuids; }
106
+ set { this.generateGuids = value; }
107
+ }
108
+
109
+ /// <summary>
110
+ /// Gets or sets the option to set the format of guids.
111
+ /// D - 32 digits separated by hyphens:
112
+ /// xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
113
+ /// B - 32 digits separated by hyphens, enclosed in brackets:
114
+ /// {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
115
+ /// </summary>
116
+ /// <value>Guid format either B or D.</value>
117
+ public string GuidFormat
118
+ {
119
+ get { return this.guidFormat; }
120
+ set { this.guidFormat = value; }
121
+ }
122
+
123
+ /// <summary>
124
+ /// Gets the sequence of the extension.
125
+ /// </summary>
126
+ /// <value>The sequence of the extension.</value>
127
+ public override int Sequence
128
+ {
129
+ get { return 1000; }
130
+ }
131
+
132
+ /// <summary>
133
+ /// Gets of sets the option to set unique identifiers.
134
+ /// </summary>
135
+ /// <value>The option to set unique identifiers.</value>
136
+ public bool SetUniqueIdentifiers
137
+ {
138
+ get { return this.setUniqueIdentifiers; }
139
+ set { this.setUniqueIdentifiers = value; }
140
+ }
141
+
142
+ /// <summary>
143
+ /// Gets or sets the template type.
144
+ /// </summary>
145
+ /// <value>The template type.</value>
146
+ public TemplateType TemplateType
147
+ {
148
+ get { return this.templateType; }
149
+ set { this.templateType = value; }
150
+ }
151
+
152
+ /// <summary>
153
+ /// Mutate a WiX document.
154
+ /// </summary>
155
+ /// <param name="wix">The Wix document element.</param>
156
+ public override void Mutate(Wix.Wix wix)
157
+ {
158
+ this.components.Clear();
159
+ this.directories.Clear();
160
+ this.directoryRefs.Clear();
161
+ this.features.Clear();
162
+ this.files.Clear();
163
+ this.fragments.Clear();
164
+ this.rootElement = null;
165
+
166
+ // index elements in this wix document
167
+ this.IndexElement(wix);
168
+
169
+ this.MutateWix(wix);
170
+
171
+ this.MutateFiles();
172
+
173
+ this.MutateDirectories();
174
+
175
+ this.MutateComponents();
176
+
177
+ if (null != this.componentGroupName)
178
+ {
179
+ this.CreateComponentGroup(wix);
180
+ }
181
+
182
+ // add the components to the product feature after all the identifiers have been set
183
+ if (TemplateType.Package == this.templateType)
184
+ {
185
+ Wix.Feature feature = (Wix.Feature)this.features[0];
186
+
187
+ foreach (Wix.ComponentGroup group in this.componentGroups)
188
+ {
189
+ Wix.ComponentGroupRef componentGroupRef = new Wix.ComponentGroupRef();
190
+ componentGroupRef.Id = group.Id;
191
+
192
+ feature.AddChild(componentGroupRef);
193
+ }
194
+ }
195
+ else if (TemplateType.Module == this.templateType)
196
+ {
197
+ foreach (Wix.ISchemaElement element in wix.Children)
198
+ {
199
+ if (element is Wix.Module)
200
+ {
201
+ foreach (Wix.ComponentGroup group in this.componentGroups)
202
+ {
203
+ Wix.ComponentGroupRef componentGroupRef = new Wix.ComponentGroupRef();
204
+ componentGroupRef.Id = group.Id;
205
+
206
+ ((Wix.IParentElement)element).AddChild(componentGroupRef);
207
+ }
208
+ break;
209
+ }
210
+ }
211
+ }
212
+
213
+ //if(!this.createFragments && TemplateType.Package
214
+ foreach (Wix.Fragment fragment in this.fragments.Values)
215
+ {
216
+ wix.AddChild(fragment);
217
+ }
218
+ }
219
+
220
+ /// <summary>
221
+ /// Creates a component group with a given name.
222
+ /// </summary>
223
+ /// <param name="wix">The Wix document element.</param>
224
+ private void CreateComponentGroup(Wix.Wix wix)
225
+ {
226
+ Wix.ComponentGroup componentGroup = new Wix.ComponentGroup();
227
+ componentGroup.Id = this.componentGroupName;
228
+ this.componentGroups.Add(componentGroup);
229
+
230
+ Wix.Fragment cgFragment = new Wix.Fragment();
231
+ cgFragment.AddChild(componentGroup);
232
+ wix.AddChild(cgFragment);
233
+
234
+ int componentCount = 0;
235
+ for (; componentCount < this.components.Count; componentCount++)
236
+ {
237
+ Wix.Component c = this.components[componentCount] as Wix.Component;
238
+
239
+ if (this.createFragments)
240
+ {
241
+ if (c.ParentElement is Wix.Directory)
242
+ {
243
+ Wix.Directory parentDirectory = c.ParentElement as Wix.Directory;
244
+
245
+ componentGroup.AddChild(c);
246
+ c.Directory = parentDirectory.Id;
247
+ parentDirectory.RemoveChild(c);
248
+ }
249
+ else if (c.ParentElement is Wix.DirectoryRef)
250
+ {
251
+ Wix.DirectoryRef parentDirectory = c.ParentElement as Wix.DirectoryRef;
252
+
253
+ componentGroup.AddChild(c);
254
+ c.Directory = parentDirectory.Id;
255
+ parentDirectory.RemoveChild(c);
256
+
257
+ // Remove whole fragment if moving the component to the component group just leaves an empty DirectoryRef
258
+ if (0 < this.fragments.Count && parentDirectory.ParentElement is Wix.Fragment)
259
+ {
260
+ Wix.Fragment parentFragment = parentDirectory.ParentElement as Wix.Fragment;
261
+ int childCount = 0;
262
+ foreach (Wix.ISchemaElement element in parentFragment.Children)
263
+ {
264
+ childCount++;
265
+ }
266
+
267
+ // Component should always have an Id but the SortedList creation allows for null and bases the name on the fragment count which we cannot reverse engineer here.
268
+ if (1 == childCount && !String.IsNullOrEmpty(c.Id))
269
+ {
270
+ int removeIndex = this.fragments.IndexOfKey(String.Concat("Component:", c.Id));
271
+ if (0 <= removeIndex)
272
+ {
273
+ this.fragments.RemoveAt(removeIndex);
274
+ }
275
+ }
276
+ }
277
+ }
278
+ }
279
+ else
280
+ {
281
+ Wix.ComponentRef componentRef = new Wix.ComponentRef();
282
+ componentRef.Id = c.Id;
283
+ componentGroup.AddChild(componentRef);
284
+ }
285
+ }
286
+ }
287
+
288
+ /// <summary>
289
+ /// Index an element.
290
+ /// </summary>
291
+ /// <param name="element">The element to index.</param>
292
+ private void IndexElement(Wix.ISchemaElement element)
293
+ {
294
+ if (element is Wix.Component)
295
+ {
296
+ this.components.Add(element);
297
+ }
298
+ else if (element is Wix.ComponentGroup)
299
+ {
300
+ this.componentGroups.Add(element);
301
+ }
302
+ else if (element is Wix.Directory)
303
+ {
304
+ this.directories.Add(element);
305
+ }
306
+ else if (element is Wix.DirectoryRef)
307
+ {
308
+ this.directoryRefs.Add(element);
309
+ }
310
+ else if (element is Wix.Feature)
311
+ {
312
+ this.features.Add(element);
313
+ }
314
+ else if (element is Wix.File)
315
+ {
316
+ this.files.Add(element);
317
+ }
318
+ else if (element is Wix.Module || element is Wix.PatchCreation || element is Wix.Package)
319
+ {
320
+ Debug.Assert(null == this.rootElement);
321
+ this.rootElement = (Wix.IParentElement)element;
322
+ }
323
+
324
+ // index the child elements
325
+ if (element is Wix.IParentElement)
326
+ {
327
+ foreach (Wix.ISchemaElement childElement in ((Wix.IParentElement)element).Children)
328
+ {
329
+ this.IndexElement(childElement);
330
+ }
331
+ }
332
+ }
333
+
334
+ /// <summary>
335
+ /// Mutate the components.
336
+ /// </summary>
337
+ private void MutateComponents()
338
+ {
339
+ IdentifierGenerator identifierGenerator = new IdentifierGenerator("Component", this.Core);
340
+ if (TemplateType.Module == this.templateType)
341
+ {
342
+ identifierGenerator.MaxIdentifierLength = IdentifierGenerator.MaxModuleIdentifierLength;
343
+ }
344
+
345
+ foreach (Wix.Component component in this.components)
346
+ {
347
+ if (null == component.Id)
348
+ {
349
+ string firstFileId = string.Empty;
350
+
351
+ // attempt to create a possible identifier from the first file identifier in the component
352
+ foreach (Wix.File file in component[typeof(Wix.File)])
353
+ {
354
+ firstFileId = file.Id;
355
+ break;
356
+ }
357
+
358
+ if (string.IsNullOrEmpty(firstFileId))
359
+ {
360
+ firstFileId = this.GetGuid();
361
+ }
362
+
363
+ component.Id = identifierGenerator.GetIdentifier(firstFileId);
364
+ }
365
+
366
+ if (null == component.Guid)
367
+ {
368
+ if (this.AutogenerateGuids)
369
+ {
370
+ component.Guid = "*";
371
+ }
372
+ else
373
+ {
374
+ component.Guid = this.GetGuid();
375
+ }
376
+ }
377
+
378
+ if (this.createFragments && component.ParentElement is Wix.Directory)
379
+ {
380
+ Wix.Directory directory = (Wix.Directory)component.ParentElement;
381
+
382
+ // parent directory must have an identifier to create a reference to it
383
+ if (null == directory.Id)
384
+ {
385
+ break;
386
+ }
387
+
388
+ if (this.rootElement is Wix.Module)
389
+ {
390
+ // add a ComponentRef for the Component
391
+ Wix.ComponentRef componentRef = new Wix.ComponentRef();
392
+ componentRef.Id = component.Id;
393
+ this.rootElement.AddChild(componentRef);
394
+ }
395
+
396
+ // create a new Fragment
397
+ Wix.Fragment fragment = new Wix.Fragment();
398
+ this.fragments.Add(String.Concat("Component:", (null != component.Id ? component.Id : this.fragments.Count.ToString())), fragment);
399
+
400
+ // create a new DirectoryRef
401
+ Wix.DirectoryRef directoryRef = new Wix.DirectoryRef();
402
+ directoryRef.Id = directory.Id;
403
+ fragment.AddChild(directoryRef);
404
+
405
+ // move the Component from the the Directory to the DirectoryRef
406
+ directory.RemoveChild(component);
407
+ directoryRef.AddChild(component);
408
+ }
409
+ }
410
+ }
411
+
412
+ /// <summary>
413
+ /// Mutate the directories.
414
+ /// </summary>
415
+ private void MutateDirectories()
416
+ {
417
+ if (!this.setUniqueIdentifiers)
418
+ {
419
+ // assign all identifiers before fragmenting (because fragmenting requires them all to be present)
420
+ IdentifierGenerator identifierGenerator = new IdentifierGenerator("Directory", this.Core);
421
+ if (TemplateType.Module == this.templateType)
422
+ {
423
+ identifierGenerator.MaxIdentifierLength = IdentifierGenerator.MaxModuleIdentifierLength;
424
+ }
425
+
426
+ foreach (Wix.Directory directory in this.directories)
427
+ {
428
+ if (null == directory.Id)
429
+ {
430
+ directory.Id = identifierGenerator.GetIdentifier(directory.Name);
431
+ }
432
+ }
433
+ }
434
+
435
+ if (this.createFragments)
436
+ {
437
+ foreach (Wix.Directory directory in this.directories)
438
+ {
439
+ if (directory.ParentElement is Wix.Directory)
440
+ {
441
+ Wix.Directory parentDirectory = (Wix.Directory)directory.ParentElement;
442
+
443
+ // parent directory must have an identifier to create a reference to it
444
+ if (null == parentDirectory.Id)
445
+ {
446
+ return;
447
+ }
448
+
449
+ // create a new Fragment
450
+ Wix.Fragment fragment = new Wix.Fragment();
451
+ this.fragments.Add(String.Concat("Directory:", ("TARGETDIR" == directory.Id ? null : (null != directory.Id ? directory.Id : this.fragments.Count.ToString()))), fragment);
452
+
453
+ // create a new DirectoryRef
454
+ Wix.DirectoryRef directoryRef = new Wix.DirectoryRef();
455
+ directoryRef.Id = parentDirectory.Id;
456
+ fragment.AddChild(directoryRef);
457
+
458
+ // move the Directory from the parent Directory to DirectoryRef
459
+ parentDirectory.RemoveChild(directory);
460
+ directoryRef.AddChild(directory);
461
+ }
462
+ else if (directory.ParentElement is Wix.Fragment)
463
+ {
464
+ // When creating fragments, remove any top-level Directory elements;
465
+ // the fragments should be pulled in by their DirectoryRefs instead.
466
+ Wix.Fragment parent = (Wix.Fragment)directory.ParentElement;
467
+ parent.RemoveChild(directory);
468
+
469
+ // Remove the fragment if it is empty.
470
+ if (parent.Children.GetEnumerator().Current == null && parent.ParentElement != null)
471
+ {
472
+ ((Wix.IParentElement)parent.ParentElement).RemoveChild(parent);
473
+ }
474
+ }
475
+ else if (directory.ParentElement == this.rootElement)
476
+ {
477
+ // create a new Fragment
478
+ Wix.Fragment fragment = new Wix.Fragment();
479
+ this.fragments.Add(String.Concat("Directory:", ("TARGETDIR" == directory.Id ? null : (null != directory.Id ? directory.Id : this.fragments.Count.ToString()))), fragment);
480
+
481
+ // move the Directory from the root element to the Fragment
482
+ this.rootElement.RemoveChild(directory);
483
+ fragment.AddChild(directory);
484
+ }
485
+ }
486
+ }
487
+ }
488
+
489
+ /// <summary>
490
+ /// Mutate the files.
491
+ /// </summary>
492
+ private void MutateFiles()
493
+ {
494
+ IdentifierGenerator identifierGenerator = new IdentifierGenerator("File", this.Core);
495
+ if (TemplateType.Module == this.templateType)
496
+ {
497
+ identifierGenerator.MaxIdentifierLength = IdentifierGenerator.MaxModuleIdentifierLength;
498
+ }
499
+
500
+ foreach (Wix.File file in this.files)
501
+ {
502
+ if (null == file.Id)
503
+ {
504
+ file.Id = identifierGenerator.GetIdentifier(Path.GetFileName(file.Source));
505
+ }
506
+ }
507
+ }
508
+
509
+ /// <summary>
510
+ /// Mutate a Wix element.
511
+ /// </summary>
512
+ /// <param name="wix">The Wix element to mutate.</param>
513
+ private void MutateWix(Wix.Wix wix)
514
+ {
515
+ if (TemplateType.Fragment != this.templateType)
516
+ {
517
+ if (null != this.rootElement || 0 != this.features.Count)
518
+ {
519
+ throw new Exception("The template option cannot be used with Feature, Package, or Module elements present.");
520
+ }
521
+
522
+ // create a package element although it won't always be used
523
+ Wix.SummaryInformation package = new Wix.SummaryInformation();
524
+ if (TemplateType.Module == this.templateType)
525
+ {
526
+ package.Id = this.GetGuid();
527
+ }
528
+ else
529
+ {
530
+ package.Compressed = Wix.YesNoType.yes;
531
+ }
532
+
533
+ package.InstallerVersion = 200;
534
+
535
+ Wix.Directory targetDir = new Wix.Directory();
536
+ targetDir.Id = "TARGETDIR";
537
+ targetDir.Name = "SourceDir";
538
+
539
+ foreach (Wix.DirectoryRef directoryRef in this.directoryRefs)
540
+ {
541
+ if (String.Equals(directoryRef.Id, "TARGETDIR", StringComparison.OrdinalIgnoreCase))
542
+ {
543
+ Wix.IParentElement parent = directoryRef.ParentElement as Wix.IParentElement;
544
+
545
+ foreach (Wix.ISchemaElement element in directoryRef.Children)
546
+ {
547
+ targetDir.AddChild(element);
548
+ }
549
+
550
+ parent.RemoveChild(directoryRef);
551
+
552
+ if (null != ((Wix.ISchemaElement)parent).ParentElement)
553
+ {
554
+ int i = 0;
555
+
556
+ foreach (Wix.ISchemaElement element in parent.Children)
557
+ {
558
+ i++;
559
+ }
560
+
561
+ if (0 == i)
562
+ {
563
+ Wix.IParentElement supParent = (Wix.IParentElement)((Wix.ISchemaElement)parent).ParentElement;
564
+ supParent.RemoveChild((Wix.ISchemaElement)parent);
565
+ }
566
+ }
567
+
568
+ break;
569
+ }
570
+ }
571
+
572
+ if (TemplateType.Module == this.templateType)
573
+ {
574
+ Wix.Module module = new Wix.Module();
575
+ module.Id = "PUT-MODULE-NAME-HERE";
576
+ module.Language = "1033";
577
+ module.Version = "1.0.0.0";
578
+
579
+ package.Manufacturer = "PUT-COMPANY-NAME-HERE";
580
+ module.AddChild(package);
581
+ module.AddChild(targetDir);
582
+
583
+ wix.AddChild(module);
584
+ this.rootElement = module;
585
+ }
586
+ else // product
587
+ {
588
+ Wix.Package product = new Wix.Package();
589
+ product.Id = this.GetGuid();
590
+ product.Language = "1033";
591
+ product.Manufacturer = "PUT-COMPANY-NAME-HERE";
592
+ product.Name = "PUT-PRODUCT-NAME-HERE";
593
+ product.UpgradeCode = this.GetGuid();
594
+ product.Version = "1.0.0.0";
595
+ product.AddChild(package);
596
+ product.AddChild(targetDir);
597
+
598
+ Wix.Media media = new Wix.Media();
599
+ media.Id = "1";
600
+ media.Cabinet = "product.cab";
601
+ media.EmbedCab = Wix.YesNoType.yes;
602
+ product.AddChild(media);
603
+
604
+ Wix.Feature feature = new Wix.Feature();
605
+ feature.Id = "ProductFeature";
606
+ feature.Title = "PUT-FEATURE-TITLE-HERE";
607
+ feature.Level = 1;
608
+ product.AddChild(feature);
609
+ this.features.Add(feature);
610
+
611
+ wix.AddChild(product);
612
+ this.rootElement = product;
613
+ }
614
+ }
615
+ }
616
+
617
+ /// <summary>
618
+ /// Get a generated guid or a placeholder for a guid.
619
+ /// </summary>
620
+ /// <returns>A generated guid or placeholder.</returns>
621
+ private string GetGuid()
622
+ {
623
+ if (this.generateGuids)
624
+ {
625
+ return Guid.NewGuid().ToString(this.guidFormat, CultureInfo.InvariantCulture).ToUpper(CultureInfo.InvariantCulture);
626
+ }
627
+ else
628
+ {
629
+ return "PUT-GUID-HERE";
630
+ }
631
+ }
632
+ }
633
+}
src/heat/UtilTransformMutator.cs
new
+77
@@ -0,0 +1,77 @@
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.Harvesters
4
+{
5
+ using System;
6
+ using System.IO;
7
+ using System.Xml;
8
+ using System.Xml.Xsl;
9
+ using WixToolset.Harvesters.Data;
10
+ using WixToolset.Harvesters.Extensibility;
11
+
12
+ internal class UtilTransformMutator : BaseMutatorExtension
13
+ {
14
+ private string transform;
15
+ private int transformSequence;
16
+
17
+ /// <summary>
18
+ /// Instantiate a new UtilTransformMutator.
19
+ /// </summary>
20
+ /// <param name="transform">Path to the XSL transform file.</param>
21
+ /// <param name="transformSequence">Order in which the transform should be applied,
22
+ /// relative to other transforms.</param>
23
+ public UtilTransformMutator(string transform, int transformSequence)
24
+ {
25
+ this.transform = transform;
26
+ this.transformSequence = transformSequence;
27
+ }
28
+
29
+ /// <summary>
30
+ /// Gets the sequence of the extension.
31
+ /// </summary>
32
+ /// <value>The sequence of the extension.</value>
33
+ public override int Sequence
34
+ {
35
+ get { return 3000 + this.transformSequence; }
36
+ }
37
+
38
+ /// <summary>
39
+ /// Mutate a WiX document as a string.
40
+ /// </summary>
41
+ /// <param name="wixString">The Wix document element as a string.</param>
42
+ /// <returns>The mutated Wix document as a string.</returns>
43
+ public override string Mutate(string wixString)
44
+ {
45
+ try
46
+ {
47
+ XslCompiledTransform xslt = new XslCompiledTransform();
48
+ xslt.Load(this.transform, XsltSettings.TrustedXslt, new XmlUrlResolver());
49
+
50
+ using (XmlTextReader xmlReader = new XmlTextReader(new StringReader(wixString)))
51
+ {
52
+ using (StringWriter stringWriter = new StringWriter())
53
+ {
54
+ XmlWriterSettings xmlSettings = new XmlWriterSettings();
55
+ xmlSettings.Indent = true;
56
+ xmlSettings.IndentChars = " ";
57
+ xmlSettings.OmitXmlDeclaration = true;
58
+
59
+ using (XmlWriter xmlWriter = XmlWriter.Create(stringWriter, xmlSettings))
60
+ {
61
+ xslt.Transform(xmlReader, xmlWriter);
62
+ }
63
+
64
+ wixString = stringWriter.ToString();
65
+ }
66
+ }
67
+ }
68
+ catch (Exception ex)
69
+ {
70
+ this.Core.Messaging.Write(HarvesterErrors.ErrorTransformingHarvestedWiX(this.transform, ex.Message));
71
+ return null;
72
+ }
73
+
74
+ return wixString;
75
+ }
76
+ }
77
+}
src/heat/VSHeatExtension.cs
new
+229
@@ -0,0 +1,229 @@
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.Harvesters
4
+{
5
+ using System;
6
+ using System.Collections;
7
+ using WixToolset.Data;
8
+ using WixToolset.Harvesters.Data;
9
+ using WixToolset.Harvesters.Extensibility;
10
+
11
+ /// <summary>
12
+ /// Defines generated element types.
13
+ /// </summary>
14
+ internal enum GenerateType
15
+ {
16
+ /// <summary>Generate Components.</summary>
17
+ Components,
18
+
19
+ /// <summary>Generate a Container with Payloads.</summary>
20
+ Container,
21
+
22
+ /// <summary>Generate a Bundle PackageGroups.</summary>
23
+ PackageGroup,
24
+
25
+ /// <summary>Generate a PayloadGroup with Payloads.</summary>
26
+ PayloadGroup,
27
+ }
28
+
29
+ /// <summary>
30
+ /// VS-related extensions for the WiX Toolset Harvester application.
31
+ /// </summary>
32
+ internal class VSHeatExtension : BaseHeatExtension
33
+ {
34
+ /// <summary>
35
+ /// Gets the supported command line types for this extension.
36
+ /// </summary>
37
+ /// <value>The supported command line types for this extension.</value>
38
+ public override HeatCommandLineOption[] CommandLineTypes
39
+ {
40
+ get
41
+ {
42
+ return new HeatCommandLineOption[]
43
+ {
44
+ new HeatCommandLineOption("project", "harvest outputs of a VS project"),
45
+ new HeatCommandLineOption("-configuration", "configuration to set when harvesting the project"),
46
+ new HeatCommandLineOption("-directoryid", "overridden directory id for generated directory elements"),
47
+ new HeatCommandLineOption("-generate", Environment.NewLine +
48
+ " specify what elements to generate, one of:" + Environment.NewLine +
49
+ " components, container, payloadgroup, packagegroup" + Environment.NewLine +
50
+ " (default is components)"),
51
+ new HeatCommandLineOption("-msbuildbinpath", "msbuild bin directory path"),
52
+ new HeatCommandLineOption("-platform", "platform to set when harvesting the project"),
53
+ new HeatCommandLineOption("-pog", Environment.NewLine +
54
+ " specify output group of VS project, one of:" + Environment.NewLine +
55
+ " " + String.Join(",", VSProjectHarvester.GetOutputGroupNames()) + Environment.NewLine +
56
+ " This option may be repeated for multiple output groups."),
57
+ new HeatCommandLineOption("-projectname", "overridden project name to use in variables"),
58
+ new HeatCommandLineOption("-usetoolsversion", "ignore msbuildbinpath if project specifies known msbuild version"),
59
+ new HeatCommandLineOption("-wixvar", "generate binder variables instead of preprocessor variables"),
60
+ };
61
+ }
62
+ }
63
+
64
+ /// <summary>
65
+ /// Parse the command line options for this extension.
66
+ /// </summary>
67
+ /// <param name="type">The active harvester type.</param>
68
+ /// <param name="args">The option arguments.</param>
69
+ public override void ParseOptions(string type, string[] args)
70
+ {
71
+ if ("project" == type)
72
+ {
73
+ string[] allOutputGroups = VSProjectHarvester.GetOutputGroupNames();
74
+ bool suppressUniqueId = false;
75
+ bool generateWixVars = false;
76
+ bool useToolsVersion = false;
77
+ GenerateType generateType = GenerateType.Components;
78
+ string directoryIds = null;
79
+ string msbuildBinPath = null;
80
+ string projectName = null;
81
+ string configuration = null;
82
+ string platform = null;
83
+ ArrayList outputGroups = new ArrayList();
84
+
85
+ for (int i = 0; i < args.Length; i++)
86
+ {
87
+ if ("-configuration" == args[i])
88
+ {
89
+ configuration = args[++i];
90
+ }
91
+ else if ("-directoryid" == args[i])
92
+ {
93
+ if (!IsValidArg(args, ++i))
94
+ {
95
+ throw new WixException(HarvesterErrors.InvalidDirectoryId(args[i]));
96
+ }
97
+
98
+ directoryIds = args[i];
99
+ }
100
+ else if ("-generate" == args[i])
101
+ {
102
+ if (!IsValidArg(args, ++i))
103
+ {
104
+ throw new WixException(HarvesterErrors.InvalidProjectOutputType(args[i]));
105
+ }
106
+
107
+ string genType = args[i].ToUpperInvariant();
108
+ switch(genType)
109
+ {
110
+ case "CONTAINER":
111
+ generateType = GenerateType.Container;
112
+ break;
113
+ case "COMPONENTS":
114
+ generateType = GenerateType.Components;
115
+ break;
116
+ case "PACKAGEGROUP":
117
+ generateType = GenerateType.PackageGroup;
118
+ break;
119
+ case "PAYLOADGROUP":
120
+ generateType = GenerateType.PayloadGroup;
121
+ break;
122
+ default:
123
+ throw new WixException(HarvesterErrors.InvalidProjectOutputType(genType));
124
+ }
125
+ }
126
+ else if ("-msbuildbinpath" == args[i])
127
+ {
128
+ if (!IsValidArg(args, ++i))
129
+ {
130
+ throw new WixException(HarvesterErrors.ArgumentRequiresValue(args[i-1]));
131
+ }
132
+
133
+ msbuildBinPath = args[i];
134
+ }
135
+ else if ("-platform" == args[i])
136
+ {
137
+ platform = args[++i];
138
+ }
139
+ else if ("-pog" == args[i])
140
+ {
141
+ if (!IsValidArg(args, ++i))
142
+ {
143
+ throw new WixException(HarvesterErrors.InvalidOutputGroup(args[i]));
144
+ }
145
+
146
+ string pogName = args[i];
147
+ bool found = false;
148
+ foreach (string availableOutputGroup in allOutputGroups)
149
+ {
150
+ if (String.Equals(pogName, availableOutputGroup, StringComparison.Ordinal))
151
+ {
152
+ outputGroups.Add(availableOutputGroup);
153
+ found = true;
154
+ break;
155
+ }
156
+ }
157
+
158
+ if (!found)
159
+ {
160
+ throw new WixException(HarvesterErrors.InvalidOutputGroup(pogName));
161
+ }
162
+ }
163
+ else if (args[i].StartsWith("-pog:", StringComparison.Ordinal))
164
+ {
165
+ this.Core.Messaging.Write(WarningMessages.DeprecatedCommandLineSwitch("pog:", "pog"));
166
+
167
+ string pogName = args[i].Substring(5);
168
+ bool found = false;
169
+ foreach (string availableOutputGroup in allOutputGroups)
170
+ {
171
+ if (String.Equals(pogName, availableOutputGroup, StringComparison.Ordinal))
172
+ {
173
+ outputGroups.Add(availableOutputGroup);
174
+ found = true;
175
+ break;
176
+ }
177
+ }
178
+
179
+ if (!found)
180
+ {
181
+ throw new WixException(HarvesterErrors.InvalidOutputGroup(pogName));
182
+ }
183
+ }
184
+ else if ("-projectname" == args[i])
185
+ {
186
+ if (!IsValidArg(args, ++i))
187
+ {
188
+ throw new WixException(HarvesterErrors.InvalidProjectName(args[i]));
189
+ }
190
+
191
+ projectName = args[i];
192
+ }
193
+ else if ("-suid" == args[i])
194
+ {
195
+ suppressUniqueId = true;
196
+ }
197
+ else if ("-usetoolsversion" == args[i])
198
+ {
199
+ useToolsVersion = true;
200
+ }
201
+ else if ("-wixvar" == args[i])
202
+ {
203
+ generateWixVars = true;
204
+ }
205
+ }
206
+
207
+ if (outputGroups.Count == 0)
208
+ {
209
+ throw new WixException(HarvesterErrors.NoOutputGroupSpecified());
210
+ }
211
+
212
+ VSProjectHarvester harvester = new VSProjectHarvester(
213
+ (string[]) outputGroups.ToArray(typeof(string)));
214
+
215
+ harvester.SetUniqueIdentifiers = !suppressUniqueId;
216
+ harvester.GenerateWixVars = generateWixVars;
217
+ harvester.GenerateType = generateType;
218
+ harvester.DirectoryIds = directoryIds;
219
+ harvester.MsbuildBinPath = msbuildBinPath;
220
+ harvester.ProjectName = projectName;
221
+ harvester.Configuration = configuration;
222
+ harvester.Platform = platform;
223
+ harvester.UseToolsVersion = String.IsNullOrEmpty(msbuildBinPath) || useToolsVersion;
224
+
225
+ this.Core.Harvester.Extension = harvester;
226
+ }
227
+ }
228
+ }
229
+}
src/heat/VSProjectHarvester.cs
new
+1455
@@ -0,0 +1,1455 @@
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.Harvesters
4
+{
5
+ using System;
6
+ using System.IO;
7
+ using System.Reflection;
8
+ using System.Collections;
9
+ using System.Collections.Generic;
10
+ using System.Globalization;
11
+ using System.Text.RegularExpressions;
12
+ using System.Xml;
13
+ using WixToolset.Data;
14
+ using WixToolset.Extensibility.Services;
15
+ using WixToolset.Harvesters.Data;
16
+ using WixToolset.Harvesters.Extensibility;
17
+ using Wix = WixToolset.Harvesters.Serialize;
18
+
19
+ /// <summary>
20
+ /// Harvest WiX authoring for the outputs of a VS project.
21
+ /// </summary>
22
+ internal class VSProjectHarvester : BaseHarvesterExtension
23
+ {
24
+ // These format strings are used for generated element identifiers.
25
+ // {0} = project name
26
+ // {1} = POG name
27
+ // {2} = file name
28
+ private const string DirectoryIdFormat = "{0}.{1}";
29
+ private const string ComponentIdFormat = "{0}.{1}.{2}";
30
+ private const string FileIdFormat = "{0}.{1}.{2}";
31
+ private const string VariableFormat = "$(var.{0}.{1})";
32
+ private const string WixVariableFormat = "!(wix.{0}.{1})";
33
+
34
+ private const string ComponentPrefix = "cmp";
35
+ private const string DirectoryPrefix = "dir";
36
+ private const string FilePrefix = "fil";
37
+
38
+ private string projectGUID;
39
+ private string directoryIds;
40
+ private string directoryRefSeed;
41
+ private string projectName;
42
+ private string configuration;
43
+ private string platform;
44
+ private bool setUniqueIdentifiers;
45
+ private GenerateType generateType;
46
+ private bool generateWixVars;
47
+
48
+
49
+ private static readonly ProjectOutputGroup[] allOutputGroups = new ProjectOutputGroup[]
50
+ {
51
+ new ProjectOutputGroup("Binaries", "BuiltProjectOutputGroup", "TargetDir"),
52
+ new ProjectOutputGroup("Symbols", "DebugSymbolsProjectOutputGroup", "TargetDir"),
53
+ new ProjectOutputGroup("Documents", "DocumentationProjectOutputGroup", "ProjectDir"),
54
+ new ProjectOutputGroup("Satellites", "SatelliteDllsProjectOutputGroup", "TargetDir"),
55
+ new ProjectOutputGroup("Sources", "SourceFilesProjectOutputGroup", "ProjectDir"),
56
+ new ProjectOutputGroup("Content", "ContentFilesProjectOutputGroup", "ProjectDir"),
57
+ };
58
+
59
+ private string[] outputGroups;
60
+
61
+ /// <summary>
62
+ /// Instantiate a new VSProjectHarvester.
63
+ /// </summary>
64
+ /// <param name="outputGroups">List of project output groups to harvest.</param>
65
+ public VSProjectHarvester(string[] outputGroups)
66
+ {
67
+ if (outputGroups == null)
68
+ {
69
+ throw new ArgumentNullException("outputGroups");
70
+ }
71
+
72
+ this.outputGroups = outputGroups;
73
+ }
74
+
75
+ /// <summary>
76
+ /// Gets or sets the configuration to set when harvesting.
77
+ /// </summary>
78
+ /// <value>The configuration to set when harvesting.</value>
79
+ public string Configuration
80
+ {
81
+ get { return this.configuration; }
82
+ set { this.configuration = value; }
83
+ }
84
+
85
+ public string DirectoryIds
86
+ {
87
+ get { return this.directoryIds; }
88
+ set { this.directoryIds = value; }
89
+ }
90
+
91
+ /// <summary>
92
+ /// Gets or sets what type of elements are to be generated.
93
+ /// </summary>
94
+ /// <value>The type of elements being generated.</value>
95
+ public GenerateType GenerateType
96
+ {
97
+ get { return this.generateType; }
98
+ set { this.generateType = value; }
99
+ }
100
+
101
+ /// <summary>
102
+ /// Gets or sets whether or not to use wix variables.
103
+ /// </summary>
104
+ /// <value>Whether or not to use wix variables.</value>
105
+ public bool GenerateWixVars
106
+ {
107
+ get { return this.generateWixVars; }
108
+ set { this.generateWixVars = value; }
109
+ }
110
+
111
+ /// <summary>
112
+ /// Gets or sets the location to load MSBuild from.
113
+ /// </summary>
114
+ public string MsbuildBinPath { get; set; }
115
+
116
+ /// <summary>
117
+ /// Gets or sets the platform to set when harvesting.
118
+ /// </summary>
119
+ /// <value>The platform to set when harvesting.</value>
120
+ public string Platform
121
+ {
122
+ get { return this.platform; }
123
+ set { this.platform = value; }
124
+ }
125
+
126
+ /// <summary>
127
+ /// Gets or sets the project name to use in wix variables.
128
+ /// </summary>
129
+ /// <value>The project name to use in wix variables.</value>
130
+ public string ProjectName
131
+ {
132
+ get { return this.projectName; }
133
+ set { this.projectName = value; }
134
+ }
135
+
136
+ /// <summary>
137
+ /// Gets or sets the option to set unique identifiers.
138
+ /// </summary>
139
+ /// <value>The option to set unique identifiers.</value>
140
+ public bool SetUniqueIdentifiers
141
+ {
142
+ get { return this.setUniqueIdentifiers; }
143
+ set { this.setUniqueIdentifiers = value; }
144
+ }
145
+
146
+ /// <summary>
147
+ /// Gets or sets whether to ignore MsbuildBinPath when the project file specifies a known MSBuild version.
148
+ /// </summary>
149
+ public bool UseToolsVersion { get; set; }
150
+
151
+ /// <summary>
152
+ /// Gets a list of friendly output group names that will be recognized on the command-line.
153
+ /// </summary>
154
+ /// <returns>Array of output group names.</returns>
155
+ public static string[] GetOutputGroupNames()
156
+ {
157
+ string[] names = new string[VSProjectHarvester.allOutputGroups.Length];
158
+ for (int i = 0; i < names.Length; i++)
159
+ {
160
+ names[i] = VSProjectHarvester.allOutputGroups[i].Name;
161
+ }
162
+ return names;
163
+ }
164
+
165
+ /// <summary>
166
+ /// Harvest a VS project.
167
+ /// </summary>
168
+ /// <param name="argument">The path of the VS project file.</param>
169
+ /// <returns>The harvested directory.</returns>
170
+ public override Wix.Fragment[] Harvest(string argument)
171
+ {
172
+ if (null == argument)
173
+ {
174
+ throw new ArgumentNullException("argument");
175
+ }
176
+
177
+ if (!System.IO.File.Exists(argument))
178
+ {
179
+ throw new FileNotFoundException(argument);
180
+ }
181
+
182
+ // Match specified output group names to available POG structures
183
+ // and collect list of build output groups to pass to MSBuild.
184
+ ProjectOutputGroup[] pogs = new ProjectOutputGroup[this.outputGroups.Length];
185
+ string[] buildOutputGroups = new string[this.outputGroups.Length];
186
+ for (int i = 0; i < this.outputGroups.Length; i++)
187
+ {
188
+ foreach (ProjectOutputGroup pog in VSProjectHarvester.allOutputGroups)
189
+ {
190
+ if (pog.Name == this.outputGroups[i])
191
+ {
192
+ pogs[i] = pog;
193
+ buildOutputGroups[i] = pog.BuildOutputGroup;
194
+ }
195
+ }
196
+
197
+ if (buildOutputGroups[i] == null)
198
+ {
199
+ throw new WixException(HarvesterErrors.InvalidOutputGroup(this.outputGroups[i]));
200
+ }
201
+ }
202
+
203
+ string projectFile = Path.GetFullPath(argument);
204
+
205
+ IDictionary buildOutputs = this.GetProjectBuildOutputs(projectFile, buildOutputGroups);
206
+
207
+ ArrayList fragmentList = new ArrayList();
208
+
209
+ for (int i = 0; i < pogs.Length; i++)
210
+ {
211
+ this.HarvestProjectOutputGroup(projectFile, buildOutputs, pogs[i], fragmentList);
212
+ }
213
+
214
+ return (Wix.Fragment[]) fragmentList.ToArray(typeof(Wix.Fragment));
215
+ }
216
+
217
+ /// <summary>
218
+ /// Runs MSBuild on a project file to get the list of filenames for the specified output groups.
219
+ /// </summary>
220
+ /// <param name="projectFile">VS MSBuild project file to load.</param>
221
+ /// <param name="buildOutputGroups">List of MSBuild output group names.</param>
222
+ /// <returns>Dictionary mapping output group names to lists of filenames in the group.</returns>
223
+ private IDictionary GetProjectBuildOutputs(string projectFile, string[] buildOutputGroups)
224
+ {
225
+ MSBuildProject project = this.GetMsbuildProject(projectFile);
226
+
227
+ project.Load(projectFile);
228
+
229
+ IDictionary buildOutputs = new Hashtable();
230
+
231
+ string originalDirectory = System.IO.Directory.GetCurrentDirectory();
232
+ System.IO.Directory.SetCurrentDirectory(Path.GetDirectoryName(projectFile));
233
+ bool buildSuccess = false;
234
+ try
235
+ {
236
+ buildSuccess = project.Build(projectFile, buildOutputGroups, buildOutputs);
237
+ }
238
+ finally
239
+ {
240
+ System.IO.Directory.SetCurrentDirectory(originalDirectory);
241
+ }
242
+
243
+ if (!buildSuccess)
244
+ {
245
+ throw new WixException(HarvesterErrors.BuildFailed());
246
+ }
247
+
248
+ this.projectGUID = project.GetEvaluatedProperty("ProjectGuid");
249
+
250
+ if (null == this.projectGUID)
251
+ {
252
+ throw new WixException(HarvesterErrors.BuildFailed());
253
+ }
254
+
255
+ IDictionary newDictionary = new Dictionary<object, object>();
256
+ foreach (string buildOutput in buildOutputs.Keys)
257
+ {
258
+ IEnumerable buildOutputFiles = buildOutputs[buildOutput] as IEnumerable;
259
+
260
+ bool hasFiles = false;
261
+
262
+ foreach (object file in buildOutputFiles)
263
+ {
264
+ hasFiles = true;
265
+ break;
266
+ }
267
+
268
+ // Try the item group if no outputs
269
+ if (!hasFiles)
270
+ {
271
+ IEnumerable itemFiles = project.GetEvaluatedItemsByName(String.Concat(buildOutput, "Output"));
272
+ List<object> itemFileList = new List<object>();
273
+
274
+ // Get each BuildItem and add the file path to our list
275
+ foreach (object itemFile in itemFiles)
276
+ {
277
+ itemFileList.Add(project.GetBuildItem(itemFile));
278
+ }
279
+
280
+ // Use our list for this build output
281
+ newDictionary.Add(buildOutput, itemFileList);
282
+ }
283
+ else
284
+ {
285
+ newDictionary.Add(buildOutput, buildOutputFiles);
286
+ }
287
+ }
288
+
289
+ return newDictionary;
290
+ }
291
+
292
+ /// <summary>
293
+ /// Creates WiX fragments for files in one output group.
294
+ /// </summary>
295
+ /// <param name="projectFile">VS MSBuild project file.</param>
296
+ /// <param name="buildOutputs">Dictionary of build outputs retrieved from an MSBuild run on the project file.</param>
297
+ /// <param name="pog">Project output group parameters.</param>
298
+ /// <param name="fragmentList">List to which generated fragments will be added.</param>
299
+ /// <returns>Count of harvested files.</returns>
300
+ private int HarvestProjectOutputGroup(string projectFile, IDictionary buildOutputs, ProjectOutputGroup pog, IList fragmentList)
301
+ {
302
+ string projectName = Path.GetFileNameWithoutExtension(projectFile);
303
+ string projectBaseDir = null;
304
+
305
+ if (this.ProjectName != null)
306
+ {
307
+ projectName = this.ProjectName;
308
+ }
309
+
310
+ string sanitizedProjectName = this.Core.CreateIdentifierFromFilename(projectName);
311
+
312
+ Wix.IParentElement harvestParent;
313
+
314
+ if (this.GenerateType == GenerateType.Container)
315
+ {
316
+ Wix.Container container = new Wix.Container();
317
+ harvestParent = container;
318
+
319
+ container.Name = String.Format(CultureInfo.InvariantCulture, DirectoryIdFormat, sanitizedProjectName, pog.Name);
320
+ }
321
+ else if (this.GenerateType == GenerateType.PayloadGroup)
322
+ {
323
+ Wix.PayloadGroup payloadGroup = new Wix.PayloadGroup();
324
+ harvestParent = payloadGroup;
325
+
326
+ payloadGroup.Id = String.Format(CultureInfo.InvariantCulture, DirectoryIdFormat, sanitizedProjectName, pog.Name);
327
+ }
328
+ else if (this.GenerateType == GenerateType.PackageGroup)
329
+ {
330
+ Wix.PackageGroup packageGroup = new Wix.PackageGroup();
331
+ harvestParent = packageGroup;
332
+
333
+ packageGroup.Id = String.Format(CultureInfo.InvariantCulture, DirectoryIdFormat, sanitizedProjectName, pog.Name);
334
+ }
335
+ else
336
+ {
337
+ Wix.DirectoryRef directoryRef = new Wix.DirectoryRef();
338
+ harvestParent = directoryRef;
339
+
340
+ if (!String.IsNullOrEmpty(this.directoryIds))
341
+ {
342
+ directoryRef.Id = this.directoryIds;
343
+ }
344
+ else if (this.setUniqueIdentifiers)
345
+ {
346
+ directoryRef.Id = String.Format(CultureInfo.InvariantCulture, DirectoryIdFormat, sanitizedProjectName, pog.Name);
347
+ }
348
+ else
349
+ {
350
+ directoryRef.Id = this.Core.CreateIdentifierFromFilename(String.Format(CultureInfo.InvariantCulture, DirectoryIdFormat, sanitizedProjectName, pog.Name));
351
+ }
352
+
353
+ this.directoryRefSeed = this.Core.GenerateIdentifier(DirectoryPrefix, this.projectGUID, pog.Name);
354
+ }
355
+
356
+ IEnumerable pogFiles = buildOutputs[pog.BuildOutputGroup] as IEnumerable;
357
+ if (pogFiles == null)
358
+ {
359
+ throw new WixException(HarvesterErrors.MissingProjectOutputGroup(
360
+ projectFile, pog.BuildOutputGroup));
361
+ }
362
+
363
+ if (pog.FileSource == "ProjectDir")
364
+ {
365
+ projectBaseDir = Path.GetDirectoryName(projectFile) + "\\";
366
+ }
367
+
368
+ int harvestCount = this.HarvestProjectOutputGroupFiles(projectBaseDir, projectName, pog.Name, pog.FileSource, pogFiles, harvestParent);
369
+
370
+ if (this.GenerateType == GenerateType.Container)
371
+ {
372
+ // harvestParent must be a Container at this point
373
+ Wix.Container container = harvestParent as Wix.Container;
374
+
375
+ Wix.Fragment fragment = new Wix.Fragment();
376
+ fragment.AddChild(container);
377
+ fragmentList.Add(fragment);
378
+ }
379
+ else if (this.GenerateType == GenerateType.PackageGroup)
380
+ {
381
+ // harvestParent must be a PackageGroup at this point
382
+ Wix.PackageGroup packageGroup = harvestParent as Wix.PackageGroup;
383
+
384
+ Wix.Fragment fragment = new Wix.Fragment();
385
+ fragment.AddChild(packageGroup);
386
+ fragmentList.Add(fragment);
387
+ }
388
+ else if (this.GenerateType == GenerateType.PayloadGroup)
389
+ {
390
+ // harvestParent must be a Container at this point
391
+ Wix.PayloadGroup payloadGroup = harvestParent as Wix.PayloadGroup;
392
+
393
+ Wix.Fragment fragment = new Wix.Fragment();
394
+ fragment.AddChild(payloadGroup);
395
+ fragmentList.Add(fragment);
396
+ }
397
+ else
398
+ {
399
+ // harvestParent must be a DirectoryRef at this point
400
+ Wix.DirectoryRef directoryRef = harvestParent as Wix.DirectoryRef;
401
+
402
+ if (harvestCount > 0)
403
+ {
404
+ Wix.Fragment drf = new Wix.Fragment();
405
+ drf.AddChild(directoryRef);
406
+ fragmentList.Add(drf);
407
+ }
408
+
409
+ Wix.ComponentGroup cg = new Wix.ComponentGroup();
410
+
411
+ if (this.setUniqueIdentifiers || !String.IsNullOrEmpty(this.directoryIds))
412
+ {
413
+ cg.Id = String.Format(CultureInfo.InvariantCulture, DirectoryIdFormat, sanitizedProjectName, pog.Name);
414
+ }
415
+ else
416
+ {
417
+ cg.Id = directoryRef.Id;
418
+ }
419
+
420
+ if (harvestCount > 0)
421
+ {
422
+ this.AddComponentsToComponentGroup(directoryRef, cg);
423
+ }
424
+
425
+ Wix.Fragment cgf = new Wix.Fragment();
426
+ cgf.AddChild(cg);
427
+ fragmentList.Add(cgf);
428
+ }
429
+
430
+ return harvestCount;
431
+ }
432
+
433
+ /// <summary>
434
+ /// Add all Components in an element tree to a ComponentGroup.
435
+ /// </summary>
436
+ /// <param name="parent">Parent of an element tree that will be searched for Components.</param>
437
+ /// <param name="cg">The ComponentGroup the Components will be added to.</param>
438
+ private void AddComponentsToComponentGroup(Wix.IParentElement parent, Wix.ComponentGroup cg)
439
+ {
440
+ foreach (Wix.ISchemaElement childElement in parent.Children)
441
+ {
442
+ Wix.Component c = childElement as Wix.Component;
443
+ if (c != null)
444
+ {
445
+ Wix.ComponentRef cr = new Wix.ComponentRef();
446
+ cr.Id = c.Id;
447
+ cg.AddChild(cr);
448
+ }
449
+ else
450
+ {
451
+ Wix.IParentElement p = childElement as Wix.IParentElement;
452
+ if (p != null)
453
+ {
454
+ this.AddComponentsToComponentGroup(p, cg);
455
+ }
456
+ }
457
+ }
458
+ }
459
+
460
+ /// <summary>
461
+ /// Harvest files from one output group of a VS project.
462
+ /// </summary>
463
+ /// <param name="baseDir">The base directory of the files.</param>
464
+ /// <param name="projectName">Name of the project, to be used as a prefix for generated identifiers.</param>
465
+ /// <param name="pogName">Name of the project output group, used for generating identifiers for WiX elements.</param>
466
+ /// <param name="pogFileSource">The ProjectOutputGroup file source.</param>
467
+ /// <param name="outputGroupFiles">The files from one output group to harvest.</param>
468
+ /// <param name="parent">The parent element that will contain the components of the harvested files.</param>
469
+ /// <returns>The number of files harvested.</returns>
470
+ private int HarvestProjectOutputGroupFiles(string baseDir, string projectName, string pogName, string pogFileSource, IEnumerable outputGroupFiles, Wix.IParentElement parent)
471
+ {
472
+ int fileCount = 0;
473
+
474
+ Wix.ISchemaElement exeFile = null;
475
+ Wix.ISchemaElement dllFile = null;
476
+ Wix.ISchemaElement appConfigFile = null;
477
+
478
+ // Keep track of files inserted
479
+ // Files can have different absolute paths but get mapped to the same SourceFile
480
+ // after the project variables have been used. For example, a WiX project that
481
+ // is building multiple cultures will have many output MSIs/MSMs, but will all get
482
+ // mapped to $(var.ProjName.TargetDir)\ProjName.msm. These duplicates would
483
+ // prevent generated code from compiling.
484
+ Dictionary<string, bool> seenList = new Dictionary<string,bool>();
485
+
486
+ foreach (object output in outputGroupFiles)
487
+ {
488
+ string filePath = output.ToString();
489
+ string fileName = Path.GetFileName(filePath);
490
+ string fileDir = Path.GetDirectoryName(filePath);
491
+ string link = null;
492
+
493
+ MethodInfo getMetadataMethod = output.GetType().GetMethod("GetMetadata");
494
+ if (getMetadataMethod != null)
495
+ {
496
+ link = (string)getMetadataMethod.Invoke(output, new object[] { "Link" });
497
+ if (!String.IsNullOrEmpty(link))
498
+ {
499
+ fileDir = Path.GetDirectoryName(Path.Combine(baseDir, link));
500
+ }
501
+ }
502
+
503
+ Wix.IParentElement parentDir = parent;
504
+ // Ignore Containers and PayloadGroups because they do not have a nested structure.
505
+ if (baseDir != null && !String.Equals(Path.GetDirectoryName(baseDir), fileDir, StringComparison.OrdinalIgnoreCase)
506
+ && this.GenerateType != GenerateType.Container && this.GenerateType != GenerateType.PackageGroup && this.GenerateType != GenerateType.PayloadGroup)
507
+ {
508
+ Uri baseUri = new Uri(baseDir);
509
+ Uri relativeUri = baseUri.MakeRelativeUri(new Uri(fileDir));
510
+ parentDir = this.GetSubDirElement(parentDir, relativeUri);
511
+ }
512
+
513
+ string parentDirId = null;
514
+
515
+ if (parentDir is Wix.DirectoryRef)
516
+ {
517
+ parentDirId = this.directoryRefSeed;
518
+ }
519
+ else if (parentDir is Wix.Directory)
520
+ {
521
+ parentDirId = ((Wix.Directory)parentDir).Id;
522
+ }
523
+
524
+ if (this.GenerateType == GenerateType.Container || this.GenerateType == GenerateType.PayloadGroup)
525
+ {
526
+ Wix.Payload payload = new Wix.Payload();
527
+
528
+ this.HarvestProjectOutputGroupPayloadFile(baseDir, projectName, pogName, pogFileSource, filePath, fileName, link, parentDir, payload, seenList);
529
+ }
530
+ else if (this.GenerateType == GenerateType.PackageGroup)
531
+ {
532
+ this.HarvestProjectOutputGroupPackage(projectName, pogName, pogFileSource, filePath, fileName, link, parentDir, seenList);
533
+ }
534
+ else
535
+ {
536
+ Wix.Component component = new Wix.Component();
537
+ Wix.File file = new Wix.File();
538
+
539
+ this.HarvestProjectOutputGroupFile(baseDir, projectName, pogName, pogFileSource, filePath, fileName, link, parentDir, parentDirId, component, file, seenList);
540
+
541
+ if (String.Equals(Path.GetExtension(file.Source), ".exe", StringComparison.OrdinalIgnoreCase))
542
+ {
543
+ exeFile = file;
544
+ }
545
+ else if (String.Equals(Path.GetExtension(file.Source), ".dll", StringComparison.OrdinalIgnoreCase))
546
+ {
547
+ dllFile = file;
548
+ }
549
+ else if (file.Source.EndsWith("app.config", StringComparison.OrdinalIgnoreCase))
550
+ {
551
+ appConfigFile = file;
552
+ }
553
+ }
554
+
555
+ fileCount++;
556
+ }
557
+
558
+ // if there was no exe file found fallback on the dll file found
559
+ if (exeFile == null && dllFile != null)
560
+ {
561
+ exeFile = dllFile;
562
+ }
563
+
564
+ // Special case for the app.config file in the Binaries POG...
565
+ // The POG refers to the files in the OBJ directory, while the
566
+ // generated WiX code references them in the bin directory.
567
+ // The app.config file gets renamed to match the exe name.
568
+ if ("Binaries" == pogName && null != exeFile && null != appConfigFile)
569
+ {
570
+ if (appConfigFile is Wix.File)
571
+ {
572
+ Wix.File appConfigFileAsWixFile = appConfigFile as Wix.File;
573
+ Wix.File exeFileAsWixFile = exeFile as Wix.File;
574
+ // Case insensitive replace
575
+ appConfigFileAsWixFile.Source = Regex.Replace(appConfigFileAsWixFile.Source, @"app\.config", Path.GetFileName(exeFileAsWixFile.Source) + ".config", RegexOptions.IgnoreCase);
576
+ }
577
+ }
578
+
579
+ return fileCount;
580
+ }
581
+
582
+ private void HarvestProjectOutputGroupFile(string baseDir, string projectName, string pogName, string pogFileSource, string filePath, string fileName, string link, Wix.IParentElement parentDir, string parentDirId, Wix.Component component, Wix.File file, Dictionary<string, bool> seenList)
583
+ {
584
+ string varFormat = VariableFormat;
585
+ if (this.generateWixVars)
586
+ {
587
+ varFormat = WixVariableFormat;
588
+ }
589
+
590
+ if (pogName.Equals("Satellites", StringComparison.OrdinalIgnoreCase))
591
+ {
592
+ Wix.Directory locDirectory = new Wix.Directory();
593
+
594
+ locDirectory.Name = Path.GetFileName(Path.GetDirectoryName(Path.GetFullPath(filePath)));
595
+ file.Source = String.Concat(String.Format(CultureInfo.InvariantCulture, varFormat, projectName, pogFileSource), "\\", locDirectory.Name, "\\", Path.GetFileName(filePath));
596
+
597
+ if (!seenList.ContainsKey(file.Source))
598
+ {
599
+ parentDir.AddChild(locDirectory);
600
+ locDirectory.AddChild(component);
601
+ component.AddChild(file);
602
+ seenList.Add(file.Source, true);
603
+
604
+ if (this.setUniqueIdentifiers)
605
+ {
606
+ locDirectory.Id = this.Core.GenerateIdentifier(DirectoryPrefix, parentDirId, locDirectory.Name);
607
+ file.Id = this.Core.GenerateIdentifier(FilePrefix, locDirectory.Id, fileName);
608
+ component.Id = this.Core.GenerateIdentifier(ComponentPrefix, locDirectory.Id, file.Id);
609
+ }
610
+ else
611
+ {
612
+ locDirectory.Id = this.Core.CreateIdentifierFromFilename(String.Format(DirectoryIdFormat, (parentDir is Wix.DirectoryRef) ? ((Wix.DirectoryRef)parentDir).Id : parentDirId, locDirectory.Name));
613
+ file.Id = this.Core.CreateIdentifierFromFilename(String.Format(CultureInfo.InvariantCulture, VSProjectHarvester.FileIdFormat, projectName, pogName, String.Concat(locDirectory.Name, ".", fileName)));
614
+ component.Id = this.Core.CreateIdentifierFromFilename(String.Format(CultureInfo.InvariantCulture, VSProjectHarvester.ComponentIdFormat, projectName, pogName, String.Concat(locDirectory.Name, ".", fileName)));
615
+ }
616
+ }
617
+ }
618
+ else
619
+ {
620
+ file.Source = GenerateSourceFilePath(baseDir, projectName, pogFileSource, filePath, link, varFormat);
621
+
622
+ if (!seenList.ContainsKey(file.Source))
623
+ {
624
+ component.AddChild(file);
625
+ parentDir.AddChild(component);
626
+ seenList.Add(file.Source, true);
627
+
628
+ if (this.setUniqueIdentifiers)
629
+ {
630
+ file.Id = this.Core.GenerateIdentifier(FilePrefix, parentDirId, fileName);
631
+ component.Id = this.Core.GenerateIdentifier(ComponentPrefix, parentDirId, file.Id);
632
+ }
633
+ else
634
+ {
635
+ file.Id = this.Core.CreateIdentifierFromFilename(String.Format(CultureInfo.InvariantCulture, VSProjectHarvester.FileIdFormat, projectName, pogName, fileName));
636
+ component.Id = this.Core.CreateIdentifierFromFilename(String.Format(CultureInfo.InvariantCulture, VSProjectHarvester.ComponentIdFormat, projectName, pogName, fileName));
637
+ }
638
+ }
639
+ }
640
+ }
641
+
642
+ private void HarvestProjectOutputGroupPackage(string projectName, string pogName, string pogFileSource, string filePath, string fileName, string link, Wix.IParentElement parentDir, Dictionary<string, bool> seenList)
643
+ {
644
+ string varFormat = VariableFormat;
645
+ if (this.generateWixVars)
646
+ {
647
+ varFormat = WixVariableFormat;
648
+ }
649
+
650
+ if (pogName.Equals("Binaries", StringComparison.OrdinalIgnoreCase))
651
+ {
652
+ if (String.Equals(Path.GetExtension(filePath), ".exe", StringComparison.OrdinalIgnoreCase))
653
+ {
654
+ Wix.ExePackage exePackage = new Wix.ExePackage();
655
+ exePackage.SourceFile = String.Concat(String.Format(CultureInfo.InvariantCulture, varFormat, projectName, pogFileSource), "\\", Path.GetFileName(filePath));
656
+ if (!seenList.ContainsKey(exePackage.SourceFile))
657
+ {
658
+ parentDir.AddChild(exePackage);
659
+ seenList.Add(exePackage.SourceFile, true);
660
+ }
661
+ }
662
+ else if (String.Equals(Path.GetExtension(filePath), ".msi", StringComparison.OrdinalIgnoreCase))
663
+ {
664
+ Wix.MsiPackage msiPackage = new Wix.MsiPackage();
665
+ msiPackage.SourceFile = String.Concat(String.Format(CultureInfo.InvariantCulture, varFormat, projectName, pogFileSource), "\\", Path.GetFileName(filePath));
666
+ if (!seenList.ContainsKey(msiPackage.SourceFile))
667
+ {
668
+ parentDir.AddChild(msiPackage);
669
+ seenList.Add(msiPackage.SourceFile, true);
670
+ }
671
+ }
672
+ }
673
+ }
674
+
675
+ private void HarvestProjectOutputGroupPayloadFile(string baseDir, string projectName, string pogName, string pogFileSource, string filePath, string fileName, string link, Wix.IParentElement parentDir, Wix.Payload file, Dictionary<string, bool> seenList)
676
+ {
677
+ string varFormat = VariableFormat;
678
+ if (this.generateWixVars)
679
+ {
680
+ varFormat = WixVariableFormat;
681
+ }
682
+
683
+ if (pogName.Equals("Satellites", StringComparison.OrdinalIgnoreCase))
684
+ {
685
+ string locDirectoryName = Path.GetFileName(Path.GetDirectoryName(Path.GetFullPath(filePath)));
686
+ file.SourceFile = String.Concat(String.Format(CultureInfo.InvariantCulture, varFormat, projectName, pogFileSource), "\\", locDirectoryName, "\\", Path.GetFileName(filePath));
687
+
688
+ if (!seenList.ContainsKey(file.SourceFile))
689
+ {
690
+ parentDir.AddChild(file);
691
+ seenList.Add(file.SourceFile, true);
692
+ }
693
+ }
694
+ else
695
+ {
696
+ file.SourceFile = GenerateSourceFilePath(baseDir, projectName, pogFileSource, filePath, link, varFormat);
697
+
698
+ if (!seenList.ContainsKey(file.SourceFile))
699
+ {
700
+ parentDir.AddChild(file);
701
+ seenList.Add(file.SourceFile, true);
702
+ }
703
+ }
704
+ }
705
+
706
+ /// <summary>
707
+ /// Helper function to generates a source file path when harvesting files.
708
+ /// </summary>
709
+ /// <param name="baseDir"></param>
710
+ /// <param name="projectName"></param>
711
+ /// <param name="pogFileSource"></param>
712
+ /// <param name="filePath"></param>
713
+ /// <param name="link"></param>
714
+ /// <param name="varFormat"></param>
715
+ /// <returns></returns>
716
+ private static string GenerateSourceFilePath(string baseDir, string projectName, string pogFileSource, string filePath, string link, string varFormat)
717
+ {
718
+ string ret;
719
+
720
+ if (null == baseDir && !String.IsNullOrEmpty(link))
721
+ {
722
+ // This needs to be the absolute path as a link can be located anywhere.
723
+ ret = filePath;
724
+ }
725
+ else if (null == baseDir)
726
+ {
727
+ ret = String.Concat(String.Format(CultureInfo.InvariantCulture, varFormat, projectName, pogFileSource), "\\", Path.GetFileName(filePath));
728
+ }
729
+ else if (filePath.StartsWith(baseDir, StringComparison.OrdinalIgnoreCase))
730
+ {
731
+ ret = String.Concat(String.Format(CultureInfo.InvariantCulture, varFormat, projectName, pogFileSource), "\\", filePath.Substring(baseDir.Length));
732
+ }
733
+ else
734
+ {
735
+ // come up with a relative path to the file
736
+ Uri sourcePathUri = new Uri(filePath);
737
+ Uri baseDirUri = new Uri(baseDir);
738
+ Uri sourceRelativeUri = baseDirUri.MakeRelativeUri(sourcePathUri);
739
+ string relativePath = sourceRelativeUri.ToString().Replace('/', Path.DirectorySeparatorChar);
740
+ if (!sourceRelativeUri.UserEscaped)
741
+ {
742
+ relativePath = Uri.UnescapeDataString(relativePath);
743
+ }
744
+
745
+ ret = String.Concat(String.Format(CultureInfo.InvariantCulture, varFormat, projectName, pogFileSource), "\\", relativePath);
746
+ }
747
+
748
+ return ret;
749
+ }
750
+
751
+ /// <summary>
752
+ /// Gets a Directory element corresponding to a relative subdirectory within the project,
753
+ /// either by locating a suitable existing Directory or creating a new one.
754
+ /// </summary>
755
+ /// <param name="parentDir">The parent element which the subdirectory is relative to.</param>
756
+ /// <param name="relativeUri">Relative path of the subdirectory.</param>
757
+ /// <returns>Directory element for the relative path.</returns>
758
+ private Wix.IParentElement GetSubDirElement(Wix.IParentElement parentDir, Uri relativeUri)
759
+ {
760
+ string[] segments = relativeUri.ToString().Split('\\', '/');
761
+ string firstSubDirName = Uri.UnescapeDataString(segments[0]);
762
+ DirectoryAttributeAccessor subDir = null;
763
+
764
+ if (String.Equals(firstSubDirName, "..", StringComparison.Ordinal))
765
+ {
766
+ return parentDir;
767
+ }
768
+
769
+ Type directoryType;
770
+ Type directoryRefType;
771
+ if (parentDir is Wix.Directory || parentDir is Wix.DirectoryRef)
772
+ {
773
+ directoryType = typeof(Wix.Directory);
774
+ directoryRefType = typeof(Wix.DirectoryRef);
775
+ }
776
+ else
777
+ {
778
+ throw new ArgumentException("GetSubDirElement parentDir");
779
+ }
780
+
781
+ // Search for an existing directory element.
782
+ foreach (Wix.ISchemaElement childElement in parentDir.Children)
783
+ {
784
+ if(VSProjectHarvester.AreTypesEquivalent(childElement.GetType(), directoryType))
785
+ {
786
+ DirectoryAttributeAccessor childDir = new DirectoryAttributeAccessor(childElement);
787
+ if (String.Equals(childDir.Name, firstSubDirName, StringComparison.OrdinalIgnoreCase))
788
+ {
789
+ subDir = childDir;
790
+ break;
791
+ }
792
+ }
793
+ }
794
+
795
+ if (subDir == null)
796
+ {
797
+ string parentId = null;
798
+ DirectoryAttributeAccessor parentDirectory = null;
799
+ DirectoryAttributeAccessor parentDirectoryRef = null;
800
+
801
+ if (VSProjectHarvester.AreTypesEquivalent(parentDir.GetType(), directoryType))
802
+ {
803
+ parentDirectory = new DirectoryAttributeAccessor((Wix.ISchemaElement)parentDir);
804
+ }
805
+ else if (VSProjectHarvester.AreTypesEquivalent(parentDir.GetType(), directoryRefType))
806
+ {
807
+ parentDirectoryRef = new DirectoryAttributeAccessor((Wix.ISchemaElement)parentDir);
808
+ }
809
+
810
+ if (parentDirectory != null)
811
+ {
812
+ parentId = parentDirectory.Id;
813
+ }
814
+ else if (parentDirectoryRef != null)
815
+ {
816
+ if (this.setUniqueIdentifiers)
817
+ {
818
+ //Use the GUID of the project instead of the project name to help keep things stable.
819
+ parentId = this.directoryRefSeed;
820
+ }
821
+ else
822
+ {
823
+ parentId = parentDirectoryRef.Id;
824
+ }
825
+ }
826
+
827
+ Wix.ISchemaElement newDirectory = (Wix.ISchemaElement)directoryType.GetConstructor(new Type[] { }).Invoke(null);
828
+ subDir = new DirectoryAttributeAccessor(newDirectory);
829
+
830
+ if (this.setUniqueIdentifiers)
831
+ {
832
+ subDir.Id = this.Core.GenerateIdentifier(DirectoryPrefix, parentId, firstSubDirName);
833
+ }
834
+ else
835
+ {
836
+ subDir.Id = String.Format(DirectoryIdFormat, parentId, firstSubDirName);
837
+ }
838
+
839
+ subDir.Name = firstSubDirName;
840
+
841
+ parentDir.AddChild(subDir.Element);
842
+ }
843
+
844
+ if (segments.Length == 1)
845
+ {
846
+ return subDir.ElementAsParent;
847
+ }
848
+ else
849
+ {
850
+ Uri nextRelativeUri = new Uri(Uri.UnescapeDataString(relativeUri.ToString()).Substring(firstSubDirName.Length + 1), UriKind.Relative);
851
+ return this.GetSubDirElement(subDir.ElementAsParent, nextRelativeUri);
852
+ }
853
+ }
854
+
855
+ private MSBuildProject GetMsbuildProject(string projectFile)
856
+ {
857
+ XmlDocument document = new XmlDocument();
858
+ try
859
+ {
860
+ document.Load(projectFile);
861
+ }
862
+ catch (Exception e)
863
+ {
864
+ throw new WixException(HarvesterErrors.CannotLoadProject(projectFile, e.Message));
865
+ }
866
+
867
+ string version = null;
868
+
869
+ if (this.UseToolsVersion)
870
+ {
871
+ foreach (XmlNode child in document.ChildNodes)
872
+ {
873
+ if (String.Equals(child.Name, "Project", StringComparison.Ordinal) && child.Attributes != null)
874
+ {
875
+ XmlNode toolsVersionAttribute = child.Attributes["ToolsVersion"];
876
+ if (toolsVersionAttribute != null)
877
+ {
878
+ version = toolsVersionAttribute.Value;
879
+ this.Core.Messaging.Write(HarvesterVerboses.FoundToolsVersion(version));
880
+
881
+ break;
882
+ }
883
+ }
884
+ }
885
+
886
+ switch (version)
887
+ {
888
+ case "4.0":
889
+ version = "4.0.0.0";
890
+ break;
891
+ case "12.0":
892
+ version = "12.0.0.0";
893
+ break;
894
+ case "14.0":
895
+ version = "14.0.0.0";
896
+ break;
897
+ default:
898
+ if (String.IsNullOrEmpty(this.MsbuildBinPath))
899
+ {
900
+ throw new WixException(HarvesterErrors.MsbuildBinPathRequired(version ?? "(none)"));
901
+ }
902
+
903
+ version = null;
904
+ break;
905
+ }
906
+ }
907
+
908
+ var project = this.ConstructMsbuild40Project(version);
909
+ return project;
910
+ }
911
+
912
+ private Assembly ResolveFromMsbuildBinPath(object sender, ResolveEventArgs args)
913
+ {
914
+ var assemblyName = new AssemblyName(args.Name);
915
+
916
+ var assemblyPath = Path.Combine(this.MsbuildBinPath, $"{assemblyName.Name}.dll");
917
+ if (!File.Exists(assemblyPath))
918
+ {
919
+ return null;
920
+ }
921
+
922
+ return Assembly.LoadFrom(assemblyPath);
923
+ }
924
+
925
+ private MSBuildProject ConstructMsbuild40Project(string loadVersion)
926
+ {
927
+ const string MSBuildEngineAssemblyName = "Microsoft.Build, Version={0}, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
928
+ const string MSBuildFrameworkAssemblyName = "Microsoft.Build.Framework, Version={0}, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
929
+ Assembly msbuildAssembly;
930
+ Assembly msbuildFrameworkAssembly;
931
+
932
+ if (loadVersion == null)
933
+ {
934
+ this.Core.Messaging.Write(HarvesterVerboses.LoadingProjectWithBinPath(this.MsbuildBinPath));
935
+ AppDomain.CurrentDomain.AssemblyResolve += this.ResolveFromMsbuildBinPath;
936
+
937
+ try
938
+ {
939
+ msbuildAssembly = Assembly.Load("Microsoft.Build");
940
+ }
941
+ catch (Exception e)
942
+ {
943
+ throw new WixException(HarvesterErrors.CannotLoadMSBuildAssembly(e.Message));
944
+ }
945
+
946
+ try
947
+ {
948
+ msbuildFrameworkAssembly = Assembly.Load("Microsoft.Build.Framework");
949
+ }
950
+ catch (Exception e)
951
+ {
952
+ throw new WixException(HarvesterErrors.CannotLoadMSBuildAssembly(e.Message));
953
+ }
954
+ }
955
+ else
956
+ {
957
+ this.Core.Messaging.Write(HarvesterVerboses.LoadingProjectWithVersion(loadVersion));
958
+
959
+ try
960
+ {
961
+ msbuildAssembly = Assembly.Load(String.Format(MSBuildEngineAssemblyName, loadVersion));
962
+ }
963
+ catch (Exception e)
964
+ {
965
+ throw new WixException(HarvesterErrors.CannotLoadMSBuildAssembly(e.Message));
966
+ }
967
+
968
+ try
969
+ {
970
+ msbuildFrameworkAssembly = Assembly.Load(String.Format(MSBuildFrameworkAssemblyName, loadVersion));
971
+ }
972
+ catch (Exception e)
973
+ {
974
+ throw new WixException(HarvesterErrors.CannotLoadMSBuildAssembly(e.Message));
975
+ }
976
+ }
977
+
978
+ Type projectType;
979
+ Type buildItemType;
980
+
981
+ Type buildManagerType;
982
+ Type buildParametersType;
983
+ Type buildRequestDataFlagsType;
984
+ Type buildRequestDataType;
985
+ Type hostServicesType;
986
+ Type projectCollectionType;
987
+ Type projectInstanceType;
988
+
989
+ Type writeHandlerType;
990
+ Type colorSetterType;
991
+ Type colorResetterType;
992
+ Type loggerVerbosityType;
993
+ Type consoleLoggerType;
994
+ Type iLoggerType;
995
+
996
+ try
997
+ {
998
+ buildItemType = msbuildAssembly.GetType("Microsoft.Build.Execution.ProjectItemInstance", true);
999
+ projectType = msbuildAssembly.GetType("Microsoft.Build.Evaluation.Project", true);
1000
+
1001
+ buildManagerType = msbuildAssembly.GetType("Microsoft.Build.Execution.BuildManager", true);
1002
+ buildParametersType = msbuildAssembly.GetType("Microsoft.Build.Execution.BuildParameters", true);
1003
+ buildRequestDataFlagsType = msbuildAssembly.GetType("Microsoft.Build.Execution.BuildRequestDataFlags", true);
1004
+ buildRequestDataType = msbuildAssembly.GetType("Microsoft.Build.Execution.BuildRequestData", true);
1005
+ hostServicesType = msbuildAssembly.GetType("Microsoft.Build.Execution.HostServices", true);
1006
+ projectCollectionType = msbuildAssembly.GetType("Microsoft.Build.Evaluation.ProjectCollection", true);
1007
+ projectInstanceType = msbuildAssembly.GetType("Microsoft.Build.Execution.ProjectInstance", true);
1008
+
1009
+ writeHandlerType = msbuildAssembly.GetType("Microsoft.Build.Logging.WriteHandler", true);
1010
+ colorSetterType = msbuildAssembly.GetType("Microsoft.Build.Logging.ColorSetter", true);
1011
+ colorResetterType = msbuildAssembly.GetType("Microsoft.Build.Logging.ColorResetter", true);
1012
+ loggerVerbosityType = msbuildFrameworkAssembly.GetType("Microsoft.Build.Framework.LoggerVerbosity", true);
1013
+ consoleLoggerType = msbuildAssembly.GetType("Microsoft.Build.Logging.ConsoleLogger", true);
1014
+ iLoggerType = msbuildFrameworkAssembly.GetType("Microsoft.Build.Framework.ILogger", true);
1015
+ }
1016
+ catch (TargetInvocationException tie)
1017
+ {
1018
+ throw new WixException(HarvesterErrors.CannotLoadMSBuildEngine(tie.InnerException.Message));
1019
+ }
1020
+ catch (Exception e)
1021
+ {
1022
+ throw new WixException(HarvesterErrors.CannotLoadMSBuildEngine(e.Message));
1023
+ }
1024
+
1025
+ MSBuild40Types types = new MSBuild40Types();
1026
+ types.buildManagerType = buildManagerType;
1027
+ types.buildParametersType = buildParametersType;
1028
+ types.buildRequestDataFlagsType = buildRequestDataFlagsType;
1029
+ types.buildRequestDataType = buildRequestDataType;
1030
+ types.hostServicesType = hostServicesType;
1031
+ types.projectCollectionType = projectCollectionType;
1032
+ types.projectInstanceType = projectInstanceType;
1033
+ types.writeHandlerType = writeHandlerType;
1034
+ types.colorSetterType = colorSetterType;
1035
+ types.colorResetterType = colorResetterType;
1036
+ types.loggerVerbosityType = loggerVerbosityType;
1037
+ types.consoleLoggerType = consoleLoggerType;
1038
+ types.iLoggerType = iLoggerType;
1039
+ return new MSBuild40Project(null, projectType, buildItemType, loadVersion, types, this.Core, this.configuration, this.platform);
1040
+ }
1041
+
1042
+ private static bool AreTypesEquivalent(Type a, Type b)
1043
+ {
1044
+ return (a == b) || (a.IsAssignableFrom(b) && b.IsAssignableFrom(a));
1045
+ }
1046
+
1047
+ private abstract class MSBuildProject
1048
+ {
1049
+ protected Type projectType;
1050
+ protected Type buildItemType;
1051
+ protected object project;
1052
+ private string loadVersion;
1053
+
1054
+ public MSBuildProject(object project, Type projectType, Type buildItemType, string loadVersion)
1055
+ {
1056
+ this.project = project;
1057
+ this.projectType = projectType;
1058
+ this.buildItemType = buildItemType;
1059
+ this.loadVersion = loadVersion;
1060
+ }
1061
+
1062
+ public string LoadVersion
1063
+ {
1064
+ get { return this.loadVersion; }
1065
+ }
1066
+
1067
+ public abstract bool Build(string projectFileName, string[] targetNames, IDictionary targetOutputs);
1068
+
1069
+ public abstract MSBuildProjectItemType GetBuildItem(object buildItem);
1070
+
1071
+ public abstract IEnumerable GetEvaluatedItemsByName(string itemName);
1072
+
1073
+ public abstract string GetEvaluatedProperty(string propertyName);
1074
+
1075
+ public abstract void Load(string projectFileName);
1076
+ }
1077
+
1078
+ private abstract class MSBuildProjectItemType
1079
+ {
1080
+ public MSBuildProjectItemType(object buildItem)
1081
+ {
1082
+ this.buildItem = buildItem;
1083
+ }
1084
+
1085
+ public abstract override string ToString();
1086
+
1087
+ public abstract string GetMetadata(string name);
1088
+
1089
+ protected object buildItem;
1090
+ }
1091
+
1092
+
1093
+ private struct MSBuild40Types
1094
+ {
1095
+ public Type buildManagerType;
1096
+ public Type buildParametersType;
1097
+ public Type buildRequestDataFlagsType;
1098
+ public Type buildRequestDataType;
1099
+ public Type hostServicesType;
1100
+ public Type projectCollectionType;
1101
+ public Type projectInstanceType;
1102
+ public Type writeHandlerType;
1103
+ public Type colorSetterType;
1104
+ public Type colorResetterType;
1105
+ public Type loggerVerbosityType;
1106
+ public Type consoleLoggerType;
1107
+ public Type iLoggerType;
1108
+ }
1109
+
1110
+ private class MSBuild40Project : MSBuildProject
1111
+ {
1112
+ private MSBuild40Types types;
1113
+ private object projectCollection;
1114
+ private object currentProjectInstance;
1115
+ private object buildManager;
1116
+ private object buildParameters;
1117
+ private IHarvesterCore harvesterCore;
1118
+
1119
+ public MSBuild40Project(object project, Type projectType, Type buildItemType, string loadVersion, MSBuild40Types types, IHarvesterCore harvesterCore, string configuration, string platform)
1120
+ : base(project, projectType, buildItemType, loadVersion)
1121
+ {
1122
+ this.types = types;
1123
+ this.harvesterCore = harvesterCore;
1124
+
1125
+ this.buildParameters = this.types.buildParametersType.GetConstructor(new Type[] { }).Invoke(null);
1126
+
1127
+ try
1128
+ {
1129
+ var loggers = this.CreateLoggers();
1130
+
1131
+ // this.buildParameters.Loggers = loggers;
1132
+ this.types.buildParametersType.GetProperty("Loggers").SetValue(this.buildParameters, loggers, null);
1133
+ }
1134
+ catch (TargetInvocationException tie)
1135
+ {
1136
+ if (this.harvesterCore != null)
1137
+ {
1138
+ this.harvesterCore.Messaging.Write(HarvesterWarnings.NoLogger(tie.InnerException.Message));
1139
+ }
1140
+ }
1141
+ catch (Exception e)
1142
+ {
1143
+ if (this.harvesterCore != null)
1144
+ {
1145
+ this.harvesterCore.Messaging.Write(HarvesterWarnings.NoLogger(e.Message));
1146
+ }
1147
+ }
1148
+
1149
+ this.buildManager = this.types.buildManagerType.GetConstructor(new Type[] { }).Invoke(null);
1150
+
1151
+ if (configuration != null || platform != null)
1152
+ {
1153
+ Dictionary<string, string> globalVariables = new Dictionary<string, string>();
1154
+ if (configuration != null)
1155
+ {
1156
+ globalVariables.Add("Configuration", configuration);
1157
+ }
1158
+
1159
+ if (platform != null)
1160
+ {
1161
+ globalVariables.Add("Platform", platform);
1162
+ }
1163
+
1164
+ this.projectCollection = this.types.projectCollectionType.GetConstructor(new Type[] { typeof(IDictionary<string, string>) }).Invoke(new object[] { globalVariables });
1165
+ }
1166
+ else
1167
+ {
1168
+ this.projectCollection = this.types.projectCollectionType.GetConstructor(new Type[] {}).Invoke(null);
1169
+ }
1170
+ }
1171
+
1172
+ private object CreateLoggers()
1173
+ {
1174
+ var logger = new HarvestLogger(this.harvesterCore.Messaging);
1175
+ var loggerVerbosity = Enum.Parse(this.types.loggerVerbosityType, "Minimal");
1176
+ var writeHandler = Delegate.CreateDelegate(this.types.writeHandlerType, logger, nameof(logger.LogMessage));
1177
+ var colorSetter = Delegate.CreateDelegate(this.types.colorSetterType, logger, nameof(logger.SetColor));
1178
+ var colorResetter = Delegate.CreateDelegate(this.types.colorResetterType, logger, nameof(logger.ResetColor));
1179
+
1180
+ var consoleLoggerCtor = this.types.consoleLoggerType.GetConstructor(new Type[] {
1181
+ this.types.loggerVerbosityType,
1182
+ this.types.writeHandlerType,
1183
+ this.types.colorSetterType,
1184
+ this.types.colorResetterType,
1185
+ });
1186
+ var consoleLogger = consoleLoggerCtor.Invoke(new object[] { loggerVerbosity, writeHandler, colorSetter, colorResetter });
1187
+
1188
+ var loggers = Array.CreateInstance(this.types.iLoggerType, 1);
1189
+ loggers.SetValue(consoleLogger, 0);
1190
+
1191
+ return loggers;
1192
+ }
1193
+
1194
+ public override bool Build(string projectFileName, string[] targetNames, IDictionary targetOutputs)
1195
+ {
1196
+ try
1197
+ {
1198
+ // this.buildManager.BeginBuild(this.buildParameters);
1199
+ this.types.buildManagerType.GetMethod("BeginBuild", new Type[] { this.types.buildParametersType }).Invoke(this.buildManager, new object[] { this.buildParameters });
1200
+
1201
+ // buildRequestData = new BuildRequestData(this.currentProjectInstance, targetNames, null, BuildRequestData.BuildRequestDataFlags.ReplaceExistingProjectInstance);
1202
+ ConstructorInfo buildRequestDataCtor = this.types.buildRequestDataType.GetConstructor(
1203
+ new Type[]
1204
+ {
1205
+ this.types.projectInstanceType, typeof(string[]), this.types.hostServicesType, this.types.buildRequestDataFlagsType
1206
+ });
1207
+ object buildRequestDataFlags = this.types.buildRequestDataFlagsType.GetField("ReplaceExistingProjectInstance").GetRawConstantValue();
1208
+ object buildRequestData = buildRequestDataCtor.Invoke(new object[] { this.currentProjectInstance, targetNames, null, buildRequestDataFlags });
1209
+
1210
+ // BuildSubmission submission = this.buildManager.PendBuildRequest(buildRequestData);
1211
+ object submission = this.types.buildManagerType.GetMethod("PendBuildRequest", new Type[] { this.types.buildRequestDataType })
1212
+ .Invoke(this.buildManager, new object[] { buildRequestData });
1213
+
1214
+ // BuildResult buildResult = submission.Execute();
1215
+ object buildResult = submission.GetType().GetMethod("Execute", new Type[] { }).Invoke(submission, null);
1216
+
1217
+ // bool buildSucceeded = buildResult.OverallResult == BuildResult.Success;
1218
+ object overallResult = buildResult.GetType().GetProperty("OverallResult").GetValue(buildResult, null);
1219
+ bool buildSucceeded = String.Equals(overallResult.ToString(), "Success", StringComparison.Ordinal);
1220
+
1221
+ // this.buildManager.EndBuild();
1222
+ this.types.buildManagerType.GetMethod("EndBuild", new Type[] { }).Invoke(this.buildManager, null);
1223
+
1224
+ // fill in empty lists for each target so that heat will look at the item group later
1225
+ foreach (string target in targetNames)
1226
+ {
1227
+ targetOutputs.Add(target, new List<object>());
1228
+ }
1229
+
1230
+ return buildSucceeded;
1231
+ }
1232
+ catch (TargetInvocationException tie)
1233
+ {
1234
+ throw new WixException(HarvesterErrors.CannotBuildProject(projectFileName, tie.InnerException.Message));
1235
+ }
1236
+ catch (Exception e)
1237
+ {
1238
+ throw new WixException(HarvesterErrors.CannotBuildProject(projectFileName, e.Message));
1239
+ }
1240
+ }
1241
+
1242
+ public override MSBuildProjectItemType GetBuildItem(object buildItem)
1243
+ {
1244
+ return new MSBuild40ProjectItemType(buildItem);
1245
+ }
1246
+
1247
+ public override IEnumerable GetEvaluatedItemsByName(string itemName)
1248
+ {
1249
+ MethodInfo getEvaluatedItem = this.types.projectInstanceType.GetMethod("GetItems", new Type[] { typeof(string) });
1250
+ return (IEnumerable)getEvaluatedItem.Invoke(this.currentProjectInstance, new object[] { itemName });
1251
+ }
1252
+
1253
+ public override string GetEvaluatedProperty(string propertyName)
1254
+ {
1255
+ MethodInfo getProperty = this.types.projectInstanceType.GetMethod("GetPropertyValue", new Type[] { typeof(string) });
1256
+ return (string)getProperty.Invoke(this.currentProjectInstance, new object[] { propertyName });
1257
+ }
1258
+
1259
+ public override void Load(string projectFileName)
1260
+ {
1261
+ try
1262
+ {
1263
+ //this.project = this.projectCollection.LoadProject(projectFileName);
1264
+ this.project = this.types.projectCollectionType.GetMethod("LoadProject", new Type[] { typeof(string) }).Invoke(this.projectCollection, new object[] { projectFileName });
1265
+
1266
+ // this.currentProjectInstance = this.project.CreateProjectInstance();
1267
+ MethodInfo createProjectInstanceMethod = this.projectType.GetMethod("CreateProjectInstance", new Type[] { });
1268
+ this.currentProjectInstance = createProjectInstanceMethod.Invoke(this.project, null);
1269
+ }
1270
+ catch (TargetInvocationException tie)
1271
+ {
1272
+ throw new WixException(HarvesterErrors.CannotLoadProject(projectFileName, tie.InnerException.Message));
1273
+ }
1274
+ catch (Exception e)
1275
+ {
1276
+ throw new WixException(HarvesterErrors.CannotLoadProject(projectFileName, e.Message));
1277
+ }
1278
+ }
1279
+ }
1280
+
1281
+ private class MSBuild40ProjectItemType : MSBuildProjectItemType
1282
+ {
1283
+ public MSBuild40ProjectItemType(object buildItem)
1284
+ : base(buildItem)
1285
+ {
1286
+ }
1287
+
1288
+ public override string ToString()
1289
+ {
1290
+ PropertyInfo includeProperty = this.buildItem.GetType().GetProperty("EvaluatedInclude");
1291
+ return (string)includeProperty.GetValue(this.buildItem, null);
1292
+ }
1293
+
1294
+ public override string GetMetadata(string name)
1295
+ {
1296
+ MethodInfo getMetadataMethod = this.buildItem.GetType().GetMethod("GetMetadataValue");
1297
+ if (null != getMetadataMethod)
1298
+ {
1299
+ return (string)getMetadataMethod.Invoke(this.buildItem, new object[] { name });
1300
+ }
1301
+ return string.Empty;
1302
+ }
1303
+ }
1304
+
1305
+ /// <summary>
1306
+ /// Used internally in the VSProjectHarvester class to encapsulate
1307
+ /// the settings for a particular MSBuild "project output group".
1308
+ /// </summary>
1309
+ private struct ProjectOutputGroup
1310
+ {
1311
+ public readonly string Name;
1312
+ public readonly string BuildOutputGroup;
1313
+ public readonly string FileSource;
1314
+
1315
+ /// <summary>
1316
+ /// Creates a new project output group.
1317
+ /// </summary>
1318
+ /// <param name="name">Friendly name used by heat.</param>
1319
+ /// <param name="buildOutputGroup">MSBuild's name of the project output group.</param>
1320
+ /// <param name="fileSource">VS directory token containing the files of the POG.</param>
1321
+ public ProjectOutputGroup(string name, string buildOutputGroup, string fileSource)
1322
+ {
1323
+ this.Name = name;
1324
+ this.BuildOutputGroup = buildOutputGroup;
1325
+ this.FileSource = fileSource;
1326
+ }
1327
+ }
1328
+
1329
+ /// <summary>
1330
+ /// Internal class for getting and setting common attrbiutes on
1331
+ /// directory elements.
1332
+ /// </summary>
1333
+ internal class DirectoryAttributeAccessor
1334
+ {
1335
+ public Wix.ISchemaElement directoryElement;
1336
+
1337
+ public DirectoryAttributeAccessor(Wix.ISchemaElement directoryElement)
1338
+ {
1339
+ this.directoryElement = directoryElement;
1340
+ }
1341
+
1342
+ /// <summary>
1343
+ /// Gets the element as a ISchemaElement.
1344
+ /// </summary>
1345
+ public Wix.ISchemaElement Element
1346
+ {
1347
+ get { return this.directoryElement; }
1348
+ }
1349
+
1350
+ /// <summary>
1351
+ /// Gets the element as a IParentElement.
1352
+ /// </summary>
1353
+ public Wix.IParentElement ElementAsParent
1354
+ {
1355
+ get { return (Wix.IParentElement)this.directoryElement; }
1356
+ }
1357
+
1358
+ /// <summary>
1359
+ /// Gets or sets the Id attrbiute.
1360
+ /// </summary>
1361
+ public string Id
1362
+ {
1363
+ get
1364
+ {
1365
+ if (this.directoryElement is Wix.Directory wixDirectory)
1366
+ {
1367
+ return wixDirectory.Id;
1368
+ }
1369
+ else if (this.directoryElement is Wix.DirectoryRef wixDirectoryRef)
1370
+ {
1371
+ return wixDirectoryRef.Id;
1372
+ }
1373
+ else
1374
+ {
1375
+ throw new WixException(HarvesterErrors.DirectoryAttributeAccessorBadType("Id"));
1376
+ }
1377
+ }
1378
+ set
1379
+ {
1380
+ if (this.directoryElement is Wix.Directory wixDirectory)
1381
+ {
1382
+ wixDirectory.Id = value;
1383
+ }
1384
+ else if (this.directoryElement is Wix.DirectoryRef wixDirectoryRef)
1385
+ {
1386
+ wixDirectoryRef.Id = value;
1387
+ }
1388
+ else
1389
+ {
1390
+ throw new WixException(HarvesterErrors.DirectoryAttributeAccessorBadType("Id"));
1391
+ }
1392
+ }
1393
+ }
1394
+
1395
+ /// <summary>
1396
+ /// Gets or sets the Name attribute.
1397
+ /// </summary>
1398
+ public string Name
1399
+ {
1400
+ get
1401
+ {
1402
+ if (this.directoryElement is Wix.Directory wixDirectory)
1403
+ {
1404
+ return wixDirectory.Name;
1405
+ }
1406
+ else
1407
+ {
1408
+ throw new WixException(HarvesterErrors.DirectoryAttributeAccessorBadType("Name"));
1409
+ }
1410
+ }
1411
+ set
1412
+ {
1413
+ if (this.directoryElement is Wix.Directory wixDirectory)
1414
+ {
1415
+ wixDirectory.Name = value;
1416
+ }
1417
+ else
1418
+ {
1419
+ throw new WixException(HarvesterErrors.DirectoryAttributeAccessorBadType("Name"));
1420
+ }
1421
+ }
1422
+ }
1423
+ }
1424
+
1425
+ internal class HarvestLogger
1426
+ {
1427
+ public HarvestLogger(IMessaging messaging)
1428
+ {
1429
+ this.Color = ConsoleColor.Black;
1430
+ this.Messaging = messaging;
1431
+ }
1432
+
1433
+ private ConsoleColor Color { get; set; }
1434
+ private IMessaging Messaging { get; }
1435
+
1436
+ public void LogMessage(string message)
1437
+ {
1438
+ if (this.Color == ConsoleColor.Red)
1439
+ {
1440
+ this.Messaging.Write(HarvesterErrors.BuildErrorDuringHarvesting(message));
1441
+ }
1442
+ }
1443
+
1444
+ public void SetColor(ConsoleColor color)
1445
+ {
1446
+ this.Color = color;
1447
+ }
1448
+
1449
+ public void ResetColor()
1450
+ {
1451
+ this.Color = ConsoleColor.Black;
1452
+ }
1453
+ }
1454
+ }
1455
+}
src/heat/heat.csproj
+19
-1
@@ -20,13 +20,31 @@
20
<Compile Include="..\wix\ConsoleMessageListener.cs" Link="ConsoleMessageListener.cs" />
21
</ItemGroup>
22
23
+ <ItemGroup>
24
+ <Compile Update="Serialize\WixHarvesterStrings.Designer.cs">
25
+ <DesignTime>True</DesignTime>
26
+ <AutoGen>True</AutoGen>
27
+ <DependentUpon>WixHarvesterStrings.resx</DependentUpon>
28
+ </Compile>
29
+ </ItemGroup>
30
+
31
+ <ItemGroup>
32
+ <EmbeddedResource Update="Serialize\WixHarvesterStrings.resx">
33
+ <Generator>ResXFileCodeGenerator</Generator>
34
+ <LastGenOutput>WixHarvesterStrings.Designer.cs</LastGenOutput>
35
+ </EmbeddedResource>
36
+ </ItemGroup>
37
+
38
<ItemGroup Condition="'$(TargetFramework)'=='net461' and '$(OS)' != 'Windows_NT'">
39
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" PrivateAssets="All" Version="1.0.0" />
40
</ItemGroup>
41
42
<ItemGroup>
43
+ <PackageReference Include="Microsoft.Win32.Registry" Version="4.7.0" />
44
+ <PackageReference Include="System.Diagnostics.PerformanceCounter" Version="4.7.0" />
45
+ <PackageReference Include="System.DirectoryServices" Version="4.7.0" />
46
<PackageReference Include="WixToolset.Core" Version="4.0.*" />
29
- <PackageReference Include="WixToolset.Harvesters" Version="4.0.*" />
47
+ <PackageReference Include="WixToolset.Core.Burn" Version="4.0.*" />
48
</ItemGroup>
49
50
<ItemGroup>
src/test/WixToolsetTest.Heat/HeatRunner.cs
new
+92
@@ -0,0 +1,92 @@
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 WixToolsetTest.Harvesters
4
+{
5
+ using System;
6
+ using System.Collections.Generic;
7
+ using System.Threading;
8
+ using System.Threading.Tasks;
9
+ using WixToolset.Core;
10
+ using WixToolset.Core.Burn;
11
+ using WixToolset.Core.TestPackage;
12
+ using WixToolset.Data;
13
+ using WixToolset.Extensibility.Data;
14
+ using WixToolset.Extensibility.Services;
15
+ using WixToolset.Harvesters;
16
+
17
+ /// <summary>
18
+ /// Utility class to emulate heat.exe.
19
+ /// </summary>
20
+ public static class HeatRunner
21
+ {
22
+ /// <summary>
23
+ /// Emulates calling heat.exe.
24
+ /// </summary>
25
+ /// <param name="args"></param>
26
+ /// <param name="messages"></param>
27
+ /// <param name="warningsAsErrors"></param>
28
+ /// <returns></returns>
29
+ public static int Execute(string[] args, out List<Message> messages, bool warningsAsErrors = true)
30
+ {
31
+ var serviceProvider = WixToolsetServiceProviderFactory.CreateServiceProvider();
32
+ var task = Execute(args, serviceProvider, out messages, warningsAsErrors: warningsAsErrors);
33
+ return task.Result;
34
+ }
35
+
36
+ /// <summary>
37
+ /// Emulates calling wix.exe with standard backends.
38
+ /// This overload always treats warnings as errors.
39
+ /// </summary>
40
+ /// <param name="args"></param>
41
+ /// <returns></returns>
42
+ public static WixRunnerResult Execute(params string[] args)
43
+ {
44
+ return Execute(true, args);
45
+ }
46
+
47
+ /// <summary>
48
+ /// Emulates calling wix.exe with standard backends.
49
+ /// </summary>
50
+ /// <param name="warningsAsErrors"></param>
51
+ /// <param name="args"></param>
52
+ /// <returns></returns>
53
+ public static WixRunnerResult Execute(bool warningsAsErrors, params string[] args)
54
+ {
55
+ var serviceProvider = WixToolsetServiceProviderFactory.CreateServiceProvider();
56
+ var exitCode = Execute(args, serviceProvider, out var messages, warningsAsErrors: warningsAsErrors);
57
+ return new WixRunnerResult { ExitCode = exitCode.Result, Messages = messages.ToArray() };
58
+ }
59
+
60
+ /// <summary>
61
+ /// Emulates calling wix.exe with standard backends.
62
+ /// </summary>
63
+ /// <param name="args"></param>
64
+ /// <param name="coreProvider"></param>
65
+ /// <param name="messages"></param>
66
+ /// <param name="warningsAsErrors"></param>
67
+ /// <returns></returns>
68
+ public static Task<int> Execute(string[] args, IWixToolsetCoreServiceProvider coreProvider, out List<Message> messages, bool warningsAsErrors = true)
69
+ {
70
+ coreProvider.AddBundleBackend();
71
+
72
+ var listener = new TestMessageListener();
73
+
74
+ messages = listener.Messages;
75
+
76
+ var messaging = coreProvider.GetService<IMessaging>();
77
+ messaging.SetListener(listener);
78
+
79
+ if (warningsAsErrors)
80
+ {
81
+ messaging.WarningsAsError = true;
82
+ }
83
+
84
+ var arguments = coreProvider.GetService<ICommandLineArguments>();
85
+ arguments.Populate(args);
86
+
87
+ var commandLine = HeatCommandLineFactory.CreateCommandLine(coreProvider);
88
+ var command = commandLine.ParseStandardCommandLine(arguments);
89
+ return command?.ExecuteAsync(CancellationToken.None) ?? Task.FromResult(1);
90
+ }
91
+ }
92
+}
src/test/WixToolsetTest.Heat/PayloadTests.cs
new
+66
@@ -0,0 +1,66 @@
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 WixToolsetTest.Harvesters
4
+{
5
+ using System;
6
+ using System.IO;
7
+ using WixBuildTools.TestSupport;
8
+ using Xunit;
9
+
10
+ public class PayloadTests
11
+ {
12
+ [Fact]
13
+ public void CanHarvestExePackagePayload()
14
+ {
15
+ var folder = TestData.Get(@"TestData");
16
+
17
+ using (var fs = new DisposableFileSystem())
18
+ {
19
+ var baseFolder = fs.GetFolder();
20
+ var outputFilePath = Path.Combine(baseFolder, "test.wxs");
21
+
22
+ var result = HeatRunner.Execute(new[]
23
+ {
24
+ "exepackagepayload",
25
+ Path.Combine(folder, ".Data", "burn.exe"),
26
+ "-o", outputFilePath,
27
+ });
28
+
29
+ result.AssertSuccess();
30
+
31
+ Assert.True(File.Exists(outputFilePath));
32
+
33
+ var expected = File.ReadAllText(Path.Combine(folder, "Payload", "HarvestedExePackagePayload.wxs")).Replace("\r\n", "\n");
34
+ var actual = File.ReadAllText(outputFilePath).Replace("\r\n", "\n");
35
+ Assert.Equal(expected, actual);
36
+ }
37
+ }
38
+
39
+ [Fact]
40
+ public void CanHarvestMsuPackagePayload()
41
+ {
42
+ var folder = TestData.Get(@"TestData");
43
+
44
+ using (var fs = new DisposableFileSystem())
45
+ {
46
+ var baseFolder = fs.GetFolder();
47
+ var outputFilePath = Path.Combine(baseFolder, "test.wxs");
48
+
49
+ var result = HeatRunner.Execute(new[]
50
+ {
51
+ "msupackagepayload",
52
+ Path.Combine(folder, ".Data", "Windows8.1-KB2937592-x86.msu"),
53
+ "-o", outputFilePath,
54
+ });
55
+
56
+ result.AssertSuccess();
57
+
58
+ Assert.True(File.Exists(outputFilePath));
59
+
60
+ var expected = File.ReadAllText(Path.Combine(folder, "Payload", "HarvestedMsuPackagePayload.wxs")).Replace("\r\n", "\n");
61
+ var actual = File.ReadAllText(outputFilePath).Replace("\r\n", "\n");
62
+ Assert.Equal(expected, actual);
63
+ }
64
+ }
65
+ }
66
+}
src/test/WixToolsetTest.Heat/TestData/.Data/Windows8.1-KB2937592-x86.msu
Binary files /dev/null and b/src/test/WixToolsetTest.Heat/TestData/.Data/Windows8.1-KB2937592-x86.msu differ
src/test/WixToolsetTest.Heat/TestData/.Data/burn.exe
Binary files /dev/null and b/src/test/WixToolsetTest.Heat/TestData/.Data/burn.exe differ
src/test/WixToolsetTest.Heat/TestData/Payload/HarvestedExePackagePayload.wxs
new
+6
@@ -0,0 +1,6 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
3
+ <Fragment>
4
+ <ExePackagePayload Description="WiX Toolset Bootstrapper" Hash="F6E722518AC3AB7E31C70099368D5770788C179AA23226110DCF07319B1E1964E246A1E8AE72E2CF23E0138AFC281BAFDE45969204405E114EB20C8195DA7E5E" ProductName="Windows Installer XML Toolset" Size="463360" Version="3.14.1703.0" />
5
+ </Fragment>
6
+</Wix>
\ No newline at end of file
src/test/WixToolsetTest.Heat/TestData/Payload/HarvestedMsuPackagePayload.wxs
new
+6
@@ -0,0 +1,6 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
3
+ <Fragment>
4
+ <MsuPackagePayload Hash="904ADEA6AB675ACE16483138BF3F5850FD56ACB6E3A13AFA7263ED49C68CCE6CF84D6AAD6F99AAF175A95EE1A56C787C5AD968019056490B1073E7DBB7B9B7BE" Size="309544" />
5
+ </Fragment>
6
+</Wix>
\ No newline at end of file
src/test/WixToolsetTest.Heat/WixToolsetTest.Heat.csproj
new
+28
@@ -0,0 +1,28 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<!-- 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. -->
3
+
4
+<Project Sdk="Microsoft.NET.Sdk">
5
+ <PropertyGroup>
6
+ <TargetFramework>netcoreapp3.1</TargetFramework>
7
+ <IsPackable>false</IsPackable>
8
+ </PropertyGroup>
9
+
10
+ <ItemGroup>
11
+ <Content Include="TestData\**" CopyToOutputDirectory="PreserveNewest" />
12
+ </ItemGroup>
13
+
14
+ <ItemGroup>
15
+ <ProjectReference Include="..\..\heat\heat.csproj" />
16
+ </ItemGroup>
17
+
18
+ <ItemGroup>
19
+ <PackageReference Include="WixBuildTools.TestSupport" Version="4.0.*" />
20
+ <PackageReference Include="WixToolset.Core.TestPackage" Version="4.0.*" />
21
+ </ItemGroup>
22
+
23
+ <ItemGroup>
24
+ <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.1.0" />
25
+ <PackageReference Include="xunit" Version="2.4.1" />
26
+ <PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" PrivateAssets="All" />
27
+ </ItemGroup>
28
+</Project>