using Model; using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Reflection.Emit; using System.Text; using System.Threading.Tasks; namespace ConsoleApp.Menu { /// /// The selector of a menu. /// /// The type of the selector. internal class Selector : IEquatable> where T : notnull { #region Attributes & Properties private string _line = ""; /// /// The string that are displayed on the menu. /// public string Line { get => _line; private set { if (string.IsNullOrEmpty(value)) _line = "no data"; else _line = value; } } /// /// The item contained in the selector. /// public T Item { get; private set; } #endregion #region Constructors /// /// The constructor of the selector. /// /// The item to place inside. /// The string to display in the menu. public Selector(T item, string line = "") { Line = line; Item = item; } #endregion #region IEquatable implementation public virtual bool Equals(Selector? other) { if (other == null) return false; if (other == this) return true; return other.Line.Equals(this.Line); } public override bool Equals(object? obj) { var item = obj as Selector; if (item == null) return false; return Equals(obj); } public override int GetHashCode() { return Line.GetHashCode(); } #endregion } }