diff options
Diffstat (limited to 'src/WixToolset.Data/IntermediateSymbol.cs')
-rw-r--r-- | src/WixToolset.Data/IntermediateSymbol.cs | 53 |
1 files changed, 49 insertions, 4 deletions
diff --git a/src/WixToolset.Data/IntermediateSymbol.cs b/src/WixToolset.Data/IntermediateSymbol.cs index 408be37c..4be17094 100644 --- a/src/WixToolset.Data/IntermediateSymbol.cs +++ b/src/WixToolset.Data/IntermediateSymbol.cs | |||
@@ -6,15 +6,28 @@ namespace WixToolset.Data | |||
6 | using System.Diagnostics; | 6 | using System.Diagnostics; |
7 | using SimpleJson; | 7 | using SimpleJson; |
8 | 8 | ||
9 | /// <summary> | ||
10 | /// Intermediate symbol. | ||
11 | /// </summary> | ||
9 | [DebuggerDisplay("{DebuggerDisplay,nq}")] | 12 | [DebuggerDisplay("{DebuggerDisplay,nq}")] |
10 | public class IntermediateSymbol | 13 | public class IntermediateSymbol |
11 | { | 14 | { |
12 | private object tags; | 15 | private object tags; |
13 | 16 | ||
17 | /// <summary> | ||
18 | /// Creates an intermediate symbol. | ||
19 | /// </summary> | ||
20 | /// <param name="definition">Symbol definition.</param> | ||
14 | public IntermediateSymbol(IntermediateSymbolDefinition definition) : this(definition, null, null) | 21 | public IntermediateSymbol(IntermediateSymbolDefinition definition) : this(definition, null, null) |
15 | { | 22 | { |
16 | } | 23 | } |
17 | 24 | ||
25 | /// <summary> | ||
26 | /// Creates an intermediate symbol with source line number and identifier. | ||
27 | /// </summary> | ||
28 | /// <param name="definition">Symbol definition.</param> | ||
29 | /// <param name="sourceLineNumber">Source line number.</param> | ||
30 | /// <param name="id">Symbol identifier.</param> | ||
18 | public IntermediateSymbol(IntermediateSymbolDefinition definition, SourceLineNumber sourceLineNumber, Identifier id = null) | 31 | public IntermediateSymbol(IntermediateSymbolDefinition definition, SourceLineNumber sourceLineNumber, Identifier id = null) |
19 | { | 32 | { |
20 | this.Definition = definition; | 33 | this.Definition = definition; |
@@ -23,18 +36,40 @@ namespace WixToolset.Data | |||
23 | this.Id = id; | 36 | this.Id = id; |
24 | } | 37 | } |
25 | 38 | ||
39 | /// <summary> | ||
40 | /// Gets the symbol's definition. | ||
41 | /// </summary> | ||
26 | public IntermediateSymbolDefinition Definition { get; } | 42 | public IntermediateSymbolDefinition Definition { get; } |
27 | 43 | ||
44 | /// <summary> | ||
45 | /// Gets the symbol's fields. | ||
46 | /// </summary> | ||
28 | public IntermediateField[] Fields { get; } | 47 | public IntermediateField[] Fields { get; } |
29 | 48 | ||
30 | public SourceLineNumber SourceLineNumbers { get; set; } | 49 | /// <summary> |
31 | 50 | /// Gets the optional source line number of the symbol. | |
32 | public Identifier Id { get; set; } | 51 | /// </summary> |
33 | 52 | public SourceLineNumber SourceLineNumbers { get; internal set; } | |
53 | |||
54 | /// <summary> | ||
55 | /// Gets the optional identifier for the symbol. | ||
56 | /// </summary> | ||
57 | public Identifier Id { get; internal set; } | ||
58 | |||
59 | /// <summary> | ||
60 | /// Direct access by index to the symbol's fields. | ||
61 | /// </summary> | ||
62 | /// <param name="index">Index of the field to access.</param> | ||
63 | /// <returns>Symbol's field.</returns> | ||
34 | public IntermediateField this[int index] => this.Fields[index]; | 64 | public IntermediateField this[int index] => this.Fields[index]; |
35 | 65 | ||
36 | private string DebuggerDisplay => $"{this.Definition?.Name} {this.Id?.Id}"; | 66 | private string DebuggerDisplay => $"{this.Definition?.Name} {this.Id?.Id}"; |
37 | 67 | ||
68 | /// <summary> | ||
69 | /// Add a custom tag to the symbol. | ||
70 | /// </summary> | ||
71 | /// <param name="add">String tag to add to the symbol.</param> | ||
72 | /// <returns>True if the tag was added; otherwise false if th tag was already present.</returns> | ||
38 | public bool AddTag(string add) | 73 | public bool AddTag(string add) |
39 | { | 74 | { |
40 | if (this.tags == null) | 75 | if (this.tags == null) |
@@ -73,6 +108,11 @@ namespace WixToolset.Data | |||
73 | return true; | 108 | return true; |
74 | } | 109 | } |
75 | 110 | ||
111 | /// <summary> | ||
112 | /// Tests whether a symbol has a tag. | ||
113 | /// </summary> | ||
114 | /// <param name="has">String tag to find.</param> | ||
115 | /// <returns>True if the symbol has the tag; otherwise false.</returns> | ||
76 | public bool HasTag(string has) | 116 | public bool HasTag(string has) |
77 | { | 117 | { |
78 | if (this.tags == null) | 118 | if (this.tags == null) |
@@ -97,6 +137,11 @@ namespace WixToolset.Data | |||
97 | return false; | 137 | return false; |
98 | } | 138 | } |
99 | 139 | ||
140 | /// <summary> | ||
141 | /// Removes a tag from the symbol. | ||
142 | /// </summary> | ||
143 | /// <param name="remove">String tag to remove.</param> | ||
144 | /// <returns>True if the tag was removed; otherwise false if the tag was not present.</returns> | ||
100 | public bool RemoveTag(string remove) | 145 | public bool RemoveTag(string remove) |
101 | { | 146 | { |
102 | if (this.tags is string tag) | 147 | if (this.tags is string tag) |