2026-08-10 14:57:50 +01:00
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using MessagePack;
|
|
|
|
|
|
using MessagePack.ReactivePropertyExtension;
|
|
|
|
|
|
using MessagePack.Resolvers;
|
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
|
|
|
|
|
|
|
public static class RegisterResolver
|
|
|
|
|
|
{
|
|
|
|
|
|
private static bool registered = false;
|
|
|
|
|
|
public static void Register()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (registered) return;
|
|
|
|
|
|
|
|
|
|
|
|
// Set extensions to default resolver.
|
|
|
|
|
|
var resolver = CompositeResolver.Create(
|
|
|
|
|
|
MathResolver.Instance,
|
|
|
|
|
|
TypeResolver.Instance,
|
|
|
|
|
|
NativeGuidResolver.Instance,
|
|
|
|
|
|
StandardResolver.Instance,
|
|
|
|
|
|
ReactivePropertyResolver.Instance
|
|
|
|
|
|
);
|
|
|
|
|
|
var options = MessagePackSerializerOptions.Standard.WithResolver(resolver);
|
|
|
|
|
|
MessagePackSerializer.DefaultOptions = options;
|
|
|
|
|
|
|
2026-09-14 17:39:12 +02:00
|
|
|
|
// Add CultMath serialization support to Newtonsoft JSON
|
2026-08-10 14:57:50 +01:00
|
|
|
|
JsonConvert.DefaultSettings = () => new JsonSerializerSettings
|
|
|
|
|
|
{
|
|
|
|
|
|
Converters = new List<JsonConverter>
|
|
|
|
|
|
{
|
2026-09-11 21:48:45 +02:00
|
|
|
|
new MathJsonConverter()
|
2026-08-10 14:57:50 +01:00
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
registered = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|