| 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 WixProductSearch = new IntermediateSymbolDefinition( |
| 10 | SymbolDefinitionType.WixProductSearch, |
| 11 | new[] |
| 12 | { |
| 13 | new IntermediateFieldDefinition(nameof(WixProductSearchSymbolFields.Guid), IntermediateFieldType.String), |
| 14 | new IntermediateFieldDefinition(nameof(WixProductSearchSymbolFields.Attributes), IntermediateFieldType.Number), |
| 15 | new IntermediateFieldDefinition(nameof(WixProductSearchSymbolFields.Type), IntermediateFieldType.Number), |
| 16 | }, |
| 17 | typeof(WixProductSearchSymbol)); |
| 18 | } |
| 19 | } |
| 20 | |
| 21 | namespace WixToolset.Data.Symbols |
| 22 | { |
| 23 | using System; |
| 24 | |
| 25 | public enum WixProductSearchSymbolFields |
| 26 | { |
| 27 | Guid, |
| 28 | Attributes, |
| 29 | Type, |
| 30 | } |
| 31 | |
| 32 | [Flags] |
| 33 | public enum WixProductSearchAttributes |
| 34 | { |
| 35 | None = 0x0, |
| 36 | |
| 37 | /// <summary> |
| 38 | /// Guid contains the UpgradeCode. If not set, it contains the ProductCode. |
| 39 | /// </summary> |
| 40 | UpgradeCode = 0x1, |
| 41 | } |
| 42 | |
| 43 | public enum WixProductSearchType |
| 44 | { |
| 45 | Version, |
| 46 | Language, |
| 47 | State, |
| 48 | Assignment, |
| 49 | } |
| 50 | |
| 51 | public class WixProductSearchSymbol : IntermediateSymbol |
| 52 | { |
| 53 | public WixProductSearchSymbol() : base(SymbolDefinitions.WixProductSearch, null, null) |
| 54 | { |
| 55 | } |
| 56 | |
| 57 | public WixProductSearchSymbol(SourceLineNumber sourceLineNumber, Identifier id = null) : base(SymbolDefinitions.WixProductSearch, sourceLineNumber, id) |
| 58 | { |
| 59 | } |
| 60 | |
| 61 | public IntermediateField this[WixProductSearchSymbolFields index] => this.Fields[(int)index]; |
| 62 | |
| 63 | public string Guid |
| 64 | { |
| 65 | get => (string)this.Fields[(int)WixProductSearchSymbolFields.Guid]; |
| 66 | set => this.Set((int)WixProductSearchSymbolFields.Guid, value); |
| 67 | } |
| 68 | |
| 69 | public WixProductSearchAttributes Attributes |
| 70 | { |
| 71 | get => (WixProductSearchAttributes)this.Fields[(int)WixProductSearchSymbolFields.Attributes].AsNumber(); |
| 72 | set => this.Set((int)WixProductSearchSymbolFields.Attributes, (int)value); |
| 73 | } |
| 74 | |
| 75 | public WixProductSearchType Type |
| 76 | { |
| 77 | get => (WixProductSearchType)this.Fields[(int)WixProductSearchSymbolFields.Type].AsNumber(); |
| 78 | set => this.Set((int)WixProductSearchSymbolFields.Type, (int)value); |
| 79 | } |
| 80 | |
| 81 | public bool IsUpgradeCode |
| 82 | { |
| 83 | get { return this.Attributes.HasFlag(WixProductSearchAttributes.UpgradeCode); } |
| 84 | set |
| 85 | { |
| 86 | if (value) |
| 87 | { |
| 88 | this.Attributes |= WixProductSearchAttributes.UpgradeCode; |
| 89 | } |
| 90 | else |
| 91 | { |
| 92 | this.Attributes &= ~WixProductSearchAttributes.UpgradeCode; |
| 93 | } |
| 94 | } |
| 95 | } |
| 96 | } |
| 97 | } |