58 lines
1.3 KiB
C#
58 lines
1.3 KiB
C#
namespace OwnChar.Data;
|
|
|
|
public class DataManagerAction(string id)
|
|
{
|
|
public DataManagerAction? BaseAction { get; }
|
|
|
|
public string ActionId
|
|
{
|
|
get
|
|
{
|
|
if (BaseAction != null)
|
|
return $"{BaseAction.ActionId}.{id}";
|
|
return id;
|
|
}
|
|
}
|
|
|
|
public DataManagerAction(DataManagerAction baseAction, string id) : this(id)
|
|
{
|
|
BaseAction = baseAction;
|
|
}
|
|
|
|
public static bool operator ==(DataManagerAction? a, DataManagerAction? b)
|
|
{
|
|
if (a is null || b is null)
|
|
return false;
|
|
|
|
if (a.ActionId == b.ActionId)
|
|
return true;
|
|
|
|
if (a.BaseAction != null && a.BaseAction.ActionId == b.ActionId)
|
|
return true;
|
|
|
|
if (b.BaseAction != null && a.ActionId == b.BaseAction.ActionId)
|
|
return true;
|
|
|
|
return false;
|
|
}
|
|
|
|
public static bool operator !=(DataManagerAction? a, DataManagerAction? b)
|
|
{
|
|
return !(a == b);
|
|
}
|
|
|
|
public override bool Equals(object? obj)
|
|
{
|
|
if (ReferenceEquals(this, obj))
|
|
return true;
|
|
if (obj is not DataManagerAction action)
|
|
return false;
|
|
return action == this;
|
|
}
|
|
|
|
public override int GetHashCode()
|
|
{
|
|
return ActionId.GetHashCode();
|
|
}
|
|
}
|