Further work on static side
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
using System;
|
||||
|
||||
namespace PkmnLib.Static.Utils;
|
||||
|
||||
/// <summary>
|
||||
@@ -12,24 +10,28 @@ public readonly record struct StringKey
|
||||
{
|
||||
private readonly string _key;
|
||||
|
||||
/// <inheritdoc cref="StringKey"/>
|
||||
public StringKey(string key)
|
||||
{
|
||||
_key = key;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a <see cref="StringKey"/> to a <see cref="string"/>.
|
||||
/// </summary>
|
||||
public static implicit operator string(StringKey key) => key._key;
|
||||
|
||||
/// <summary>
|
||||
/// Converts a <see cref="string"/> to a <see cref="StringKey"/>.
|
||||
/// </summary>
|
||||
public static implicit operator StringKey(string key) => new(key);
|
||||
|
||||
/// <inheritdoc cref="string.ToString()"/>
|
||||
public override string ToString() => _key.ToLowerInvariant();
|
||||
|
||||
public bool Equals(StringKey other)
|
||||
{
|
||||
return string.Equals(_key, other._key, StringComparison.InvariantCultureIgnoreCase);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return StringComparer.InvariantCultureIgnoreCase.GetHashCode(_key);
|
||||
}
|
||||
/// <inheritdoc />
|
||||
public bool Equals(StringKey other) => string.Equals(_key, other._key, StringComparison.InvariantCultureIgnoreCase);
|
||||
|
||||
/// <inheritdoc />
|
||||
public override int GetHashCode() => StringComparer.InvariantCultureIgnoreCase.GetHashCode(_key);
|
||||
}
|
||||
Reference in New Issue
Block a user