Last active
October 16, 2020 10:02
-
-
Save ryancheung/8174d385661309d93f78bacca731dfd3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// <auto-generated> | |
// THIS (.cs) FILE IS GENERATED BY MPC(MessagePack-CSharp). DO NOT CHANGE IT. | |
// </auto-generated> | |
#pragma warning disable 618 | |
#pragma warning disable 612 | |
#pragma warning disable 414 | |
#pragma warning disable 168 | |
#pragma warning disable SA1200 // Using directives should be placed correctly | |
#pragma warning disable SA1312 // Variable names should begin with lower-case letter | |
#pragma warning disable SA1649 // File name should match first type name | |
namespace MessagePack.Resolvers | |
{ | |
using System; | |
public class GeneratedResolver : global::MessagePack.IFormatterResolver | |
{ | |
public static readonly global::MessagePack.IFormatterResolver Instance = new GeneratedResolver(); | |
private GeneratedResolver() | |
{ | |
} | |
public global::MessagePack.Formatters.IMessagePackFormatter<T> GetFormatter<T>() | |
{ | |
return FormatterCache<T>.Formatter; | |
} | |
private static class FormatterCache<T> | |
{ | |
internal static readonly global::MessagePack.Formatters.IMessagePackFormatter<T> Formatter; | |
static FormatterCache() | |
{ | |
var f = GeneratedResolverGetFormatterHelper.GetFormatter(typeof(T)); | |
if (f != null) | |
{ | |
Formatter = (global::MessagePack.Formatters.IMessagePackFormatter<T>)f; | |
} | |
} | |
} | |
} | |
internal static class GeneratedResolverGetFormatterHelper | |
{ | |
private static readonly global::System.Collections.Generic.Dictionary<Type, int> lookup; | |
static GeneratedResolverGetFormatterHelper() | |
{ | |
lookup = new global::System.Collections.Generic.Dictionary<Type, int>(1) | |
{ | |
{ typeof(global::XXXAdmin.Shared.WeatherForecast), 0 }, | |
}; | |
} | |
internal static object GetFormatter(Type t) | |
{ | |
int key; | |
if (!lookup.TryGetValue(t, out key)) | |
{ | |
return null; | |
} | |
switch (key) | |
{ | |
case 0: return new MessagePack.Formatters.XXXAdmin.Shared.WeatherForecastFormatter(); | |
default: return null; | |
} | |
} | |
} | |
} | |
#pragma warning restore 168 | |
#pragma warning restore 414 | |
#pragma warning restore 618 | |
#pragma warning restore 612 | |
#pragma warning restore SA1312 // Variable names should begin with lower-case letter | |
#pragma warning restore SA1200 // Using directives should be placed correctly | |
#pragma warning restore SA1649 // File name should match first type name | |
// <auto-generated> | |
// THIS (.cs) FILE IS GENERATED BY MPC(MessagePack-CSharp). DO NOT CHANGE IT. | |
// </auto-generated> | |
#pragma warning disable 618 | |
#pragma warning disable 612 | |
#pragma warning disable 414 | |
#pragma warning disable 168 | |
#pragma warning disable SA1129 // Do not use default value type constructor | |
#pragma warning disable SA1200 // Using directives should be placed correctly | |
#pragma warning disable SA1309 // Field names should not begin with underscore | |
#pragma warning disable SA1312 // Variable names should begin with lower-case letter | |
#pragma warning disable SA1403 // File may only contain a single namespace | |
#pragma warning disable SA1649 // File name should match first type name | |
namespace MessagePack.Formatters.XXXAdmin.Shared | |
{ | |
using System; | |
using System.Buffers; | |
using MessagePack; | |
public sealed class WeatherForecastFormatter : global::MessagePack.Formatters.IMessagePackFormatter<global::XXXAdmin.Shared.WeatherForecast> | |
{ | |
public void Serialize(ref MessagePackWriter writer, global::XXXAdmin.Shared.WeatherForecast value, global::MessagePack.MessagePackSerializerOptions options) | |
{ | |
if (value == null) | |
{ | |
writer.WriteNil(); | |
return; | |
} | |
IFormatterResolver formatterResolver = options.Resolver; | |
writer.WriteArrayHeader(3); | |
formatterResolver.GetFormatterWithVerify<global::System.DateTime>().Serialize(ref writer, value.Date, options); | |
writer.Write(value.TemperatureC); | |
formatterResolver.GetFormatterWithVerify<string>().Serialize(ref writer, value.Summary, options); | |
} | |
public global::XXXAdmin.Shared.WeatherForecast Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) | |
{ | |
if (reader.TryReadNil()) | |
{ | |
return null; | |
} | |
options.Security.DepthStep(ref reader); | |
IFormatterResolver formatterResolver = options.Resolver; | |
var length = reader.ReadArrayHeader(); | |
var __Date__ = default(global::System.DateTime); | |
var __TemperatureC__ = default(int); | |
var __Summary__ = default(string); | |
for (int i = 0; i < length; i++) | |
{ | |
var key = i; | |
switch (key) | |
{ | |
case 0: | |
__Date__ = formatterResolver.GetFormatterWithVerify<global::System.DateTime>().Deserialize(ref reader, options); | |
break; | |
case 1: | |
__TemperatureC__ = reader.ReadInt32(); | |
break; | |
case 2: | |
__Summary__ = formatterResolver.GetFormatterWithVerify<string>().Deserialize(ref reader, options); | |
break; | |
default: | |
reader.Skip(); | |
break; | |
} | |
} | |
var ____result = new global::XXXAdmin.Shared.WeatherForecast(); | |
____result.Date = __Date__; | |
____result.TemperatureC = __TemperatureC__; | |
____result.Summary = __Summary__; | |
reader.Depth--; | |
return ____result; | |
} | |
} | |
} | |
#pragma warning restore 168 | |
#pragma warning restore 414 | |
#pragma warning restore 618 | |
#pragma warning restore 612 | |
#pragma warning restore SA1129 // Do not use default value type constructor | |
#pragma warning restore SA1200 // Using directives should be placed correctly | |
#pragma warning restore SA1309 // Field names should not begin with underscore | |
#pragma warning restore SA1312 // Variable names should begin with lower-case letter | |
#pragma warning restore SA1403 // File may only contain a single namespace | |
#pragma warning restore SA1649 // File name should match first type name | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment