Initial Commit (broken due to version update)

This commit is contained in:
Reinier Vens 2020-09-25 07:12:38 +01:00
commit 3f7b3b7440
3132 changed files with 1103305 additions and 0 deletions

View file

@ -0,0 +1,65 @@
using MessagePack.Formatters;
namespace MessagePack.Resolvers
{
public sealed class PrimitiveObjectResolver : IFormatterResolver
{
public static IFormatterResolver Instance = new PrimitiveObjectResolver();
PrimitiveObjectResolver()
{
}
public IMessagePackFormatter<T> GetFormatter<T>()
{
return FormatterCache<T>.formatter;
}
static class FormatterCache<T>
{
public static readonly IMessagePackFormatter<T> formatter;
static FormatterCache()
{
formatter = (typeof(T) == typeof(object))
? (IMessagePackFormatter<T>)(object)PrimitiveObjectFormatter.Instance
: null;
}
}
}
//#if NETSTANDARD
// /// <summary>
// /// In `object`, when serializing resolve by concrete type and when deserializing use primitive.
// /// </summary>
// public sealed class DynamicObjectTypeFallbackResolver : IFormatterResolver
// {
// public static IFormatterResolver Instance = new DynamicObjectTypeFallbackResolver();
// DynamicObjectTypeFallbackResolver()
// {
// }
// public IMessagePackFormatter<T> GetFormatter<T>()
// {
// return FormatterCache<T>.formatter;
// }
// static class FormatterCache<T>
// {
// public static readonly IMessagePackFormatter<T> formatter;
// static FormatterCache()
// {
// formatter = (typeof(T) == typeof(object))
// ? (IMessagePackFormatter<T>)(object)DynamicObjectTypeFallbackFormatter.Instance
// : null;
// }
// }
// }
//#endif
}