Innovenergy_trunk/csharp/app/API/DataModel/DataElement.cs

24 lines
705 B
C#

using Newtonsoft.Json;
namespace InnovEnergy.API.DataModel;
public abstract record DataElement : IComparable<DataElement>
{
[JsonProperty(Order = Int32.MinValue + 0)] public String Name { get; set; } = "<no name>";
[JsonProperty(Order = Int32.MinValue + 1)] public String Type { get; set; }
protected DataElement()
{
Type = GetType().Name;
}
public override String ToString() => $"{Type.ToLower()} '{Name}'";
public Int32 CompareTo(DataElement? other)
{
if (ReferenceEquals(this, other)) return 0;
if (ReferenceEquals(null, other)) return 1;
return String.Compare(Name, other.Name, StringComparison.InvariantCultureIgnoreCase);
}
}