// 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.Core.Link
{
using System;
using System.Collections.Generic;
using System.Linq;
using WixToolset.Data;
///
/// Symbol with section representing a single unique symbol.
///
internal class SymbolWithSection
{
private HashSet possibleConflicts;
private HashSet redundants;
///
/// Creates a symbol for a symbol.
///
///
/// Symbol for the symbol
public SymbolWithSection(IntermediateSection section, IntermediateSymbol symbol)
{
this.Symbol = symbol;
this.Section = section;
this.Name = String.Concat(this.Symbol.Definition.Name, ":", this.Symbol.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.Symbol.Id.Access;
///
/// Gets the name of the symbol.
///
/// Name of the symbol.
public string Name { get; }
///
/// Gets the symbol for this symbol.
///
/// Symbol for this symbol.
public IntermediateSymbol Symbol { get; }
///
/// Gets the section for the symbol.
///
/// Section for the symbol.
public IntermediateSection Section { get; }
///
/// Gets any duplicates of this symbol with sections that are possible conflicts.
///
public IEnumerable PossiblyConflicts => this.possibleConflicts ?? Enumerable.Empty();
///
/// Gets any duplicates of this symbol with sections that are redundant.
///
public IEnumerable Redundants => this.redundants ?? Enumerable.Empty();
///
/// Adds a duplicate symbol with sections that is a possible conflict.
///
/// Symbol with section that is a possible conflict of this symbol.
public void AddPossibleConflict(SymbolWithSection symbolWithSection)
{
if (null == this.possibleConflicts)
{
this.possibleConflicts = new HashSet();
}
this.possibleConflicts.Add(symbolWithSection);
}
///
/// Adds a duplicate symbol that is redundant.
///
/// Symbol with section that is redundant of this symbol.
public void AddRedundant(SymbolWithSection symbolWithSection)
{
if (null == this.redundants)
{
this.redundants = new HashSet();
}
this.redundants.Add(symbolWithSection);
}
}
}