Initial Commit (broken due to version update)
This commit is contained in:
parent
74003df84b
commit
3f7b3b7440
3132 changed files with 1103305 additions and 0 deletions
55
Assets/Scripts/MessagePack/Resolvers/OldSpecResolver.cs
Normal file
55
Assets/Scripts/MessagePack/Resolvers/OldSpecResolver.cs
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
using MessagePack.Formatters;
|
||||
using MessagePack.Internal;
|
||||
using System;
|
||||
|
||||
namespace MessagePack.Resolvers
|
||||
{
|
||||
public sealed class OldSpecResolver : IFormatterResolver
|
||||
{
|
||||
public static readonly IFormatterResolver Instance = new OldSpecResolver();
|
||||
|
||||
OldSpecResolver()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public IMessagePackFormatter<T> GetFormatter<T>()
|
||||
{
|
||||
return FormatterCache<T>.formatter;
|
||||
}
|
||||
|
||||
static class FormatterCache<T>
|
||||
{
|
||||
public static readonly IMessagePackFormatter<T> formatter;
|
||||
|
||||
static FormatterCache()
|
||||
{
|
||||
formatter = (IMessagePackFormatter<T>)OldSpecResolverGetFormatterHelper.GetFormatter(typeof(T));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace MessagePack.Internal
|
||||
{
|
||||
internal static class OldSpecResolverGetFormatterHelper
|
||||
{
|
||||
internal static object GetFormatter(Type t)
|
||||
{
|
||||
if (t == typeof(string))
|
||||
{
|
||||
return OldSpecStringFormatter.Instance;
|
||||
}
|
||||
else if (t == typeof(string[]))
|
||||
{
|
||||
return new ArrayFormatter<string>();
|
||||
}
|
||||
else if (t == typeof(byte[]))
|
||||
{
|
||||
return OldSpecBinaryFormatter.Instance;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue