diff options
Diffstat (limited to 'src/WixToolset.Core.Burn/Bind/WixRegistrySearchInfo.cs')
-rw-r--r-- | src/WixToolset.Core.Burn/Bind/WixRegistrySearchInfo.cs | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/src/WixToolset.Core.Burn/Bind/WixRegistrySearchInfo.cs b/src/WixToolset.Core.Burn/Bind/WixRegistrySearchInfo.cs new file mode 100644 index 00000000..e25f25f4 --- /dev/null +++ b/src/WixToolset.Core.Burn/Bind/WixRegistrySearchInfo.cs | |||
@@ -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 WixToolset.Core.Burn | ||
4 | { | ||
5 | using System; | ||
6 | using System.Xml; | ||
7 | using WixToolset.Data; | ||
8 | |||
9 | /// <summary> | ||
10 | /// Utility class for all WixRegistrySearches. | ||
11 | /// </summary> | ||
12 | internal class WixRegistrySearchInfo : WixSearchInfo | ||
13 | { | ||
14 | public WixRegistrySearchInfo(Row row) | ||
15 | : this((string)row[0], (int)row[1], (string)row[2], (string)row[3], (int)row[4]) | ||
16 | { | ||
17 | } | ||
18 | |||
19 | public WixRegistrySearchInfo(string id, int root, string key, string value, int attributes) | ||
20 | : base(id) | ||
21 | { | ||
22 | this.Root = root; | ||
23 | this.Key = key; | ||
24 | this.Value = value; | ||
25 | this.Attributes = (WixRegistrySearchAttributes)attributes; | ||
26 | } | ||
27 | |||
28 | public int Root { get; private set; } | ||
29 | public string Key { get; private set; } | ||
30 | public string Value { get; private set; } | ||
31 | public WixRegistrySearchAttributes Attributes { get; private set; } | ||
32 | |||
33 | /// <summary> | ||
34 | /// Generates Burn manifest and ParameterInfo-style markup for a registry search. | ||
35 | /// </summary> | ||
36 | /// <param name="writer"></param> | ||
37 | public override void WriteXml(XmlTextWriter writer) | ||
38 | { | ||
39 | writer.WriteStartElement("RegistrySearch"); | ||
40 | this.WriteWixSearchAttributes(writer); | ||
41 | |||
42 | switch (this.Root) | ||
43 | { | ||
44 | case Core.Native.MsiInterop.MsidbRegistryRootClassesRoot: | ||
45 | writer.WriteAttributeString("Root", "HKCR"); | ||
46 | break; | ||
47 | case Core.Native.MsiInterop.MsidbRegistryRootCurrentUser: | ||
48 | writer.WriteAttributeString("Root", "HKCU"); | ||
49 | break; | ||
50 | case Core.Native.MsiInterop.MsidbRegistryRootLocalMachine: | ||
51 | writer.WriteAttributeString("Root", "HKLM"); | ||
52 | break; | ||
53 | case Core.Native.MsiInterop.MsidbRegistryRootUsers: | ||
54 | writer.WriteAttributeString("Root", "HKU"); | ||
55 | break; | ||
56 | } | ||
57 | |||
58 | writer.WriteAttributeString("Key", this.Key); | ||
59 | |||
60 | if (!String.IsNullOrEmpty(this.Value)) | ||
61 | { | ||
62 | writer.WriteAttributeString("Value", this.Value); | ||
63 | } | ||
64 | |||
65 | bool existenceOnly = 0 != (this.Attributes & WixRegistrySearchAttributes.WantExists); | ||
66 | |||
67 | writer.WriteAttributeString("Type", existenceOnly ? "exists" : "value"); | ||
68 | |||
69 | if (0 != (this.Attributes & WixRegistrySearchAttributes.Win64)) | ||
70 | { | ||
71 | writer.WriteAttributeString("Win64", "yes"); | ||
72 | } | ||
73 | |||
74 | if (!existenceOnly) | ||
75 | { | ||
76 | if (0 != (this.Attributes & WixRegistrySearchAttributes.ExpandEnvironmentVariables)) | ||
77 | { | ||
78 | writer.WriteAttributeString("ExpandEnvironment", "yes"); | ||
79 | } | ||
80 | |||
81 | // We *always* say this is VariableType="string". If we end up | ||
82 | // needing to be more specific, we will have to expand the "Format" | ||
83 | // attribute to allow "number" and "version". | ||
84 | |||
85 | writer.WriteAttributeString("VariableType", "string"); | ||
86 | } | ||
87 | |||
88 | writer.WriteEndElement(); | ||
89 | } | ||
90 | } | ||
91 | |||
92 | } | ||