| 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.Data |
| 4 | { |
| 5 | using WixToolset.Data.Symbols; |
| 6 | |
| 7 | public static partial class SymbolDefinitions |
| 8 | { |
| 9 | public static readonly IntermediateSymbolDefinition WixRegistrySearch = new IntermediateSymbolDefinition( |
| 10 | SymbolDefinitionType.WixRegistrySearch, |
| 11 | new[] |
| 12 | { |
| 13 | new IntermediateFieldDefinition(nameof(WixRegistrySearchSymbolFields.Root), IntermediateFieldType.Number), |
| 14 | new IntermediateFieldDefinition(nameof(WixRegistrySearchSymbolFields.Key), IntermediateFieldType.String), |
| 15 | new IntermediateFieldDefinition(nameof(WixRegistrySearchSymbolFields.Value), IntermediateFieldType.String), |
| 16 | new IntermediateFieldDefinition(nameof(WixRegistrySearchSymbolFields.Attributes), IntermediateFieldType.Number), |
| 17 | new IntermediateFieldDefinition(nameof(WixRegistrySearchSymbolFields.Type), IntermediateFieldType.Number), |
| 18 | }, |
| 19 | typeof(WixRegistrySearchSymbol)); |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | namespace WixToolset.Data.Symbols |
| 24 | { |
| 25 | using System; |
| 26 | |
| 27 | public enum WixRegistrySearchSymbolFields |
| 28 | { |
| 29 | Root, |
| 30 | Key, |
| 31 | Value, |
| 32 | Attributes, |
| 33 | Type, |
| 34 | } |
| 35 | |
| 36 | [Flags] |
| 37 | public enum WixRegistrySearchAttributes |
| 38 | { |
| 39 | None = 0x0, |
| 40 | ExpandEnvironmentVariables = 0x01, |
| 41 | Win64 = 0x2, |
| 42 | } |
| 43 | |
| 44 | public enum WixRegistrySearchType |
| 45 | { |
| 46 | Value, |
| 47 | Exists, |
| 48 | } |
| 49 | |
| 50 | public class WixRegistrySearchSymbol : IntermediateSymbol |
| 51 | { |
| 52 | public WixRegistrySearchSymbol() : base(SymbolDefinitions.WixRegistrySearch, null, null) |
| 53 | { |
| 54 | } |
| 55 | |
| 56 | public WixRegistrySearchSymbol(SourceLineNumber sourceLineNumber , Identifier id = null) : base(SymbolDefinitions.WixRegistrySearch, sourceLineNumber, id) |
| 57 | { |
| 58 | } |
| 59 | |
| 60 | public IntermediateField this[WixRegistrySearchSymbolFields index] => this.Fields[(int)index]; |
| 61 | |
| 62 | public RegistryRootType Root |
| 63 | { |
| 64 | get => (RegistryRootType)this.Fields[(int)WixRegistrySearchSymbolFields.Root].AsNumber(); |
| 65 | set => this.Set((int)WixRegistrySearchSymbolFields.Root, (int)value); |
| 66 | } |
| 67 | |
| 68 | public string Key |
| 69 | { |
| 70 | get => (string)this.Fields[(int)WixRegistrySearchSymbolFields.Key]; |
| 71 | set => this.Set((int)WixRegistrySearchSymbolFields.Key, value); |
| 72 | } |
| 73 | |
| 74 | public string Value |
| 75 | { |
| 76 | get => (string)this.Fields[(int)WixRegistrySearchSymbolFields.Value]; |
| 77 | set => this.Set((int)WixRegistrySearchSymbolFields.Value, value); |
| 78 | } |
| 79 | |
| 80 | public WixRegistrySearchAttributes Attributes |
| 81 | { |
| 82 | get => (WixRegistrySearchAttributes)this.Fields[(int)WixRegistrySearchSymbolFields.Attributes].AsNumber(); |
| 83 | set => this.Set((int)WixRegistrySearchSymbolFields.Attributes, (int)value); |
| 84 | } |
| 85 | |
| 86 | public WixRegistrySearchType Type |
| 87 | { |
| 88 | get => (WixRegistrySearchType)this.Fields[(int)WixRegistrySearchSymbolFields.Type].AsNumber(); |
| 89 | set => this.Set((int)WixRegistrySearchSymbolFields.Type, (int)value); |
| 90 | } |
| 91 | |
| 92 | public bool ExpandEnvironmentVariables |
| 93 | { |
| 94 | get { return this.Attributes.HasFlag(WixRegistrySearchAttributes.ExpandEnvironmentVariables); } |
| 95 | set |
| 96 | { |
| 97 | if (value) |
| 98 | { |
| 99 | this.Attributes |= WixRegistrySearchAttributes.ExpandEnvironmentVariables; |
| 100 | } |
| 101 | else |
| 102 | { |
| 103 | this.Attributes &= ~WixRegistrySearchAttributes.ExpandEnvironmentVariables; |
| 104 | } |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | public bool Win64 |
| 109 | { |
| 110 | get { return this.Attributes.HasFlag(WixRegistrySearchAttributes.Win64); } |
| 111 | set |
| 112 | { |
| 113 | if (value) |
| 114 | { |
| 115 | this.Attributes |= WixRegistrySearchAttributes.Win64; |
| 116 | } |
| 117 | else |
| 118 | { |
| 119 | this.Attributes &= ~WixRegistrySearchAttributes.Win64; |
| 120 | } |
| 121 | } |
| 122 | } |
| 123 | } |
| 124 | } |