Extract ProxyTag to separate file

This commit is contained in:
Ske 2020-06-13 13:18:21 +02:00
parent cb8f29cc47
commit 23c595f675
2 changed files with 34 additions and 30 deletions

View File

@ -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);
}
}
}
}

View 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);
}
}
}
}