Innovenergy_trunk/csharp/app/Backend/Model/TreeNode.cs

35 lines
950 B
C#
Raw Normal View History

2023-02-16 12:57:06 +00:00
using SQLite;
namespace Backend.Model;
public abstract class TreeNode
{
[PrimaryKey, AutoIncrement]
public Int64 Id { get; set; }
public String Name { get; set; } = "";
public String Information { get; set; } = ""; // unstructured random info
2023-02-22 13:46:36 +00:00
protected Boolean Equals(TreeNode other)
{
return Id == other.Id && ParentId == other.ParentId;
}
public override Boolean Equals(Object? obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
return obj.GetType() == this.GetType() && Equals((TreeNode)obj);
}
public override Int32 GetHashCode()
{
return HashCode.Combine(Id, ParentId);
}
2023-02-16 12:57:06 +00:00
[Indexed] // parent/child relation
public Int64 ParentId { get; set; }
[Ignore] // not in DB, can be used in typescript as type discriminator
public String Type => GetType().Name;
}