16 lines
427 B
C#
16 lines
427 B
C#
using System;
|
|
using System.Security.Cryptography;
|
|
using System.Text;
|
|
|
|
namespace Game.Shared.Domain;
|
|
|
|
public readonly record struct InstanceId(Guid Value)
|
|
{
|
|
private static Guid CreateDeterministicId(string source) =>
|
|
new(MD5.HashData(Encoding.UTF8.GetBytes(source)));
|
|
|
|
public static InstanceId FromKey(string key) => new(CreateDeterministicId(key));
|
|
|
|
public override string ToString() => Value.ToString();
|
|
}
|