aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Data/Symbol.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/WixToolset.Data/Symbol.cs')
-rw-r--r--src/WixToolset.Data/Symbol.cs89
1 files changed, 89 insertions, 0 deletions
diff --git a/src/WixToolset.Data/Symbol.cs b/src/WixToolset.Data/Symbol.cs
new file mode 100644
index 00000000..a96f9382
--- /dev/null
+++ b/src/WixToolset.Data/Symbol.cs
@@ -0,0 +1,89 @@
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
3namespace WixToolset.Data
4{
5 using System;
6 using System.Collections.Generic;
7 using System.Linq;
8
9 /// <summary>
10 /// Symbol representing a single row in a database.
11 /// </summary>
12 public sealed class Symbol
13 {
14 private HashSet<Symbol> possibleConflictSymbols;
15 private HashSet<Symbol> redundantSymbols;
16
17 /// <summary>
18 /// Creates a symbol for a row.
19 /// </summary>
20 /// <param name="row">Row for the symbol</param>
21 public Symbol(Row row)
22 {
23 this.Row = row;
24 this.Name = String.Concat(this.Row.TableDefinition.Name, ":", this.Row.GetPrimaryKey());
25 }
26
27 /// <summary>
28 /// Gets the accessibility of the symbol which is a direct reflection of the accessibility of the row's accessibility.
29 /// </summary>
30 /// <value>Accessbility of the symbol.</value>
31 public AccessModifier Access { get { return this.Row.Access; } }
32
33 /// <summary>
34 /// Gets the name of the symbol.
35 /// </summary>
36 /// <value>Name of the symbol.</value>
37 public string Name { get; private set; }
38
39 /// <summary>
40 /// Gets the row for this symbol.
41 /// </summary>
42 /// <value>Row for this symbol.</value>
43 public Row Row { get; private set; }
44
45 /// <summary>
46 /// Gets the section for the symbol.
47 /// </summary>
48 /// <value>Section for the symbol.</value>
49 public Section Section { get { return this.Row.Section; } }
50
51 /// <summary>
52 /// Gets any duplicates of this symbol that are possible conflicts.
53 /// </summary>
54 public IEnumerable<Symbol> PossiblyConflictingSymbols { get { return this.possibleConflictSymbols ?? Enumerable.Empty<Symbol>(); } }
55
56 /// <summary>
57 /// Gets any duplicates of this symbol that are redundant.
58 /// </summary>
59 public IEnumerable<Symbol> RedundantSymbols { get { return this.redundantSymbols ?? Enumerable.Empty<Symbol>(); } }
60
61 /// <summary>
62 /// Adds a duplicate symbol that is a possible conflict.
63 /// </summary>
64 /// <param name="symbol">Symbol that is a possible conflict of this symbol.</param>
65 public void AddPossibleConflict(Symbol symbol)
66 {
67 if (null == this.possibleConflictSymbols)
68 {
69 this.possibleConflictSymbols = new HashSet<Symbol>();
70 }
71
72 this.possibleConflictSymbols.Add(symbol);
73 }
74
75 /// <summary>
76 /// Adds a duplicate symbol that is redundant.
77 /// </summary>
78 /// <param name="symbol">Symbol that is redundant of this symbol.</param>
79 public void AddRedundant(Symbol symbol)
80 {
81 if (null == this.redundantSymbols)
82 {
83 this.redundantSymbols = new HashSet<Symbol>();
84 }
85
86 this.redundantSymbols.Add(symbol);
87 }
88 }
89}