Removed all old Serialization tags and methods Potentially Breaking Change: Removed InventoryNode.ParentID - This was an old serlization hack. Use Data.ParentUUID instead
32 lines
903 B
C#
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);
|
|
}
|
|
}
|
|
}
|