// 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.
namespace WixToolset.Data
{
using System;
using System.Collections.Generic;
using System.Linq;
///
/// Symbol representing a single row in a database.
///
public sealed class Symbol
{
private HashSet possibleConflictSymbols;
private HashSet redundantSymbols;
///
/// Creates a symbol for a row.
///
/// Row for the symbol
public Symbol(IntermediateSection section, IntermediateTuple tuple)
{
this.Row = tuple;
this.Section = section;
this.Name = String.Concat(this.Row.Definition.Name, ":", this.Row.Id.Id);
}
///
/// Gets the accessibility of the symbol which is a direct reflection of the accessibility of the row's accessibility.
///
/// Accessbility of the symbol.
public AccessModifier Access => this.Row.Id.Access;
///
/// Gets the name of the symbol.
///
/// Name of the symbol.
public string Name { get; }
///
/// Gets the row for this symbol.
///
/// Row for this symbol.
public IntermediateTuple Row { get; }
///
/// Gets the section for the symbol.
///
/// Section for the symbol.
public IntermediateSection Section { get; }
///
/// Gets any duplicates of this symbol that are possible conflicts.
///
public IEnumerable PossiblyConflictingSymbols { get { return this.possibleConflictSymbols ?? Enumerable.Empty(); } }
///
/// Gets any duplicates of this symbol that are redundant.
///
public IEnumerable RedundantSymbols { get { return this.redundantSymbols ?? Enumerable.Empty(); } }
///
/// Adds a duplicate symbol that is a possible conflict.
///
/// Symbol that is a possible conflict of this symbol.
public void AddPossibleConflict(Symbol symbol)
{
if (null == this.possibleConflictSymbols)
{
this.possibleConflictSymbols = new HashSet();
}
this.possibleConflictSymbols.Add(symbol);
}
///
/// Adds a duplicate symbol that is redundant.
///
/// Symbol that is redundant of this symbol.
public void AddRedundant(Symbol symbol)
{
if (null == this.redundantSymbols)
{
this.redundantSymbols = new HashSet();
}
this.redundantSymbols.Add(symbol);
}
}
}