main
cs 111 lines 3.54 KB
Raw
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 WixBundleVariable = new IntermediateSymbolDefinition(
10 SymbolDefinitionType.WixBundleVariable,
11 new[]
12 {
13 new IntermediateFieldDefinition(nameof(WixBundleVariableSymbolFields.Attributes), IntermediateFieldType.Number),
14 new IntermediateFieldDefinition(nameof(WixBundleVariableSymbolFields.Value), IntermediateFieldType.String),
15 new IntermediateFieldDefinition(nameof(WixBundleVariableSymbolFields.Type), IntermediateFieldType.String),
16 },
17 typeof(WixBundleVariableSymbol));
18 }
19 }
20
21 namespace WixToolset.Data.Symbols
22 {
23 using System;
24
25 public enum WixBundleVariableSymbolFields
26 {
27 Attributes,
28 Value,
29 Type,
30 }
31
32 [Flags]
33 public enum WixBundleVariableAttributes
34 {
35 None = 0x0,
36 Hidden = 0x1,
37 Persisted = 0x2,
38 }
39
40 public enum WixBundleVariableType
41 {
42 Unknown,
43 Formatted,
44 Numeric,
45 String,
46 Version,
47 }
48
49 public class WixBundleVariableSymbol : IntermediateSymbol
50 {
51 public WixBundleVariableSymbol() : base(SymbolDefinitions.WixBundleVariable, null, null)
52 {
53 }
54
55 public WixBundleVariableSymbol(SourceLineNumber sourceLineNumber, Identifier id = null) : base(SymbolDefinitions.WixBundleVariable, sourceLineNumber, id)
56 {
57 }
58
59 public IntermediateField this[WixBundleVariableSymbolFields index] => this.Fields[(int)index];
60
61 public WixBundleVariableAttributes Attributes
62 {
63 get => (WixBundleVariableAttributes)this.Fields[(int)WixBundleVariableSymbolFields.Attributes].AsNumber();
64 set => this.Set((int)WixBundleVariableSymbolFields.Attributes, (int)value);
65 }
66
67 public string Value
68 {
69 get => (string)this.Fields[(int)WixBundleVariableSymbolFields.Value];
70 set => this.Set((int)WixBundleVariableSymbolFields.Value, value);
71 }
72
73 public WixBundleVariableType Type
74 {
75 get => Enum.TryParse((string)this.Fields[(int)WixBundleVariableSymbolFields.Type], true, out WixBundleVariableType value) ? value : WixBundleVariableType.Unknown;
76 set => this.Set((int)WixBundleVariableSymbolFields.Type, value.ToString().ToLowerInvariant());
77 }
78
79 public bool Hidden
80 {
81 get { return this.Attributes.HasFlag(WixBundleVariableAttributes.Hidden); }
82 set
83 {
84 if (value)
85 {
86 this.Attributes |= WixBundleVariableAttributes.Hidden;
87 }
88 else
89 {
90 this.Attributes &= ~WixBundleVariableAttributes.Hidden;
91 }
92 }
93 }
94
95 public bool Persisted
96 {
97 get { return this.Attributes.HasFlag(WixBundleVariableAttributes.Persisted); }
98 set
99 {
100 if (value)
101 {
102 this.Attributes |= WixBundleVariableAttributes.Persisted;
103 }
104 else
105 {
106 this.Attributes &= ~WixBundleVariableAttributes.Persisted;
107 }
108 }
109 }
110 }
111 }