Files
libremetaverse/LibreMetaverse/Formatters/UUIDFormatter.cs
nooperation 2ae331bf05 Replacing MemoryPack and BinaryFormatter with MessagePack, which covers a much wider range of .net frameworks
Removed all old Serialization tags and methods
Potentially Breaking Change: Removed InventoryNode.ParentID - This was an old serlization hack. Use Data.ParentUUID instead
2025-05-24 00:49:36 -04:00

32 lines
903 B
C#

using MessagePack;
using MessagePack.Formatters;
using System;
using System.Buffers;
using System.Collections.Generic;
using System.Text;
namespace OpenMetaverse.Formatters
{
public class UUIDFormatter : IMessagePackFormatter<UUID>
{
public static readonly UUIDFormatter Instance = new UUIDFormatter();
public void Serialize(ref MessagePackWriter writer, UUID value, MessagePackSerializerOptions options)
{
writer.Write(value.GetBytes());
}
public UUID Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options)
{
var sequence = reader.ReadBytes();
if (sequence == null)
{
throw new MessagePackSerializationException("Invalid UUID");
}
var bytes = sequence.Value.ToArray();
return new UUID(bytes, 0);
}
}
}