Further work on static side

This commit is contained in:
2024-07-20 16:12:39 +02:00
parent 3845f91601
commit 1b501dee7e
29 changed files with 670 additions and 155 deletions

View File

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