diff --git a/Jil/Deserialize/InlineDeserializer.cs b/Jil/Deserialize/InlineDeserializer.cs index 4b5849b6..f466bc18 100644 --- a/Jil/Deserialize/InlineDeserializer.cs +++ b/Jil/Deserialize/InlineDeserializer.cs @@ -27,6 +27,7 @@ class InlineDeserializer const string CharBufferName = "char_buffer"; const string StringBuilderName = "string_builder"; + readonly Type OptionsType; readonly DateTimeFormat DateFormat; readonly SerializationNameFormat SerializationNameFormat; @@ -1435,7 +1436,8 @@ void SkipObjectMember() void LoadRecursiveTypeDelegate(Type recursiveType) { - var typeCache = typeof(TypeCache<,>).MakeGenericType(OptionsType, recursiveType); + + var typeCache = typeof(TypeCache<>.InnerTypeCache<>).MakeGenericType(OptionsType, recursiveType); FieldInfo thunk; if(ReadingFromString) @@ -2639,11 +2641,11 @@ HashSet FindAndPrimeRecursiveOrReusedTypes(Type forType) MethodInfo loadMtd; if(ReadingFromString) { - loadMtd = typeof(TypeCache<,>).MakeGenericType(OptionsType, primeType).GetMethod("LoadFromString", BindingFlags.Public | BindingFlags.Static); + loadMtd = typeof(TypeCache<>.InnerTypeCache<>).MakeGenericType(OptionsType, primeType).GetMethod("LoadFromString", BindingFlags.Public | BindingFlags.Static); } else { - loadMtd = typeof(TypeCache<,>).MakeGenericType(OptionsType, primeType).GetMethod("Load", BindingFlags.Public | BindingFlags.Static); + loadMtd = typeof(TypeCache<>.InnerTypeCache<>).MakeGenericType(OptionsType, primeType).GetMethod("Load", BindingFlags.Public | BindingFlags.Static); } loadMtd.Invoke(null, new object[0]); @@ -2700,7 +2702,7 @@ static class InlineDeserializerHelper { static Func BuildAlwaysFailsWithFromStream(Type optionsType) { - var specificTypeCache = typeof(TypeCache<,>).MakeGenericType(optionsType, typeof(ReturnType)); + var specificTypeCache = typeof(TypeCache<>.InnerTypeCache<>).MakeGenericType(optionsType, typeof(ReturnType)); var stashField = specificTypeCache.GetField("ExceptionDuringBuildFromStream", BindingFlags.Static | BindingFlags.Public); var emit = Emit.NewDynamicMethod(typeof(ReturnType), new[] { typeof(TextReader), typeof(int) }); @@ -2715,7 +2717,7 @@ static Func BuildAlwaysFailsWithFromStream BuildAlwaysFailsWithFromString(Type optionsType) { - var specificTypeCache = typeof(TypeCache<,>).MakeGenericType(optionsType, typeof(ReturnType)); + var specificTypeCache = typeof(TypeCache<>.InnerTypeCache<>).MakeGenericType(optionsType, typeof(ReturnType)); var stashField = specificTypeCache.GetField("ExceptionDuringBuildFromString", BindingFlags.Static | BindingFlags.Public); var emit = Emit.NewDynamicMethod(typeof(ReturnType), new[] { typeof(ThunkReader).MakeByRefType(), typeof(int) }); diff --git a/Jil/Deserialize/TypeCaches.cs b/Jil/Deserialize/TypeCaches.cs index 72146438..9477e55b 100644 --- a/Jil/Deserialize/TypeCaches.cs +++ b/Jil/Deserialize/TypeCaches.cs @@ -1,74 +1,94 @@ using System; -using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; + namespace Jil.Deserialize { + interface IDeserializeOptions { DateTimeFormat DateFormat { get; } SerializationNameFormat SerializationNameFormat { get; } } - static class TypeCache + + internal interface IDeserializeTypeCache + { + Func Get(); + StringThunkDelegate GetFromString(); + } + + class TypeCache : IDeserializeTypeCache where TOptions : IDeserializeOptions, new() { - static readonly object ThunkInitLock = new object(); - static volatile bool ThunkBeingBuilt = false; - public static volatile Func Thunk; - public static Exception ExceptionDuringBuildFromStream; + internal static class InnerTypeCache + { + static readonly object ThunkInitLock = new object(); + static volatile bool ThunkBeingBuilt = false; + public static volatile Func Thunk; + public static Exception ExceptionDuringBuildFromStream; - static readonly object StringThunkInitLock = new object(); - static volatile bool StringThunkBeingBuilt = false; - public static volatile StringThunkDelegate StringThunk; - public static Exception ExceptionDuringBuildFromString; + static readonly object StringThunkInitLock = new object(); + static volatile bool StringThunkBeingBuilt = false; + public static volatile StringThunkDelegate StringThunk; + public static Exception ExceptionDuringBuildFromString; - public static Func Get() - { - Load(); - return Thunk; - } + public static Func Get() + { + Load(); + return Thunk; + } - public static void Load() - { - if (Thunk != null) return; + public static void Load() + { + if (Thunk != null) return; + + lock (ThunkInitLock) + { + if (Thunk != null || ThunkBeingBuilt) return; + ThunkBeingBuilt = true; - lock (ThunkInitLock) + var options = new TOptions(); + + Thunk = InlineDeserializerHelper.BuildFromStream(typeof(TOptions), options.DateFormat, options.SerializationNameFormat, exceptionDuringBuild: out ExceptionDuringBuildFromStream); + } + } + + public static StringThunkDelegate GetFromString() { - if (Thunk != null || ThunkBeingBuilt) return; - ThunkBeingBuilt = true; + LoadFromString(); + return StringThunk; + } + + public static void LoadFromString() + { + if (StringThunk != null) return; + + lock (StringThunkInitLock) + { + if (StringThunk != null || StringThunkBeingBuilt) return; + StringThunkBeingBuilt = true; - var options = new TOptions(); + var options = new TOptions(); - Thunk = InlineDeserializerHelper.BuildFromStream(typeof(TOptions), options.DateFormat, options.SerializationNameFormat, exceptionDuringBuild: out ExceptionDuringBuildFromStream); + StringThunk = InlineDeserializerHelper.BuildFromString(typeof(TOptions), options.DateFormat, options.SerializationNameFormat, exceptionDuringBuild: out ExceptionDuringBuildFromString); + } } } - public static StringThunkDelegate GetFromString() + public Func Get() { - LoadFromString(); - return StringThunk; + return InnerTypeCache.Get(); } - public static void LoadFromString() + public StringThunkDelegate GetFromString() { - if (StringThunk != null) return; - - lock (StringThunkInitLock) - { - if (StringThunk != null || StringThunkBeingBuilt) return; - StringThunkBeingBuilt = true; - - var options = new TOptions(); - - StringThunk = InlineDeserializerHelper.BuildFromString(typeof(TOptions), options.DateFormat, options.SerializationNameFormat, exceptionDuringBuild: out ExceptionDuringBuildFromString); - } + return InnerTypeCache.GetFromString(); } } + + class MicrosoftStyle : IDeserializeOptions { public DateTimeFormat DateFormat { get { return DateTimeFormat.MicrosoftStyleMillisecondsSinceUnixEpoch; } } diff --git a/Jil/JSON.cs b/Jil/JSON.cs index b4a3bf3a..3314f66f 100644 --- a/Jil/JSON.cs +++ b/Jil/JSON.cs @@ -111,2243 +111,12 @@ public static void Serialize(T data, TextWriter output, Options options = nul GetWriterAction(options)(output, data, 0); } - /// - /// Generated giant switch of option finding via OptionsGeneration.linq - /// - static Action GetWriterAction(Options options) - { - // Start OptionsGeneration.linq generated content: GetWriterAction - switch (options.UseDateTimeFormat) - { - case DateTimeFormat.MicrosoftStyleMillisecondsSinceUnixEpoch: - switch (options.ShouldPrettyPrint) - { - case false: - switch (options.ShouldExcludeNulls) - { - case false: - switch (options.IsJSONP) - { - case false: - switch (options.ShouldIncludeInherited) - { - case false: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - case true: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - } - break; - case true: - switch (options.ShouldIncludeInherited) - { - case false: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - case true: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - } - break; - } - break; - case true: - switch (options.IsJSONP) - { - case false: - switch (options.ShouldIncludeInherited) - { - case false: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - case true: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - } - break; - case true: - switch (options.ShouldIncludeInherited) - { - case false: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - case true: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - } - break; - } - break; - } - break; - case true: - switch (options.ShouldExcludeNulls) - { - case false: - switch (options.IsJSONP) - { - case false: - switch (options.ShouldIncludeInherited) - { - case false: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - case true: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - } - break; - case true: - switch (options.ShouldIncludeInherited) - { - case false: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - case true: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - } - break; - } - break; - case true: - switch (options.IsJSONP) - { - case false: - switch (options.ShouldIncludeInherited) - { - case false: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - case true: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - } - break; - case true: - switch (options.ShouldIncludeInherited) - { - case false: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - case true: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - } - break; - } - break; - } - break; - } - break; - case DateTimeFormat.MillisecondsSinceUnixEpoch: - switch (options.ShouldPrettyPrint) - { - case false: - switch (options.ShouldExcludeNulls) - { - case false: - switch (options.IsJSONP) - { - case false: - switch (options.ShouldIncludeInherited) - { - case false: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - case true: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - } - break; - case true: - switch (options.ShouldIncludeInherited) - { - case false: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - case true: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - } - break; - } - break; - case true: - switch (options.IsJSONP) - { - case false: - switch (options.ShouldIncludeInherited) - { - case false: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - case true: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - } - break; - case true: - switch (options.ShouldIncludeInherited) - { - case false: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - case true: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - } - break; - } - break; - } - break; - case true: - switch (options.ShouldExcludeNulls) - { - case false: - switch (options.IsJSONP) - { - case false: - switch (options.ShouldIncludeInherited) - { - case false: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - case true: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - } - break; - case true: - switch (options.ShouldIncludeInherited) - { - case false: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - case true: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - } - break; - } - break; - case true: - switch (options.IsJSONP) - { - case false: - switch (options.ShouldIncludeInherited) - { - case false: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - case true: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - } - break; - case true: - switch (options.ShouldIncludeInherited) - { - case false: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - case true: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - } - break; - } - break; - } - break; - } - break; - case DateTimeFormat.SecondsSinceUnixEpoch: - switch (options.ShouldPrettyPrint) - { - case false: - switch (options.ShouldExcludeNulls) - { - case false: - switch (options.IsJSONP) - { - case false: - switch (options.ShouldIncludeInherited) - { - case false: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - case true: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - } - break; - case true: - switch (options.ShouldIncludeInherited) - { - case false: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - case true: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - } - break; - } - break; - case true: - switch (options.IsJSONP) - { - case false: - switch (options.ShouldIncludeInherited) - { - case false: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - case true: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - } - break; - case true: - switch (options.ShouldIncludeInherited) - { - case false: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - case true: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - } - break; - } - break; - } - break; - case true: - switch (options.ShouldExcludeNulls) - { - case false: - switch (options.IsJSONP) - { - case false: - switch (options.ShouldIncludeInherited) - { - case false: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - case true: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - } - break; - case true: - switch (options.ShouldIncludeInherited) - { - case false: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - case true: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - } - break; - } - break; - case true: - switch (options.IsJSONP) - { - case false: - switch (options.ShouldIncludeInherited) - { - case false: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - case true: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - } - break; - case true: - switch (options.ShouldIncludeInherited) - { - case false: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - case true: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - } - break; - } - break; - } - break; - } - break; - case DateTimeFormat.ISO8601: - switch (options.ShouldPrettyPrint) - { - case false: - switch (options.ShouldExcludeNulls) - { - case false: - switch (options.IsJSONP) - { - case false: - switch (options.ShouldIncludeInherited) - { - case false: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - case true: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - } - break; - case true: - switch (options.ShouldIncludeInherited) - { - case false: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - case true: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - } - break; - } - break; - case true: - switch (options.IsJSONP) - { - case false: - switch (options.ShouldIncludeInherited) - { - case false: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - case true: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - } - break; - case true: - switch (options.ShouldIncludeInherited) - { - case false: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - case true: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - } - break; - } - break; - } - break; - case true: - switch (options.ShouldExcludeNulls) - { - case false: - switch (options.IsJSONP) - { - case false: - switch (options.ShouldIncludeInherited) - { - case false: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - case true: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - } - break; - case true: - switch (options.ShouldIncludeInherited) - { - case false: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - case true: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - } - break; - } - break; - case true: - switch (options.IsJSONP) - { - case false: - switch (options.ShouldIncludeInherited) - { - case false: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - case true: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - } - break; - case true: - switch (options.ShouldIncludeInherited) - { - case false: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - case true: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - } - break; - } - break; - } - break; - } - break; - case DateTimeFormat.RFC1123: - switch (options.ShouldPrettyPrint) - { - case false: - switch (options.ShouldExcludeNulls) - { - case false: - switch (options.IsJSONP) - { - case false: - switch (options.ShouldIncludeInherited) - { - case false: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - case true: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - } - break; - case true: - switch (options.ShouldIncludeInherited) - { - case false: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - case true: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - } - break; - } - break; - case true: - switch (options.IsJSONP) - { - case false: - switch (options.ShouldIncludeInherited) - { - case false: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - case true: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - } - break; - case true: - switch (options.ShouldIncludeInherited) - { - case false: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - case true: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - } - break; - } - break; - } - break; - case true: - switch (options.ShouldExcludeNulls) - { - case false: - switch (options.IsJSONP) - { - case false: - switch (options.ShouldIncludeInherited) - { - case false: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - case true: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - } - break; - case true: - switch (options.ShouldIncludeInherited) - { - case false: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - case true: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - } - break; - } - break; - case true: - switch (options.IsJSONP) - { - case false: - switch (options.ShouldIncludeInherited) - { - case false: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - case true: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - } - break; - case true: - switch (options.ShouldIncludeInherited) - { - case false: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - case true: - switch (options.UseUnspecifiedDateTimeKindBehavior) - { - case UnspecifiedDateTimeKindBehavior.IsLocal: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - case UnspecifiedDateTimeKindBehavior.IsUTC: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return TypeCache.Get(); - case SerializationNameFormat.CamelCase: - return TypeCache.Get(); - } - break; - } - break; - } - break; - } - break; - } - break; - } - break; - } - // End OptionsGeneration.linq generated content: GetWriterAction - - throw new InvalidOperationException("Unexpected Options: " + options); - } - /// - /// Generated giant switch of option finding via OptionsGeneration.linq - /// - static StringThunkDelegate GetThunkerDelegate(Options options) + internal static Serialize.ISerializeTypeCache CreateSerializeTypeCache(Options options) { - // Start OptionsGeneration.linq generated content: GetThunkerDelegate -switch (options.UseDateTimeFormat) + // Start OptionsGeneration.linq generated content: GetWriterAction + switch (options.UseDateTimeFormat) { case DateTimeFormat.MicrosoftStyleMillisecondsSinceUnixEpoch: switch (options.ShouldPrettyPrint) @@ -2368,18 +137,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -2391,18 +160,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -2419,18 +188,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -2442,18 +211,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -2475,18 +244,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -2498,18 +267,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -2526,18 +295,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -2549,18 +318,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -2587,18 +356,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -2610,18 +379,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -2638,18 +407,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -2661,18 +430,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -2694,18 +463,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -2717,18 +486,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -2745,18 +514,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -2768,18 +537,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -2811,18 +580,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -2834,18 +603,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -2862,18 +631,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -2885,18 +654,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -2918,18 +687,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -2941,18 +710,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -2969,18 +738,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -2992,18 +761,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -3030,18 +799,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -3053,18 +822,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -3081,18 +850,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -3104,18 +873,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -3137,18 +906,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -3160,18 +929,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -3188,18 +957,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -3211,18 +980,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -3254,18 +1023,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -3277,18 +1046,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -3305,18 +1074,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -3328,18 +1097,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -3361,18 +1130,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -3384,18 +1153,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -3412,18 +1181,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -3435,18 +1204,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -3473,18 +1242,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -3496,18 +1265,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -3524,18 +1293,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -3547,18 +1316,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -3580,18 +1349,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -3603,18 +1372,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -3631,18 +1400,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -3654,18 +1423,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -3697,18 +1466,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -3720,18 +1489,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -3748,18 +1517,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -3771,18 +1540,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -3804,18 +1573,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -3827,18 +1596,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -3855,18 +1624,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -3878,18 +1647,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -3916,18 +1685,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -3939,18 +1708,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -3967,18 +1736,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -3990,18 +1759,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -4023,18 +1792,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -4046,18 +1815,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -4074,18 +1843,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -4097,18 +1866,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -4140,18 +1909,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -4163,18 +1932,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -4191,18 +1960,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -4214,18 +1983,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -4247,18 +2016,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -4270,18 +2039,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -4298,18 +2067,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -4321,18 +2090,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -4359,18 +2128,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -4382,18 +2151,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -4410,18 +2179,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -4433,18 +2202,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -4466,18 +2235,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -4489,18 +2258,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -4517,18 +2286,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -4540,18 +2309,18 @@ static StringThunkDelegate GetThunkerDelegate(Options options) switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; case UnspecifiedDateTimeKindBehavior.IsUTC: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return TypeCache.GetToString(); + return new TypeCache(); case SerializationNameFormat.CamelCase: - return TypeCache.GetToString(); + return new TypeCache(); } break; } @@ -4564,10 +2333,29 @@ static StringThunkDelegate GetThunkerDelegate(Options options) break; } break; - } - // End OptionsGeneration.linq generated content: GetThunkerDelegate + } + // End OptionsGeneration.linq generated content: GetWriterAction throw new InvalidOperationException("Unexpected Options: " + options); + } + + + /// + /// Generated giant switch of option finding via OptionsGeneration.linq + /// + static Action GetWriterAction(Options options) + { + return options.SerializeTypeCache.Get(); + } + + + + /// + /// Generated giant switch of option finding via OptionsGeneration.linq + /// + static StringThunkDelegate GetThunkerDelegate(Options options) + { + return options.SerializeTypeCache.GetToString(); } /// @@ -4653,77 +2441,57 @@ public static object Deserialize(string text, Type type, Options options = null) } return Jil.Deserialize.DeserializeIndirect.DeserializeFromString(text, type, options); - } - - /// - /// Deserializes JSON from the given TextReader. - /// - /// Pass an Options object to specify the particulars (such as DateTime formats) of - /// the JSON being deserialized. If omitted Options.Default is used, unless JSON.SetDefaultOptions(Options) has been - /// called with a different Options object. - /// - public static T Deserialize(TextReader reader, Options options = null) - { - if (reader == null) - { - throw new ArgumentNullException("reader"); - } - - if (typeof(T) == typeof(object)) - { - return DeserializeDynamic(reader, options); - } + } + internal static Deserialize.IDeserializeTypeCache CreateDeserializeTypeCache(Options options) + { try { - options = options ?? DefaultOptions; - reader = reader.MakeSupportPeek(); - switch (options.UseDateTimeFormat) { case DateTimeFormat.MicrosoftStyleMillisecondsSinceUnixEpoch: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return Jil.Deserialize.TypeCache.Get()(reader, 0); + return new Jil.Deserialize.TypeCache(); case SerializationNameFormat.CamelCase: - return Jil.Deserialize.TypeCache.Get()(reader, 0); + return new Jil.Deserialize.TypeCache(); } break; case DateTimeFormat.MillisecondsSinceUnixEpoch: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return Jil.Deserialize.TypeCache.Get()(reader, 0); + return new Jil.Deserialize.TypeCache(); case SerializationNameFormat.CamelCase: - return Jil.Deserialize.TypeCache.Get()(reader, 0); + return new Jil.Deserialize.TypeCache(); } break; case DateTimeFormat.SecondsSinceUnixEpoch: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return Jil.Deserialize.TypeCache.Get()(reader, 0); + return new Jil.Deserialize.TypeCache(); case SerializationNameFormat.CamelCase: - return Jil.Deserialize.TypeCache.Get()(reader, 0); + return new Jil.Deserialize.TypeCache(); } break; case DateTimeFormat.ISO8601: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return Jil.Deserialize.TypeCache.Get()(reader, 0); + return new Jil.Deserialize.TypeCache(); case SerializationNameFormat.CamelCase: - return Jil.Deserialize.TypeCache.Get()(reader, 0); + return new Jil.Deserialize.TypeCache(); } break; case DateTimeFormat.RFC1123: switch (options.SerializationNameFormat) { case SerializationNameFormat.Verbatim: - return Jil.Deserialize.TypeCache.Get()(reader, 0); + return new Jil.Deserialize.TypeCache(); case SerializationNameFormat.CamelCase: - return Jil.Deserialize.TypeCache.Get()(reader, 0); + return new Jil.Deserialize.TypeCache(); } break; } @@ -4733,6 +2501,44 @@ public static T Deserialize(TextReader reader, Options options = null) { if (e is DeserializationException) throw; + throw new DeserializationException(e, false); + } + } + + /// + /// Deserializes JSON from the given TextReader. + /// + /// Pass an Options object to specify the particulars (such as DateTime formats) of + /// the JSON being deserialized. If omitted Options.Default is used, unless JSON.SetDefaultOptions(Options) has been + /// called with a different Options object. + /// + public static T Deserialize(TextReader reader, Options options = null) + { + if (reader == null) + { + throw new ArgumentNullException("reader"); + } + + if (typeof(T) == typeof(object)) + { + return DeserializeDynamic(reader, options); + } + + try + { + options = options ?? DefaultOptions; + reader = reader.MakeSupportPeek(); + + + options = options ?? DefaultOptions; + + + return options.DeserializeTypeCache.Get()(reader, 0); + } + catch (Exception e) + { + if (e is DeserializationException) throw; + throw new DeserializationException(e, reader, false); } } @@ -4760,57 +2566,10 @@ public static T Deserialize(string text, Options options = null) { options = options ?? DefaultOptions; - var thunk = new Jil.Deserialize.ThunkReader(text); + var thunk = new Deserialize.ThunkReader(text); - switch (options.UseDateTimeFormat) - { - case DateTimeFormat.MicrosoftStyleMillisecondsSinceUnixEpoch: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return Jil.Deserialize.TypeCache.GetFromString()(ref thunk, 0); - case SerializationNameFormat.CamelCase: - return Jil.Deserialize.TypeCache.GetFromString()(ref thunk, 0); - } - break; - case DateTimeFormat.MillisecondsSinceUnixEpoch: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return Jil.Deserialize.TypeCache.GetFromString()(ref thunk, 0); - case SerializationNameFormat.CamelCase: - return Jil.Deserialize.TypeCache.GetFromString()(ref thunk, 0); - } - break; - case DateTimeFormat.SecondsSinceUnixEpoch: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return Jil.Deserialize.TypeCache.GetFromString()(ref thunk, 0); - case SerializationNameFormat.CamelCase: - return Jil.Deserialize.TypeCache.GetFromString()(ref thunk, 0); - } - break; - case DateTimeFormat.ISO8601: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return Jil.Deserialize.TypeCache.GetFromString()(ref thunk, 0); - case SerializationNameFormat.CamelCase: - return Jil.Deserialize.TypeCache.GetFromString()(ref thunk, 0); - } - break; - case DateTimeFormat.RFC1123: - switch (options.SerializationNameFormat) - { - case SerializationNameFormat.Verbatim: - return Jil.Deserialize.TypeCache.GetFromString()(ref thunk, 0); - case SerializationNameFormat.CamelCase: - return Jil.Deserialize.TypeCache.GetFromString()(ref thunk, 0); - } - break; - } - throw new InvalidOperationException("Unexpected Options: " + options); + return options.DeserializeTypeCache.GetFromString()(ref thunk, 0); + } catch (Exception e) { diff --git a/Jil/Options.cs b/Jil/Options.cs index 1f2117bf..39930547 100644 --- a/Jil/Options.cs +++ b/Jil/Options.cs @@ -10,6 +10,11 @@ namespace Jil /// public sealed class Options { + #region Defined Options + + + + #pragma warning disable 1591 // Start OptionsGeneration.linq generated content public static readonly Options Default = new Options(dateFormat: DateTimeFormat.MicrosoftStyleMillisecondsSinceUnixEpoch); @@ -335,6 +340,9 @@ public sealed class Options // End OptionsGeneration.linq generated content #pragma warning restore 1591 + + #endregion + internal bool ShouldPrettyPrint { get; private set; } internal bool ShouldExcludeNulls { get; private set; } internal DateTimeFormat UseDateTimeFormat { get; private set; } @@ -467,22 +475,37 @@ public override int GetHashCode() unspecifiedMask; } - /// - /// Returns true if two Options are equal, and false otherwise - /// - public override bool Equals(object obj) - { - var other = obj as Options; - if (other == null) return false; - - return - other.UseDateTimeFormat == this.UseDateTimeFormat && - other.ShouldPrettyPrint == this.ShouldPrettyPrint && - other.ShouldExcludeNulls == this.ShouldExcludeNulls && - other.IsJSONP == this.IsJSONP && - other.ShouldIncludeInherited == this.ShouldIncludeInherited && - other.UseUnspecifiedDateTimeKindBehavior == this.UseUnspecifiedDateTimeKindBehavior && - other.SerializationNameFormat == this.SerializationNameFormat; + /// + /// Returns true if two Options are equal, and false otherwise + /// + public override bool Equals(object obj) + { + var other = obj as Options; + if (other == null) return false; + + return + other.UseDateTimeFormat == this.UseDateTimeFormat && + other.ShouldPrettyPrint == this.ShouldPrettyPrint && + other.ShouldExcludeNulls == this.ShouldExcludeNulls && + other.IsJSONP == this.IsJSONP && + other.ShouldIncludeInherited == this.ShouldIncludeInherited && + other.UseUnspecifiedDateTimeKindBehavior == this.UseUnspecifiedDateTimeKindBehavior && + other.SerializationNameFormat == this.SerializationNameFormat; + } + + private Deserialize.IDeserializeTypeCache _deserializeTypeCache; + + internal Deserialize.IDeserializeTypeCache DeserializeTypeCache + { + get { return _deserializeTypeCache ?? (_deserializeTypeCache = JSON.CreateDeserializeTypeCache(this)); } } + + + private Serialize.ISerializeTypeCache _serializeTypeCache; + + internal Serialize.ISerializeTypeCache SerializeTypeCache + { + get { return _serializeTypeCache ?? (_serializeTypeCache = JSON.CreateSerializeTypeCache(this)); } + } } } \ No newline at end of file diff --git a/Jil/Serialize/InlineSerializer.cs b/Jil/Serialize/InlineSerializer.cs index 4d2b6ac7..5c994f79 100644 --- a/Jil/Serialize/InlineSerializer.cs +++ b/Jil/Serialize/InlineSerializer.cs @@ -3867,8 +3867,10 @@ void WriteEnum(Type enumType, bool popTextWriter, bool containedInNullable) } else { + + // static case - var cacheType = typeof(TypeCache<,>).MakeGenericType(RecursionLookupOptionsType, type); + var cacheType = typeof(TypeCache<>.InnerTypeCache<>).MakeGenericType(RecursionLookupOptionsType, type); FieldInfo thunk; if (BuildingToString) @@ -3985,11 +3987,11 @@ HashSet FindAndPrimeRecursiveOrReusedTypes(Type forType) MethodInfo loadMtd; if (BuildingToString) { - loadMtd = typeof(TypeCache<,>).MakeGenericType(RecursionLookupOptionsType, primeType).GetMethod("LoadToString", BindingFlags.Public | BindingFlags.Static); + loadMtd = typeof(TypeCache<>.InnerTypeCache<>).MakeGenericType(RecursionLookupOptionsType, primeType).GetMethod("LoadToString", BindingFlags.Public | BindingFlags.Static); } else { - loadMtd = typeof(TypeCache<,>).MakeGenericType(RecursionLookupOptionsType, primeType).GetMethod("Load", BindingFlags.Public | BindingFlags.Static); + loadMtd = typeof(TypeCache<>.InnerTypeCache<>).MakeGenericType(RecursionLookupOptionsType, primeType).GetMethod("Load", BindingFlags.Public | BindingFlags.Static); } loadMtd.Invoke(null, new object[0]); @@ -4292,7 +4294,7 @@ static class InlineSerializerHelper { static Action BuildAlwaysFailsWith(Type optionsType) { - var specificTypeCache = typeof(TypeCache<,>).MakeGenericType(optionsType, typeof(BuildForType)); + var specificTypeCache = typeof(TypeCache<>.InnerTypeCache<>).MakeGenericType(optionsType, typeof(BuildForType)); var stashField = specificTypeCache.GetField("ThunkExceptionDuringBuild", BindingFlags.Static | BindingFlags.Public); var emit = Emit.NewDynamicMethod(typeof(void), new[] { typeof(TextWriter), typeof(BuildForType), typeof(int) }); @@ -4306,7 +4308,7 @@ static Action BuildAlwaysFailsWith( static StringThunkDelegate BuildAlwaysFailsWithToString(Type optionsType) { - var specificTypeCache = typeof(TypeCache<,>).MakeGenericType(optionsType, typeof(BuildForType)); + var specificTypeCache = typeof(TypeCache<>.InnerTypeCache<>).MakeGenericType(optionsType, typeof(BuildForType)); var stashField = specificTypeCache.GetField("StringThunkExceptionDuringBuild", BindingFlags.Static | BindingFlags.Public); var emit = Emit.NewDynamicMethod(typeof(void), new[] { typeof(ThunkWriter).MakeByRefType(), typeof(BuildForType), typeof(int) }); diff --git a/Jil/Serialize/TypeCaches.cs b/Jil/Serialize/TypeCaches.cs index 538380f7..a7e63d12 100644 --- a/Jil/Serialize/TypeCaches.cs +++ b/Jil/Serialize/TypeCaches.cs @@ -1,12 +1,7 @@ using Sigil; using System; -using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Reflection; -using System.Reflection.Emit; -using System.Text; -using System.Threading.Tasks; + namespace Jil.Serialize { @@ -21,61 +16,83 @@ interface ISerializeOptions SerializationNameFormat SerializationNameFormat { get; } } - static class TypeCache - where TOptions : ISerializeOptions, new() + + internal interface ISerializeTypeCache { - static readonly object ThunkInitLock = new object(); - static volatile bool ThunkBeingBuilt = false; - public static volatile Action Thunk; - public static Exception ThunkExceptionDuringBuild; + Action Get(); + StringThunkDelegate GetToString(); + } - static readonly object StringThunkInitLock = new object(); - static volatile bool StringThunkBeingBuilt = false; - public static volatile StringThunkDelegate StringThunk; - public static Exception StringThunkExceptionDuringBuild; + class TypeCache : ISerializeTypeCache + where TOptions : ISerializeOptions, new() - public static Action Get() + { + public static class InnerTypeCache { - Load(); - return Thunk; - } + static readonly object ThunkInitLock = new object(); + static volatile bool ThunkBeingBuilt = false; + public static volatile Action Thunk; + public static Exception ThunkExceptionDuringBuild; - public static void Load() - { - if (Thunk != null) return; + static readonly object StringThunkInitLock = new object(); + static volatile bool StringThunkBeingBuilt = false; + public static volatile StringThunkDelegate StringThunk; + public static Exception StringThunkExceptionDuringBuild; - lock (ThunkInitLock) + public static Action Get() { - if (Thunk != null || ThunkBeingBuilt) return; - ThunkBeingBuilt = true; + Load(); + return Thunk; + } - var opts = new TOptions(); + public static void Load() + { + if (Thunk != null) return; - Thunk = InlineSerializerHelper.Build(typeof(TOptions), pretty: opts.PrettyPrint, excludeNulls: opts.ExcludeNulls, dateFormat: opts.DateFormat, jsonp: opts.JSONP, includeInherited: opts.IncludeInherited, dateTimeBehavior: opts.DateTimeKindBehavior, serializationNameFormat: opts.SerializationNameFormat, exceptionDuringBuild: out ThunkExceptionDuringBuild); - } - } + lock (ThunkInitLock) + { + if (Thunk != null || ThunkBeingBuilt) return; + ThunkBeingBuilt = true; - public static StringThunkDelegate GetToString() - { - LoadToString(); - return StringThunk; - } + var opts = new TOptions(); - public static void LoadToString() - { - if (StringThunk != null) return; + Thunk = InlineSerializerHelper.Build(typeof(TOptions), pretty: opts.PrettyPrint, excludeNulls: opts.ExcludeNulls, dateFormat: opts.DateFormat, jsonp: opts.JSONP, includeInherited: opts.IncludeInherited, dateTimeBehavior: opts.DateTimeKindBehavior, serializationNameFormat: opts.SerializationNameFormat, exceptionDuringBuild: out ThunkExceptionDuringBuild); + } + } + + public static StringThunkDelegate GetToString() + { + LoadToString(); + return StringThunk; + } - lock (StringThunkInitLock) + public static void LoadToString() { - if (StringThunk != null || StringThunkBeingBuilt) return; - StringThunkBeingBuilt = true; + if (StringThunk != null) return; + + lock (StringThunkInitLock) + { + if (StringThunk != null || StringThunkBeingBuilt) return; + StringThunkBeingBuilt = true; - var opts = new TOptions(); + var opts = new TOptions(); - StringThunk = InlineSerializerHelper.BuildToString(typeof(TOptions), pretty: opts.PrettyPrint, excludeNulls: opts.ExcludeNulls, dateFormat: opts.DateFormat, jsonp: opts.JSONP, includeInherited: opts.IncludeInherited, dateTimeBehavior: opts.DateTimeKindBehavior, serializationNameFormat: opts.SerializationNameFormat, exceptionDuringBuild: out StringThunkExceptionDuringBuild); + StringThunk = InlineSerializerHelper.BuildToString(typeof(TOptions), pretty: opts.PrettyPrint, excludeNulls: opts.ExcludeNulls, dateFormat: opts.DateFormat, jsonp: opts.JSONP, includeInherited: opts.IncludeInherited, dateTimeBehavior: opts.DateTimeKindBehavior, serializationNameFormat: opts.SerializationNameFormat, exceptionDuringBuild: out StringThunkExceptionDuringBuild); + } } } + + public Action Get() + { + return InnerTypeCache.Get(); + } + + public StringThunkDelegate GetToString() + { + return InnerTypeCache.GetToString(); + } } + // Start OptionsGeneration.linq generated content class MicrosoftStyle : ISerializeOptions diff --git a/JilTests/SpeedProofTests.cs b/JilTests/SpeedProofTests.cs index ea501d3d..88a99634 100644 --- a/JilTests/SpeedProofTests.cs +++ b/JilTests/SpeedProofTests.cs @@ -970,9 +970,8 @@ public void UseNameAutomataWhenMatchingEnums() { InlineDeserializer<_UseNameAutomataWhenMatchingEnums>.UseNameAutomataForEnums = true; Exception ignored; - // Build the *actual* deserializer method - automata = InlineDeserializerHelper.BuildFromStream<_UseNameAutomataWhenMatchingEnums>(typeof(Jil.Deserialize.TypeCache), dateFormat: Jil.DateTimeFormat.MicrosoftStyleMillisecondsSinceUnixEpoch, serializationNameFormat: SerializationNameFormat.Verbatim, exceptionDuringBuild: out ignored); + automata = InlineDeserializerHelper.BuildFromStream<_UseNameAutomataWhenMatchingEnums>(typeof(Jil.Deserialize.TypeCache.InnerTypeCache<_UseNameAutomataWhenMatchingEnums>), dateFormat: Jil.DateTimeFormat.MicrosoftStyleMillisecondsSinceUnixEpoch, serializationNameFormat: SerializationNameFormat.Verbatim, exceptionDuringBuild: out ignored); } { @@ -980,7 +979,7 @@ public void UseNameAutomataWhenMatchingEnums() Exception ignored; // Build the *actual* deserializer method - method = InlineDeserializerHelper.BuildFromStream<_UseNameAutomataWhenMatchingEnums>(typeof(Jil.Deserialize.TypeCache), dateFormat: Jil.DateTimeFormat.MicrosoftStyleMillisecondsSinceUnixEpoch, serializationNameFormat: SerializationNameFormat.Verbatim, exceptionDuringBuild: out ignored); + method = InlineDeserializerHelper.BuildFromStream<_UseNameAutomataWhenMatchingEnums>(typeof(Jil.Deserialize.TypeCache.InnerTypeCache<_UseHashWhenMatchingMembers>), dateFormat: Jil.DateTimeFormat.MicrosoftStyleMillisecondsSinceUnixEpoch, serializationNameFormat: SerializationNameFormat.Verbatim, exceptionDuringBuild: out ignored); } } finally