add a bunch of stuff copied from Foxchat.NET

This commit is contained in:
sam 2024-05-28 15:29:18 +02:00
parent f4c0a40259
commit 6114f384a0
Signed by: sam
GPG key ID: B4EF20DDE721CAA1
21 changed files with 1216 additions and 35 deletions

View file

@ -1,3 +1,4 @@
using System.Diagnostics.CodeAnalysis;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using NodaTime;
@ -43,6 +44,14 @@ public readonly struct Snowflake(ulong value)
public static implicit operator Snowflake(ulong n) => new(n);
public static implicit operator Snowflake(long n) => new((ulong)n);
public static bool TryParse(string input, [NotNullWhen(true)] out Snowflake? snowflake)
{
snowflake = null;
if (!ulong.TryParse(input, out var res)) return false;
snowflake = new Snowflake(res);
return true;
}
public override bool Equals(object? obj) => obj is Snowflake other && Value == other.Value;
public override int GetHashCode() => Value.GetHashCode();