You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.3 KiB
55 lines
1.3 KiB
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
|
|
{
|
|
internal class Selector<T> : IEquatable<Selector<T>>
|
|
where T : notnull
|
|
{
|
|
private string _line = "";
|
|
|
|
public string Line {
|
|
get => _line;
|
|
private set
|
|
{
|
|
if (string.IsNullOrEmpty(value))
|
|
_line = "no data";
|
|
else
|
|
_line = value;
|
|
}
|
|
}
|
|
public T Item { get; private set; }
|
|
|
|
public Selector(T item, string line = "")
|
|
{
|
|
Line = line;
|
|
Item = item;
|
|
}
|
|
|
|
public virtual bool Equals(Selector<T>? 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<T>;
|
|
if (item == null) return false;
|
|
return Equals(obj);
|
|
}
|
|
|
|
public override int GetHashCode()
|
|
{
|
|
return Line.GetHashCode();
|
|
}
|
|
}
|
|
}
|