mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-06 22:07:55 +00:00
Migrate to type-safe model ID structs
This commit is contained in:
parent
e5ac5edc35
commit
b9cbd241de
21 changed files with 167 additions and 41 deletions
24
PluralKit.Core/Models/SystemId.cs
Normal file
24
PluralKit.Core/Models/SystemId.cs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
namespace PluralKit.Core
|
||||
{
|
||||
public readonly struct SystemId: INumericId<SystemId, int>
|
||||
{
|
||||
public int Value { get; }
|
||||
|
||||
public SystemId(int value)
|
||||
{
|
||||
Value = value;
|
||||
}
|
||||
|
||||
public bool Equals(SystemId other) => Value == other.Value;
|
||||
|
||||
public override bool Equals(object obj) => obj is SystemId other && Equals(other);
|
||||
|
||||
public override int GetHashCode() => Value;
|
||||
|
||||
public static bool operator ==(SystemId left, SystemId right) => left.Equals(right);
|
||||
|
||||
public static bool operator !=(SystemId left, SystemId right) => !left.Equals(right);
|
||||
|
||||
public int CompareTo(SystemId other) => Value.CompareTo(other.Value);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue