Extract ProxyTag to separate file
This commit is contained in:
parent
cb8f29cc47
commit
23c595f675
@ -46,34 +46,4 @@ namespace PluralKit.Core {
|
||||
return $"{guildDisplayName ?? DisplayName ?? Name} {systemTag}";
|
||||
}
|
||||
}
|
||||
|
||||
public struct ProxyTag
|
||||
{
|
||||
public ProxyTag(string prefix, string suffix)
|
||||
{
|
||||
// Normalize empty strings to null for DB
|
||||
Prefix = prefix?.Length == 0 ? null : prefix;
|
||||
Suffix = suffix?.Length == 0 ? null : suffix;
|
||||
}
|
||||
|
||||
[JsonProperty("prefix")] public string Prefix { get; set; }
|
||||
[JsonProperty("suffix")] public string Suffix { get; set; }
|
||||
|
||||
[JsonIgnore] public string ProxyString => $"{Prefix ?? ""}text{Suffix ?? ""}";
|
||||
|
||||
public bool IsEmpty => Prefix == null && Suffix == null;
|
||||
|
||||
public bool Equals(ProxyTag other) => Prefix == other.Prefix && Suffix == other.Suffix;
|
||||
|
||||
public override bool Equals(object obj) => obj is ProxyTag other && Equals(other);
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
unchecked
|
||||
{
|
||||
return ((Prefix != null ? Prefix.GetHashCode() : 0) * 397) ^
|
||||
(Suffix != null ? Suffix.GetHashCode() : 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
34
PluralKit.Core/Models/ProxyTag.cs
Normal file
34
PluralKit.Core/Models/ProxyTag.cs
Normal file
@ -0,0 +1,34 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace PluralKit.Core
|
||||
{
|
||||
public struct ProxyTag
|
||||
{
|
||||
public ProxyTag(string prefix, string suffix)
|
||||
{
|
||||
// Normalize empty strings to null for DB
|
||||
Prefix = prefix?.Length == 0 ? null : prefix;
|
||||
Suffix = suffix?.Length == 0 ? null : suffix;
|
||||
}
|
||||
|
||||
[JsonProperty("prefix")] public string Prefix { get; set; }
|
||||
[JsonProperty("suffix")] public string Suffix { get; set; }
|
||||
|
||||
[JsonIgnore] public string ProxyString => $"{Prefix ?? ""}text{Suffix ?? ""}";
|
||||
|
||||
public bool IsEmpty => Prefix == null && Suffix == null;
|
||||
|
||||
public bool Equals(ProxyTag other) => Prefix == other.Prefix && Suffix == other.Suffix;
|
||||
|
||||
public override bool Equals(object obj) => obj is ProxyTag other && Equals(other);
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
unchecked
|
||||
{
|
||||
return ((Prefix != null ? Prefix.GetHashCode() : 0) * 397) ^
|
||||
(Suffix != null ? Suffix.GetHashCode() : 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user