// Copyright Epic Games, Inc. All Rights Reserved. using System; using System.ComponentModel; using EpicGames.Core; namespace EpicGames.Horde.Accounts { /// /// Identifier for a user account /// /// Id to construct from [LogValueType] [JsonSchemaString] [TypeConverter(typeof(BinaryIdTypeConverter))] [BinaryIdConverter(typeof(AccountIdConverter))] public readonly record struct AccountId(BinaryId Id) { /// public static AccountId Parse(string text) => new AccountId(BinaryId.Parse(text)); /// public static bool TryParse(ReadOnlySpan text, out AccountId result) { BinaryId binaryId; if (BinaryId.TryParse(text, out binaryId)) { result = new AccountId(binaryId); return true; } else { result = default; return false; } } /// public override string ToString() => Id.ToString(); } /// /// Converter to and from instances. /// class AccountIdConverter : BinaryIdConverter { /// public override AccountId FromBinaryId(BinaryId id) => new AccountId(id); /// public override BinaryId ToBinaryId(AccountId value) => value.Id; } }