refactor: move modeltypes to own folder, move IDs to file of respective type
This commit is contained in:
parent
4c17ee3d89
commit
26c18d2f48
@ -1,26 +0,0 @@
|
|||||||
namespace PluralKit.Core
|
|
||||||
{
|
|
||||||
public readonly struct GroupId: INumericId<GroupId, int>
|
|
||||||
{
|
|
||||||
public int Value { get; }
|
|
||||||
|
|
||||||
public GroupId(int value)
|
|
||||||
{
|
|
||||||
Value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Equals(GroupId other) => Value == other.Value;
|
|
||||||
|
|
||||||
public override bool Equals(object obj) => obj is GroupId other && Equals(other);
|
|
||||||
|
|
||||||
public override int GetHashCode() => Value;
|
|
||||||
|
|
||||||
public static bool operator ==(GroupId left, GroupId right) => left.Equals(right);
|
|
||||||
|
|
||||||
public static bool operator !=(GroupId left, GroupId right) => !left.Equals(right);
|
|
||||||
|
|
||||||
public int CompareTo(GroupId other) => Value.CompareTo(other.Value);
|
|
||||||
|
|
||||||
public override string ToString() => $"Group #{Value}";
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
namespace PluralKit.Core
|
|
||||||
{
|
|
||||||
public readonly struct MemberId: INumericId<MemberId, int>
|
|
||||||
{
|
|
||||||
public int Value { get; }
|
|
||||||
|
|
||||||
public MemberId(int value)
|
|
||||||
{
|
|
||||||
Value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Equals(MemberId other) => Value == other.Value;
|
|
||||||
|
|
||||||
public override bool Equals(object obj) => obj is MemberId other && Equals(other);
|
|
||||||
|
|
||||||
public override int GetHashCode() => Value;
|
|
||||||
|
|
||||||
public static bool operator ==(MemberId left, MemberId right) => left.Equals(right);
|
|
||||||
|
|
||||||
public static bool operator !=(MemberId left, MemberId right) => !left.Equals(right);
|
|
||||||
|
|
||||||
public int CompareTo(MemberId other) => Value.CompareTo(other.Value);
|
|
||||||
|
|
||||||
public override string ToString() => $"Member #{Value}";
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,8 +1,34 @@
|
|||||||
using NodaTime;
|
using NodaTime;
|
||||||
|
|
||||||
#nullable enable
|
|
||||||
|
|
||||||
namespace PluralKit.Core
|
namespace PluralKit.Core
|
||||||
{
|
{
|
||||||
|
public readonly struct GroupId: INumericId<GroupId, int>
|
||||||
|
{
|
||||||
|
public int Value { get; }
|
||||||
|
|
||||||
|
public GroupId(int value)
|
||||||
|
{
|
||||||
|
Value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Equals(GroupId other) => Value == other.Value;
|
||||||
|
|
||||||
|
public override bool Equals(object obj) => obj is GroupId other && Equals(other);
|
||||||
|
|
||||||
|
public override int GetHashCode() => Value;
|
||||||
|
|
||||||
|
public static bool operator ==(GroupId left, GroupId right) => left.Equals(right);
|
||||||
|
|
||||||
|
public static bool operator !=(GroupId left, GroupId right) => !left.Equals(right);
|
||||||
|
|
||||||
|
public int CompareTo(GroupId other) => Value.CompareTo(other.Value);
|
||||||
|
|
||||||
|
public override string ToString() => $"Group #{Value}";
|
||||||
|
}
|
||||||
|
|
||||||
|
#nullable enable
|
||||||
public class PKGroup
|
public class PKGroup
|
||||||
{
|
{
|
||||||
public GroupId Id { get; private set; }
|
public GroupId Id { get; private set; }
|
||||||
|
@ -5,7 +5,33 @@ using Newtonsoft.Json;
|
|||||||
using NodaTime;
|
using NodaTime;
|
||||||
using NodaTime.Text;
|
using NodaTime.Text;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace PluralKit.Core {
|
namespace PluralKit.Core {
|
||||||
|
public readonly struct MemberId: INumericId<MemberId, int>
|
||||||
|
{
|
||||||
|
public int Value { get; }
|
||||||
|
|
||||||
|
public MemberId(int value)
|
||||||
|
{
|
||||||
|
Value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Equals(MemberId other) => Value == other.Value;
|
||||||
|
|
||||||
|
public override bool Equals(object obj) => obj is MemberId other && Equals(other);
|
||||||
|
|
||||||
|
public override int GetHashCode() => Value;
|
||||||
|
|
||||||
|
public static bool operator ==(MemberId left, MemberId right) => left.Equals(right);
|
||||||
|
|
||||||
|
public static bool operator !=(MemberId left, MemberId right) => !left.Equals(right);
|
||||||
|
|
||||||
|
public int CompareTo(MemberId other) => Value.CompareTo(other.Value);
|
||||||
|
|
||||||
|
public override string ToString() => $"Member #{Value}";
|
||||||
|
}
|
||||||
|
|
||||||
public class PKMember
|
public class PKMember
|
||||||
{
|
{
|
||||||
// Dapper *can* figure out mapping to getter-only properties, but this doesn't work
|
// Dapper *can* figure out mapping to getter-only properties, but this doesn't work
|
||||||
|
@ -1,6 +1,33 @@
|
|||||||
using NodaTime;
|
using NodaTime;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace PluralKit.Core {
|
namespace PluralKit.Core {
|
||||||
|
|
||||||
|
public readonly struct SwitchId: INumericId<SwitchId, int>
|
||||||
|
{
|
||||||
|
public int Value { get; }
|
||||||
|
|
||||||
|
public SwitchId(int value)
|
||||||
|
{
|
||||||
|
Value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Equals(SwitchId other) => Value == other.Value;
|
||||||
|
|
||||||
|
public override bool Equals(object obj) => obj is SwitchId other && Equals(other);
|
||||||
|
|
||||||
|
public override int GetHashCode() => Value;
|
||||||
|
|
||||||
|
public static bool operator ==(SwitchId left, SwitchId right) => left.Equals(right);
|
||||||
|
|
||||||
|
public static bool operator !=(SwitchId left, SwitchId right) => !left.Equals(right);
|
||||||
|
|
||||||
|
public int CompareTo(SwitchId other) => Value.CompareTo(other.Value);
|
||||||
|
|
||||||
|
public override string ToString() => $"Switch #{Value}";
|
||||||
|
}
|
||||||
|
|
||||||
public class PKSwitch
|
public class PKSwitch
|
||||||
{
|
{
|
||||||
public SwitchId Id { get; }
|
public SwitchId Id { get; }
|
||||||
|
@ -4,7 +4,34 @@ using Newtonsoft.Json;
|
|||||||
|
|
||||||
using NodaTime;
|
using NodaTime;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace PluralKit.Core {
|
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);
|
||||||
|
|
||||||
|
public override string ToString() => $"System #{Value}";
|
||||||
|
}
|
||||||
|
|
||||||
public class PKSystem
|
public class PKSystem
|
||||||
{
|
{
|
||||||
// Additions here should be mirrored in SystemStore::Save
|
// Additions here should be mirrored in SystemStore::Save
|
||||||
|
@ -1,26 +0,0 @@
|
|||||||
namespace PluralKit.Core
|
|
||||||
{
|
|
||||||
public readonly struct SwitchId: INumericId<SwitchId, int>
|
|
||||||
{
|
|
||||||
public int Value { get; }
|
|
||||||
|
|
||||||
public SwitchId(int value)
|
|
||||||
{
|
|
||||||
Value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Equals(SwitchId other) => Value == other.Value;
|
|
||||||
|
|
||||||
public override bool Equals(object obj) => obj is SwitchId other && Equals(other);
|
|
||||||
|
|
||||||
public override int GetHashCode() => Value;
|
|
||||||
|
|
||||||
public static bool operator ==(SwitchId left, SwitchId right) => left.Equals(right);
|
|
||||||
|
|
||||||
public static bool operator !=(SwitchId left, SwitchId right) => !left.Equals(right);
|
|
||||||
|
|
||||||
public int CompareTo(SwitchId other) => Value.CompareTo(other.Value);
|
|
||||||
|
|
||||||
public override string ToString() => $"Switch #{Value}";
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
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);
|
|
||||||
|
|
||||||
public override string ToString() => $"System #{Value}";
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user