Decompiled source of EasyDeliveryAPI v1.0.0

plugins/EasyDeliveryAPI.dll

Decompiled 2 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("EasyDeliveryAPI")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Modding API for truck game.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("EasyDeliveryAPI")]
[assembly: AssemblyTitle("EasyDeliveryAPI")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace EasyDeliveryAPI
{
	internal static class Configuration
	{
		public static ConfigEntry<bool> DragEnabled;

		public static ConfigEntry<bool> MoreEnabled;

		public static void Awake(ConfigFile Config)
		{
			DragEnabled = Config.Bind<bool>("General.Toggles", "DragEnabled", true, "Wether or not files can be dragged.");
			MoreEnabled = Config.Bind<bool>("General.Toggles", "MoreEnabled", true, "Wether or not files can be dragged.");
			DragEnabled.SettingChanged += delegate
			{
				//IL_0019: Unknown result type (might be due to invalid IL or missing references)
				//IL_001f: Expected O, but got Unknown
				Object[] array2 = Resources.FindObjectsOfTypeAll(typeof(DesktopDotExe));
				for (int j = 0; j < array2.Length; j++)
				{
					DesktopDotExe val2 = (DesktopDotExe)array2[j];
					val2.drag = DragEnabled.Value;
				}
			};
			MoreEnabled.SettingChanged += delegate
			{
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0022: Expected O, but got Unknown
				//IL_0041: Unknown result type (might be due to invalid IL or missing references)
				//IL_0047: Invalid comparison between Unknown and I4
				//IL_007e: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
				Object[] array = Resources.FindObjectsOfTypeAll(typeof(DesktopDotExe));
				for (int i = 0; i < array.Length; i++)
				{
					DesktopDotExe val = (DesktopDotExe)array[i];
					foreach (File file in val.files)
					{
						if ((int)file.type == 3 && file.name == "more")
						{
							if (!MoreEnabled.Value)
							{
								foreach (File file2 in ((Folder)file).files)
								{
									val.files.Add(file2);
								}
								((Folder)file).files.Clear();
							}
							file.visible = MoreEnabled.Value;
						}
					}
				}
			};
		}
	}
	internal class DesktopPatches : MonoBehaviour
	{
		[HarmonyPatch(typeof(DesktopDotExe), "Setup")]
		private class SetupPatch : HarmonyPatch
		{
			private static void Prefix(DesktopDotExe __instance)
			{
				//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b9: Expected O, but got Unknown
				//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c0: Expected O, but got Unknown
				//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
				//IL_0227: Unknown result type (might be due to invalid IL or missing references)
				//IL_022c: Unknown result type (might be due to invalid IL or missing references)
				EasyAPI.DesktopLocation desktopLocation = EasyAPI.DesktopLocation.Main;
				foreach (File file in __instance.files)
				{
					if (file.name == "more")
					{
						return;
					}
					if (file.name == "play")
					{
						desktopLocation = EasyAPI.DesktopLocation.MainMenu;
					}
					if (file.name == "birds")
					{
						desktopLocation = EasyAPI.DesktopLocation.Weird;
					}
					file.cantFolder = false;
				}
				if (Configuration.DragEnabled.Value)
				{
					__instance.drag = true;
				}
				File val = new File(((ScreenProgram)__instance).R, __instance);
				Folder val2 = new Folder(val);
				((File)val2).icon = 3;
				((File)val2).iconHover = 4;
				((File)val2).name = "more";
				((File)val2).position = new Vector2(6f, 4f);
				((File)val2).visible = Configuration.MoreEnabled.Value;
				__instance.files.Add((File)(object)val2);
				if (1 == 0)
				{
				}
				List<File> list = desktopLocation switch
				{
					EasyAPI.DesktopLocation.Main => EasyAPI.MainGameFiles, 
					EasyAPI.DesktopLocation.MainMenu => EasyAPI.MainMenuFiles, 
					EasyAPI.DesktopLocation.Weird => EasyAPI.WeirdAreaFiles, 
					_ => throw new Exception("Invalid file location(???) this shouldnt be remotely possible."), 
				};
				if (1 == 0)
				{
				}
				List<File> list2 = list;
				foreach (File item in list2)
				{
					__instance.files.Add(item);
				}
				if (EasyAPI.handler.data.Positions == null || EasyAPI.handler.data.InFolder == null)
				{
					return;
				}
				foreach (File file2 in __instance.files)
				{
					if (EasyAPI.handler.data.Positions.ContainsKey(file2.name))
					{
						simplevec2 simplevec3 = EasyAPI.handler.data.Positions[file2.name];
						file2.position = new Vector2(simplevec3.x, simplevec3.y);
					}
				}
			}

			private static void Postfix(DesktopDotExe __instance)
			{
				if (EasyAPI.handler.data.InFolder != null)
				{
					Folder val = null;
					List<File> list = new List<File>();
					foreach (File file3 in __instance.files)
					{
						if (file3.name == "more")
						{
							File obj = file3;
							val = (Folder)(object)((obj is Folder) ? obj : null);
						}
						else if ((EasyAPI.handler.data.InFolder.ContainsKey(file3.name) && EasyAPI.handler.data.InFolder[file3.name]) || (!EasyAPI.handler.data.InFolder.ContainsKey(file3.name) && (EasyAPI.WeirdAreaFiles.Any((File file2) => file3 == file2) || EasyAPI.MainGameFiles.Any((File file2) => file3 == file2))))
						{
							list.Add(file3);
						}
					}
					if (val != null && Configuration.MoreEnabled.Value)
					{
						foreach (File item in list)
						{
							val.files.Add(item);
							__instance.files.Remove(item);
						}
					}
				}
				foreach (GameObject listener in EasyAPI.Listeners)
				{
					GameObject val2 = Object.Instantiate<GameObject>(listener, ((Component)__instance).transform);
					((Object)val2).name = ((Object)listener).name;
					((Object)val2).hideFlags = (HideFlags)0;
				}
				foreach (GameObject value in EasyAPI.CustomOptionsMenus.Values)
				{
					GameObject val3 = Object.Instantiate<GameObject>(value, ((Component)__instance).transform);
					((Object)val3).name = "optionsmenu" + ((Object)value).name;
					((Object)val3).hideFlags = (HideFlags)0;
				}
				GameObject val4 = Object.Instantiate<GameObject>(EasyAPI.OptionsMenu.Item1, ((Component)__instance).transform);
				((Object)val4).name = ((Object)EasyAPI.OptionsMenu.Item1).name;
				((Object)val4).hideFlags = (HideFlags)0;
				GameObject val5 = Object.Instantiate<GameObject>(EasyAPI.OptionsMenu.Item2, ((Component)__instance).transform);
				((Object)val5).name = ((Object)EasyAPI.OptionsMenu.Item2).name;
				((Object)val5).hideFlags = (HideFlags)0;
			}
		}

		[HarmonyPatch(typeof(ScreenSystem), "Init")]
		private class SetupPatch2 : HarmonyPatch
		{
			private static void Prefix(ScreenSystem __instance)
			{
				List<ScreenProgram> list = __instance.programs.ToList();
				foreach (ScreenProgram program in EasyAPI.Programs)
				{
					ScreenProgram val = Object.Instantiate<ScreenProgram>(program);
					((Object)val).hideFlags = (HideFlags)0;
					((Behaviour)val).enabled = true;
					list.Add(val);
				}
				__instance.programs = list.ToArray();
			}
		}

		[HarmonyPatch(typeof(DesktopDotExe), "Draw")]
		private class SaveDataPatch : HarmonyPatch
		{
			private static void Prefix(DesktopDotExe __instance)
			{
				if (EasyAPI.handler.data.Positions == null)
				{
					EasyAPI.handler.data.Positions = new Dictionary<string, simplevec2>();
				}
				if (EasyAPI.handler.data.InFolder == null)
				{
					EasyAPI.handler.data.InFolder = new Dictionary<string, bool>();
				}
				Folder val = null;
				foreach (File file in __instance.files)
				{
					if (file.name == "more")
					{
						val = (Folder)(object)((file is Folder) ? file : null);
					}
					if (file.name != "play")
					{
						EasyAPI.handler.data.Positions[file.name] = new simplevec2(file.position.x, file.position.y);
						EasyAPI.handler.data.InFolder[file.name] = false;
					}
				}
				if (val == null)
				{
					return;
				}
				foreach (File file2 in val.files)
				{
					EasyAPI.handler.data.Positions.Remove(file2.name);
					EasyAPI.handler.data.InFolder[file2.name] = true;
				}
			}

			private static void Postfix()
			{
				bool flag = default(bool);
				for (int num = EasyAPI.OldWindowViewers.Count - 1; num > 0; num--)
				{
					WindowView val = EasyAPI.OldWindowViewers[num];
					val.Draw(ref flag);
					if (flag)
					{
						EasyAPI.OldWindowViewers.Remove(val);
					}
				}
			}
		}

		[HarmonyPatch(typeof(File), "Execute")]
		private class ExecutePatch : HarmonyPatch
		{
			private static bool Prefix(File __instance, out WindowView view)
			{
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0012: Invalid comparison between Unknown and I4
				//IL_0039: Unknown result type (might be due to invalid IL or missing references)
				//IL_003f: Expected O, but got Unknown
				view = null;
				__instance.notification = false;
				if ((int)__instance.type == 1)
				{
					if (__instance.data.Contains("listener_"))
					{
						view = new WindowView(__instance.M, __instance);
					}
					else if (__instance.data.Contains("modded_"))
					{
						for (int i = 0; i < ((ScreenProgram)__instance.M).screenSystem.programs.Length; i++)
						{
							ScreenProgram val = ((ScreenProgram)__instance.M).screenSystem.programs[i];
							if (val.title == __instance.data.Substring(7))
							{
								((ScreenProgram)__instance.M).screenSystem.SetMenu(i);
								((ScreenProgram)__instance.M).screenSystem.OpenMenu();
							}
						}
					}
					else
					{
						((ScreenProgram)__instance.M).screenSystem.SetMenu(int.Parse(__instance.data));
						((ScreenProgram)__instance.M).screenSystem.OpenMenu();
					}
					return false;
				}
				return true;
			}
		}

		[HarmonyPatch]
		private class LockInput : HarmonyPatch
		{
			private static MethodInfo TargetMethod()
			{
				return typeof(sInputManager).GetMethod("GetInput", BindingFlags.Instance | BindingFlags.NonPublic);
			}

			private static void Postfix(sInputManager __instance)
			{
				if (Object.op_Implicit((Object)(object)EventSystem.current) && Object.op_Implicit((Object)(object)EventSystem.current.currentSelectedGameObject) && (Object)(object)EventSystem.current.currentSelectedGameObject.GetComponent<InputField>() != (Object)null)
				{
					LockInputMethod.Invoke(__instance, Array.Empty<object>());
					__instance.pausePressed = false;
				}
			}
		}

		[HarmonyPatch]
		private class InputFieldFix1 : HarmonyPatch
		{
			private static MethodInfo TargetMethod()
			{
				return typeof(InputField).GetMethod("IsValidChar", BindingFlags.Instance | BindingFlags.NonPublic);
			}

			private static bool Prefix(InputField __instance, char c, ref bool __result)
			{
				if (!Object.op_Implicit((Object)(object)__instance.textComponent))
				{
					__result = c != 0 && c != '\u007f';
					return false;
				}
				return true;
			}
		}

		internal static FieldInfo heldFile = typeof(DesktopDotExe).GetField("heldFile", BindingFlags.Instance | BindingFlags.NonPublic);

		internal static FieldInfo clickedOn = typeof(File).GetField("clickedOn", BindingFlags.Instance | BindingFlags.NonPublic);

		private static MethodInfo LockInputMethod = typeof(sInputManager).GetMethod("LockInput", BindingFlags.Instance | BindingFlags.NonPublic);
	}
	public class ModdedSaveSystem<T> where T : struct
	{
		public delegate T parseSaveDelegate(object save);

		private string ModID;

		public T data;

		public parseSaveDelegate ParseSave;

		private void Save()
		{
			EasyAPI.ModdedSaveHandlers[ModID] = JsonConvert.SerializeObject((object)data);
		}

		private T defaultParse(object input)
		{
			return (T)input;
		}

		public ModdedSaveSystem(string modID)
		{
			ModID = modID;
			EasyAPI.ModsLoaded[modID] = true;
			EasyAPI.OnSave = (Action)Delegate.Combine(EasyAPI.OnSave, new Action(Save));
			EasyAPI.OnLoad = (Action<Dictionary<string, string>>)Delegate.Combine(EasyAPI.OnLoad, new Action<Dictionary<string, string>>(OnDataLoaded));
			ParseSave = defaultParse;
		}

		public void OnDataLoaded(Dictionary<string, string> string_data)
		{
			if (string_data.ContainsKey(ModID))
			{
				Load(string_data[ModID]);
			}
			else
			{
				data = new T();
			}
		}

		public void Load(string string_data)
		{
			object save = JsonConvert.DeserializeObject<T>(string_data);
			data = ParseSave(save);
			EasyAPI.ModdedSaveHandlers[ModID] = string_data;
		}
	}
	internal class ModSettingsMenu : MonoBehaviour
	{
		public WindowView windowViewer;

		private UIUtil util = new UIUtil();

		private int PageNum = 0;

		public void FrameUpdate(WindowView view)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0306: Unknown result type (might be due to invalid IL or missing references)
			//IL_030b: Unknown result type (might be due to invalid IL or missing references)
			//IL_034c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0351: Unknown result type (might be due to invalid IL or missing references)
			util.M = (ScreenProgram)(object)view.M;
			util.R = view.R;
			util.nav = view.M.nav;
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(view.position * 8f, view.size * 8f);
			string text = "Page - " + PageNum;
			float num = text.Length * 8 / 2;
			float num2 = ((Rect)(ref val)).x + ((Rect)(ref val)).width / 2f;
			float num3 = 20f;
			float num4 = 12f;
			int num5 = (int)Math.Floor((((Rect)(ref val)).height - num3) / num4);
			if (util.Button("<", num2 - num - 8f, ((Rect)(ref val)).y + ((Rect)(ref val)).height - 8f, smol: true))
			{
				PageNum = Math.Max(PageNum - 1, 0);
			}
			util.R.put(text, num2 - num, ((Rect)(ref val)).y + ((Rect)(ref val)).height - 8f);
			if (util.Button(">", num2 + num, ((Rect)(ref val)).y + ((Rect)(ref val)).height - 8f, smol: true) && EasyAPI.ConfigList.Count > PageNum * num5)
			{
				PageNum++;
			}
			float num6 = 8f;
			List<string> list = EasyAPI.ConfigList.Keys.ToList();
			for (int i = 0; i < Math.Min(num5, EasyAPI.ConfigList.Count - PageNum * num5); i++)
			{
				string text2 = list[PageNum * num5 + i];
				ConfigFile targetFile = EasyAPI.ConfigList[text2];
				num = text2.Length * 8 / 2;
				if (util.Button(text2, num2 - num - 8f, ((Rect)(ref val)).y + num6, smol: true))
				{
					if (EasyAPI.CustomOptionsMenus.ContainsKey(text2))
					{
						windowViewer = EasyAPI.MakeWindow(view.M, text2, "optionsmenu" + text2);
					}
					else
					{
						ModSettingsPage.TargetFile = targetFile;
						ModSettingsPage.BuildVals();
						windowViewer = EasyAPI.MakeWindow(view.M, text2, "modsettingssingle");
					}
				}
				num6 += num4;
			}
			util.R.put("foxfoxfox.gay", ((Rect)(ref val)).x + ((Rect)(ref val)).width - (float)"foxfoxfox.gay".Length * 8f, ((Rect)(ref val)).y + ((Rect)(ref val)).height);
			if (windowViewer != null)
			{
				windowViewer.size = new Vector2(32f, 25f);
				if (!windowViewer.kill)
				{
					windowViewer.targetPosition = new Vector2(20f - windowViewer.size.x / 2f, 3f);
				}
				util.nav.zones.Clear();
				bool flag = default(bool);
				windowViewer.Draw(ref flag);
				if (flag)
				{
					windowViewer = null;
				}
			}
		}

		public void BackButtonPressed()
		{
			if (windowViewer != null && !windowViewer.kill)
			{
				windowViewer.Kill();
				((Component)util.M).SendMessage("InterruptBackButton", (SendMessageOptions)1);
				return;
			}
			ScreenProgram m = util.M;
			if (EasyAPI.ChangeWindow((DesktopDotExe)(object)((m is DesktopDotExe) ? m : null), "settings", "OptionsMenu"))
			{
				((Component)util.M).SendMessage("InterruptBackButton", (SendMessageOptions)1);
			}
		}
	}
	internal class ModSettingsPage : MonoBehaviour
	{
		public static List<Func<ConfigEntryBase, Func<UIUtil, float, float, ConfigEntryBase, string, string>>> CustomDrawHandler = new List<Func<ConfigEntryBase, Func<UIUtil, float, float, ConfigEntryBase, string, string>>>();

		public static ConfigFile TargetFile;

		private static Dictionary<string, InputField> Fields = new Dictionary<string, InputField>();

		private static List<(string, ConfigEntryBase, Func<UIUtil, float, float, ConfigEntryBase, string, string>)> builtVals = new List<(string, ConfigEntryBase, Func<UIUtil, float, float, ConfigEntryBase, string, string>)>();

		private int PageNum = 0;

		private UIUtil util = new UIUtil();

		private void DrawDescription(UIUtil util, Rect p, string str, string title)
		{
			int num = util.R.lget();
			util.R.lset(4);
			((Rect)(ref p)).y = ((Rect)(ref p)).y - 8f;
			float num2 = ((Rect)(ref p)).width / 8f - 2f;
			util.drawBox(((Rect)(ref p)).x / 8f, (((Rect)(ref p)).y + ((Rect)(ref p)).height) / 8f - 8f, num2, 7f, hasTop: false, title);
			util.R.spr(8f, 8f, ((Rect)(ref p)).x + 8f, ((Rect)(ref p)).y + ((Rect)(ref p)).height - 64f + 8f, 8f, 8f, false, num2 * 8f - 8f, 48f);
			string[] array = str.Split(new char[1] { '\n' });
			string text = "";
			for (int i = 0; i < array.Length; i++)
			{
				text += UIUtil.FormatLine(array[i], num2 - 2f);
				text += "\n";
			}
			util.R.put(text, ((Rect)(ref p)).x + 16f, ((Rect)(ref p)).y + ((Rect)(ref p)).height - 64f);
			util.R.lset(num);
		}

		private static string DrawBool(UIUtil util, float xpos, float ypos, ConfigEntryBase entry, string Name)
		{
			bool Hovered = false;
			bool? flag = util.Toggle(Name, entry.GetSerializedValue() == "true", xpos, ypos, out Hovered);
			if (flag.HasValue)
			{
				entry.SetSerializedValue(flag.Value.ToString());
			}
			return Hovered ? entry.Description.Description : null;
		}

		private static string DrawInt(UIUtil util, float xpos, float ypos, ConfigEntryBase entry, string Name)
		{
			bool Hovered = false;
			float? num = util.Adjustable(Name, entry.GetSerializedValue(), 1f, xpos, ypos, out Hovered);
			if (num.HasValue)
			{
				entry.SetSerializedValue((int.Parse(entry.GetSerializedValue()) + (int)num.Value).ToString());
			}
			return Hovered ? entry.Description.Description : null;
		}

		private static string DrawFloat(UIUtil util, float xpos, float ypos, ConfigEntryBase entry, string Name)
		{
			bool Hovered = false;
			float? num = util.Slider(Name, float.Parse(entry.GetSerializedValue()), xpos, ypos, out Hovered);
			if (num.HasValue)
			{
				entry.SetSerializedValue(num.Value.ToString());
			}
			return Hovered ? entry.Description.Description : null;
		}

		private static string DrawString(UIUtil util, float xpos, float ypos, ConfigEntryBase entry, string Name)
		{
			bool Hovered = false;
			util.R.put(Name + ": ", xpos - (float)((Name + ":").Length * 8), ypos);
			util.DrawInput(Fields[Name], "text here", xpos + 8f, ypos, out Hovered);
			return Hovered ? entry.Description.Description : null;
		}

		private static string DrawEnum(UIUtil util, float xpos, float ypos, ConfigEntryBase entry, string Name)
		{
			List<string> list = new List<string>();
			foreach (object value in Enum.GetValues(entry.SettingType))
			{
				list.Add(value.ToString());
			}
			bool Hovered = false;
			int num = list.IndexOf(entry.GetSerializedValue());
			num = ((num != -1) ? num : 0);
			string text = util.Dropdown(Name, num, list.ToArray(), xpos, ypos, out Hovered);
			if (text != null)
			{
				entry.SetSerializedValue(text);
			}
			return Hovered ? entry.Description.Description : null;
		}

		private static string DrawLabel(UIUtil util, float xpos, float ypos, ConfigEntryBase entry, string Name)
		{
			util.R.put(Name, xpos - (float)(Name.Length * 4), ypos);
			return null;
		}

		public static void BuildVals()
		{
			//IL_04b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ba: Expected O, but got Unknown
			foreach (KeyValuePair<string, InputField> field in Fields)
			{
				Object.Destroy((Object)(object)((Component)field.Value).gameObject);
			}
			builtVals.Clear();
			Fields.Clear();
			Dictionary<string, Dictionary<string, ConfigEntryBase>> dictionary = new Dictionary<string, Dictionary<string, ConfigEntryBase>>();
			Dictionary<string, Func<UIUtil, float, float, ConfigEntryBase, string, string>> dictionary2 = new Dictionary<string, Func<UIUtil, float, float, ConfigEntryBase, string, string>>();
			foreach (ConfigDefinition key in TargetFile.Keys)
			{
				Type settingType = TargetFile[key].SettingType;
				bool flag = false;
				foreach (Func<ConfigEntryBase, Func<UIUtil, float, float, ConfigEntryBase, string, string>> item2 in CustomDrawHandler)
				{
					Func<UIUtil, float, float, ConfigEntryBase, string, string> func = item2(TargetFile[key]);
					if (func != null)
					{
						dictionary2.Add(key.Key, func);
						if (!dictionary.ContainsKey(key.Section))
						{
							dictionary[key.Section] = new Dictionary<string, ConfigEntryBase>();
						}
						dictionary[key.Section][key.Key] = TargetFile[key];
						flag = true;
						break;
					}
				}
				if (!flag && (settingType.IsEnum || settingType == typeof(int) || settingType.IsEnum || settingType == typeof(bool) || settingType == typeof(string) || settingType == typeof(char) || settingType == typeof(double) || settingType == typeof(float)))
				{
					if (!dictionary.ContainsKey(key.Section))
					{
						dictionary[key.Section] = new Dictionary<string, ConfigEntryBase>();
					}
					dictionary[key.Section][key.Key] = TargetFile[key];
				}
			}
			List<string> list = dictionary.Keys.ToList();
			list.Sort();
			for (int i = 0; i < list.Count; i++)
			{
				string item = list[i];
				Dictionary<string, ConfigEntryBase> dictionary3 = dictionary[list[i]];
				builtVals.Add((item, null, DrawLabel));
				List<string> list2 = dictionary3.Keys.ToList();
				list2.Sort();
				for (int j = 0; j < list2.Count; j++)
				{
					string text = list2[j];
					ConfigEntryBase ConfigEntry = dictionary3[text];
					EasyAPI.Log.LogInfo((object)ConfigEntry.SettingType);
					if (dictionary2.ContainsKey(text))
					{
						builtVals.Add((text, ConfigEntry, dictionary2[text]));
					}
					else if (ConfigEntry.SettingType == typeof(bool))
					{
						builtVals.Add((text, ConfigEntry, DrawBool));
					}
					else if (ConfigEntry.SettingType == typeof(int))
					{
						builtVals.Add((text, ConfigEntry, DrawInt));
					}
					else if (ConfigEntry.SettingType == typeof(float))
					{
						builtVals.Add((text, ConfigEntry, DrawFloat));
					}
					else if (ConfigEntry.SettingType == typeof(string) || ConfigEntry.SettingType == typeof(char))
					{
						GameObject val = new GameObject();
						((Object)val).hideFlags = (HideFlags)61;
						InputField val2 = EasyAPI.MakeInputField(val);
						val2.text = ConfigEntry.GetSerializedValue();
						val2.characterLimit = ((!(ConfigEntry.SettingType == typeof(string))) ? 1 : 1600);
						((UnityEvent<string>)(object)val2.onSubmit).AddListener((UnityAction<string>)delegate(string submittedname)
						{
							ConfigEntry.SetSerializedValue(submittedname);
						});
						Fields.Add(text, val2);
						builtVals.Add((text, ConfigEntry, DrawString));
					}
					else if (ConfigEntry.SettingType.IsEnum)
					{
						builtVals.Add((text, ConfigEntry, DrawEnum));
					}
				}
			}
		}

		public void FrameUpdate(WindowView view)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
			util.M = (ScreenProgram)(object)view.M;
			util.R = view.R;
			util.nav = view.M.nav;
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(view.position * 8f, view.size * 8f);
			float num = 8f;
			int num2 = (int)Math.Floor((((Rect)(ref val)).height - 88f) / 12f);
			string str = "";
			string title = "";
			for (int i = 0; i < Math.Min(num2, builtVals.Count - PageNum * num2); i++)
			{
				(string, ConfigEntryBase, Func<UIUtil, float, float, ConfigEntryBase, string, string>) tuple = builtVals[i + PageNum * num2];
				string text = tuple.Item3(util, ((Rect)(ref val)).x + ((Rect)(ref val)).width / 2f, ((Rect)(ref val)).y + num, tuple.Item2, tuple.Item1);
				if (text != null)
				{
					str = text;
					(title, _, _) = tuple;
				}
				num += 12f;
			}
			Math.Min(num2, builtVals.Count - PageNum * num2);
			string text2 = "Page - " + PageNum;
			if (util.Button("<", ((Rect)(ref val)).x + ((Rect)(ref val)).width / 2f - 8f - (float)(text2.Length * 4), ((Rect)(ref val)).y + ((Rect)(ref val)).height - 72f, smol: true))
			{
				PageNum = Math.Max(PageNum - 1, 0);
			}
			util.R.put(text2, ((Rect)(ref val)).x + ((Rect)(ref val)).width / 2f - (float)(text2.Length * 4), ((Rect)(ref val)).y + ((Rect)(ref val)).height - 72f);
			if (util.Button(">", ((Rect)(ref val)).x + ((Rect)(ref val)).width / 2f + (float)text2.Length * 4f, ((Rect)(ref val)).y + ((Rect)(ref val)).height - 72f, smol: true) && builtVals.Count - 1 > (PageNum + 1) * num2)
			{
				PageNum++;
			}
			DrawDescription(util, new Rect(((Rect)(ref val)).x + 8f, ((Rect)(ref val)).y + 8f, ((Rect)(ref val)).width, ((Rect)(ref val)).height), str, title);
		}
	}
	internal struct simplevec2
	{
		public float x;

		public float y;

		public simplevec2(float x, float y)
		{
			this.x = x;
			this.y = y;
		}
	}
	internal struct filepositions
	{
		public Dictionary<string, simplevec2> Positions;

		public Dictionary<string, bool> InFolder;
	}
	[BepInPlugin("EasyDeliveryAPI", "EasyDeliveryAPI", "1.0.0")]
	public class EasyAPI : BaseUnityPlugin
	{
		[Flags]
		public enum DesktopLocation
		{
			Main = 0,
			MainMenu = 1,
			Weird = 2
		}

		internal static List<string> SaveFileNames = new List<string>();

		internal static Dictionary<string, string> ModdedSaveHandlers = new Dictionary<string, string>();

		internal static Action OnSave;

		internal static Action<Dictionary<string, string>> OnLoad;

		internal static Dictionary<string, bool> ModsLoaded = new Dictionary<string, bool>();

		internal static List<File> WeirdAreaFiles = new List<File>();

		internal static List<File> MainGameFiles = new List<File>();

		internal static List<File> MainMenuFiles = new List<File>();

		internal static List<ScreenProgram> Programs = new List<ScreenProgram>();

		internal static List<GameObject> Listeners = new List<GameObject>();

		internal static List<GameObject> sHUDListeners = new List<GameObject>();

		internal static (GameObject, GameObject) OptionsMenu;

		internal static Dictionary<string, GameObject> CustomOptionsMenus = new Dictionary<string, GameObject>();

		internal static Dictionary<string, ConfigFile> ConfigList = new Dictionary<string, ConfigFile>();

		internal static ModdedSaveSystem<filepositions> handler = new ModdedSaveSystem<filepositions>("EasyAPI");

		internal static ManualLogSource Log;

		private static MiniRenderer annoyingrenderer = new MiniRenderer();

		private static DesktopDotExe annoyingdesktop = new DesktopDotExe();

		internal static InputField RenameSaveFileInput;

		internal static FieldInfo windowViewer = typeof(DesktopDotExe).GetField("windowViewer", BindingFlags.Instance | BindingFlags.NonPublic);

		internal static List<WindowView> OldWindowViewers = new List<WindowView>();

		private static MethodInfo UpdateFileName = typeof(sSaveSystem).GetMethod("UpdateFileName", BindingFlags.Instance | BindingFlags.NonPublic);

		public static WindowView MakeWindow(DesktopDotExe __instance, string name, string target)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			File val = InstantiateFile();
			val.data = "listener_" + target;
			val.name = name;
			val.openSound = __instance.select;
			return new WindowView(__instance, val);
		}

		public static bool ChangeWindow(DesktopDotExe __instance, string name, string target)
		{
			object? value = windowViewer.GetValue(__instance);
			WindowView val = (WindowView)((value is WindowView) ? value : null);
			if (val != null)
			{
				val.Kill();
				windowViewer.SetValue(__instance, MakeWindow(__instance, name, target));
				OldWindowViewers.Add(val);
				return true;
			}
			return false;
		}

		public static void FetchSaveNames()
		{
			List<string> list = new List<string>();
			string[] files = Directory.GetFiles(Application.persistentDataPath);
			foreach (string fileName in files)
			{
				FileInfo fileInfo = new FileInfo(fileName);
				if (fileInfo.Extension == ".txt" && fileInfo.Name.Length >= 22 && fileInfo.Name.Substring(0, 22) == "EasyDeliveryCoSaveData")
				{
					list.Add(fileInfo.Name.Substring(0, fileInfo.Name.Length - 4));
				}
			}
			list.Sort();
			SaveFileNames = list;
		}

		public static void AddProgram(ScreenProgram Program)
		{
			Programs.Add(Program);
		}

		public static T AddListener<T>(string Name) where T : Component
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			GameObject val = new GameObject(Name);
			T result = val.AddComponent<T>();
			((Object)val).hideFlags = (HideFlags)61;
			Listeners.Add(val);
			return result;
		}

		public static T AddCustomOptionsMenu<T>(string Name) where T : Component
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			GameObject val = new GameObject(Name);
			T result = val.AddComponent<T>();
			((Object)val).hideFlags = (HideFlags)61;
			CustomOptionsMenus.Add(Name, val);
			return result;
		}

		public static T AddsHUDListener<T>(string Name) where T : Component
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			GameObject val = new GameObject(Name);
			T result = val.AddComponent<T>();
			((Object)val).hideFlags = (HideFlags)61;
			sHUDListeners.Add(val);
			return result;
		}

		public static void AddConfig(string Name, ConfigFile target)
		{
			ConfigList.Add(Name, target);
		}

		public static InputField MakeInputField(GameObject Target)
		{
			return Target.AddComponent<InputField>();
		}

		public static File InstantiateFile()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			return new File(annoyingrenderer, annoyingdesktop);
		}

		public static void AddFile(DesktopLocation Location, File File)
		{
			if ((Location & DesktopLocation.Main) == 0)
			{
				MainGameFiles.Add(File);
			}
			if ((Location & DesktopLocation.MainMenu) == DesktopLocation.MainMenu)
			{
				MainMenuFiles.Add(File);
			}
			if ((Location & DesktopLocation.Weird) == DesktopLocation.Weird)
			{
				WeirdAreaFiles.Add(File);
			}
		}

		public static void AddCustomSettingsDrawHandler(Func<ConfigEntryBase, Func<UIUtil, float, float, ConfigEntryBase, string, string>> Target)
		{
			ModSettingsPage.CustomDrawHandler.Add(Target);
		}

		private void Awake()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Expected O, but got Unknown
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Expected O, but got Unknown
			GameObject val = new GameObject();
			((Object)val).hideFlags = (HideFlags)61;
			RenameSaveFileInput = MakeInputField(val);
			RenameSaveFileInput.characterLimit = 12;
			((UnityEvent<string>)(object)RenameSaveFileInput.onSubmit).AddListener((UnityAction<string>)delegate(string submittedname)
			{
				string text = Application.persistentDataPath + "/EasyDeliveryCoSaveData_" + submittedname + ".txt";
				if (!File.Exists(text))
				{
					string destFileName = Application.persistentDataPath + "/modded-EasyDeliveryCoSaveData_" + submittedname + ".json";
					string text2 = Application.persistentDataPath + "/" + sSaveSystem.instance.saveFileName + ".txt";
					string text3 = Application.persistentDataPath + "/modded-" + sSaveSystem.instance.saveFileName + ".json";
					if (File.Exists(text2))
					{
						File.Copy(text2, text);
						if (File.Exists(text3))
						{
							File.Copy(text3, destFileName);
							File.Delete(text3);
						}
						File.Delete(text2);
					}
					sSaveSystem.instance.saveFileName = "EasyDeliveryCoSaveData_" + submittedname;
					UpdateFileName.Invoke(sSaveSystem.instance, Array.Empty<object>());
					FetchSaveNames();
				}
				else
				{
					RenameSaveFileInput.text = sSaveSystem.instance.saveFileName.Substring(23).Substring(0, Math.Min(sSaveSystem.instance.saveFileName.Length - 23, 12));
				}
			});
			Log = ((BaseUnityPlugin)this).Logger;
			Harmony val2 = new Harmony("EasyDesktopAPI");
			val2.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin EasyDeliveryAPI is loaded!");
			GameObject val3 = new GameObject("modsettingslist");
			val3.AddComponent<ModSettingsMenu>();
			((Object)val3).hideFlags = (HideFlags)61;
			GameObject val4 = new GameObject("modsettingssingle");
			val4.AddComponent<ModSettingsPage>();
			((Object)val4).hideFlags = (HideFlags)61;
			OptionsMenu = (val3, val4);
			Configuration.Awake(((BaseUnityPlugin)this).Config);
			AddConfig("easy delivery api", ((BaseUnityPlugin)this).Config);
			AddCustomSettingsDrawHandler(delegate(ConfigEntryBase Base)
			{
				Log.LogInfo((object)Base.Description.Tags.Length);
				if (Base.Description.Tags.Length != 0)
				{
					Log.LogInfo((object)"HIT!");
					return delegate(UIUtil util, float xpos, float ypos, ConfigEntryBase entry, string Name)
					{
						util.R.put(Name, xpos - (float)(Name.Length * 4), ypos);
						return null;
					};
				}
				return null;
			});
		}
	}
	internal class SavePatches : MonoBehaviour
	{
		[HarmonyPatch(typeof(IntroDotExe), "Awake")]
		private class AwakePatch : HarmonyPatch
		{
			private static void Prefix(IntroDotExe __instance)
			{
				PageNum = 0;
				Parent = __instance.saveFiles[0].transform.parent;
				GameObject[] saveFiles = __instance.saveFiles;
				foreach (GameObject val in saveFiles)
				{
					Object.Destroy((Object)(object)val);
				}
				__instance.saveFiles = Array.Empty<GameObject>();
				EasyAPI.FetchSaveNames();
			}
		}

		[HarmonyPatch]
		private class SelectorPatch : HarmonyPatch
		{
			private static MethodBase TargetMethod()
			{
				return typeof(IntroDotExe).GetMethod("FileSelectScreen", BindingFlags.Instance | BindingFlags.NonPublic);
			}

			private static bool Prefix(IntroDotExe __instance)
			{
				//IL_0063: Unknown result type (might be due to invalid IL or missing references)
				//IL_0071: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
				//IL_010b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0123: Unknown result type (might be due to invalid IL or missing references)
				//IL_0129: Unknown result type (might be due to invalid IL or missing references)
				//IL_0163: Unknown result type (might be due to invalid IL or missing references)
				//IL_016f: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
				//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
				//IL_021e: Unknown result type (might be due to invalid IL or missing references)
				//IL_022a: Unknown result type (might be due to invalid IL or missing references)
				object? value = nav.GetValue(__instance);
				GamepadNavigation pnav = (GamepadNavigation)((value is GamepadNavigation) ? value : null);
				UIUtil uIUtil = new UIUtil(((ScreenProgram)__instance).R, (ScreenProgram)(object)__instance, pnav);
				Vector2 val = default(Vector2);
				((Vector2)(ref val))..ctor((float)(((ScreenProgram)__instance).R.width / 2 - 64), (float)(((ScreenProgram)__instance).R.height / 2 - 32));
				float num = 16f;
				for (int i = 0; i < Math.Min(4, EasyAPI.SaveFileNames.Count - PageNum * 4); i++)
				{
					FileButton.Invoke(__instance, new object[5]
					{
						val.x,
						val.y + (num + 8f) * (float)(i % 4),
						128f,
						num,
						i + PageNum * 4
					});
				}
				((ScreenProgram)__instance).R.put("Page - " + PageNum, val.x + 32f, val.y - 12f);
				if (uIUtil.Button("<", val.x, val.y - 12f, smol: true) && PageNum > 0)
				{
					PageNum--;
				}
				if (uIUtil.Button(">", val.x + 122f, val.y - 12f, smol: true) && EasyAPI.SaveFileNames.Count > (PageNum + 1) * 4)
				{
					PageNum++;
				}
				if (uIUtil.Button("back", val.x, val.y + 90f))
				{
					GoBack.Invoke(__instance, Array.Empty<object>());
				}
				if (uIUtil.Button("refresh saves", val.x, val.y + 98f))
				{
					EasyAPI.FetchSaveNames();
				}
				if (uIUtil.Button("new save", val.x + 64f, val.y + 90f))
				{
					int num2 = EasyAPI.SaveFileNames.Count;
					string text = "";
					while (true)
					{
						text = "EasyDeliveryCoSaveData_File" + num2;
						if (!EasyAPI.SaveFileNames.Contains(text))
						{
							break;
						}
						num2++;
					}
					EasyAPI.SaveFileNames.Add(text);
					if (EasyAPI.SaveFileNames.Count > (PageNum + 1) * 4)
					{
						PageNum = EasyAPI.SaveFileNames.Count / 4;
					}
				}
				return false;
			}
		}

		[HarmonyPatch]
		private class ButtonPatch : HarmonyPatch
		{
			private static MethodBase TargetMethod()
			{
				return FileButton;
			}

			private static bool Prefix(IntroDotExe __instance, ref float x, float y, float w, float h, int index)
			{
				//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fe: Expected O, but got Unknown
				string text = EasyAPI.SaveFileNames[index];
				text = ((text.Length > 23) ? text.Substring(23).Substring(0, Math.Min(text.Length - 23, 12)) : "File1");
				bool flag = false;
				int num = 96;
				object? value = nav.GetValue(__instance);
				GamepadNavigation pnav = (GamepadNavigation)((value is GamepadNavigation) ? value : null);
				UIUtil uIUtil = new UIUtil(((ScreenProgram)__instance).R, (ScreenProgram)(object)__instance, pnav);
				if (uIUtil.MouseOver(x, y, w, h))
				{
					num = 80;
					x += 4f;
					((ScreenProgram)__instance).mouseIcon = 128;
					flag = true;
					if (((ScreenProgram)__instance).mouseButton)
					{
						((ScreenProgram)__instance).mouseIcon = 160;
						x -= 4f;
					}
					if (((ScreenProgram)__instance).mouseButtonUp)
					{
						if (Object.op_Implicit((Object)(object)sSaveSystem.instance))
						{
							Object.Destroy((Object)(object)((Component)sSaveSystem.instance).gameObject);
						}
						GameObject val = new GameObject();
						val.SetActive(false);
						val.AddComponent<sSaveSystem>().saveFileName = EasyAPI.SaveFileNames[index];
						EasyAPI.RenameSaveFileInput.text = text;
						val.transform.SetParent(Parent.parent);
						selectedSaveFile.SetValue(__instance, val);
						val.SetActive(true);
						ToNextScreen.Invoke(__instance, Array.Empty<object>());
					}
				}
				((ScreenProgram)__instance).drawBox((x - 4f) / 8f, (y - 4f) / 8f, w / 8f, h / 8f);
				((ScreenProgram)__instance).R.put(text, x + 24f, y + h / 2f - 4f);
				((ScreenProgram)__instance).R.spr((float)num, 0f, x + 8f, y + 3f, 10f, 10f);
				return false;
			}
		}

		[HarmonyPatch]
		private class DeletePatch : HarmonyPatch
		{
			private static MethodBase TargetMethod()
			{
				return NewGame;
			}

			private static bool Prefix(IntroDotExe __instance)
			{
				string path = Application.persistentDataPath + "/" + sSaveSystem.instance.saveFileName + ".txt";
				string path2 = Application.persistentDataPath + "/modded-" + sSaveSystem.instance.saveFileName + ".json";
				InterSceneData val = Object.FindObjectOfType<InterSceneData>();
				if (Object.op_Implicit((Object)(object)val))
				{
					Object.Destroy((Object)(object)((Component)val).gameObject);
				}
				Object.DestroyImmediate((Object)(object)sSaveSystem.instance);
				DeleteSaveAndGoBack.Invoke(__instance, Array.Empty<object>());
				if (File.Exists(path))
				{
					File.Delete(path);
					EasyAPI.FetchSaveNames();
				}
				if (File.Exists(path2))
				{
					File.Delete(path2);
				}
				return false;
			}
		}

		[HarmonyPatch]
		private class StartGamePatch : HarmonyPatch
		{
			private static MethodBase TargetMethod()
			{
				return typeof(IntroDotExe).GetMethod("StartGameScreen", BindingFlags.Instance | BindingFlags.NonPublic);
			}

			private static void Prefix(IntroDotExe __instance)
			{
				//IL_006d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0079: Unknown result type (might be due to invalid IL or missing references)
				Vector2 val = default(Vector2);
				((Vector2)(ref val))..ctor((float)(((ScreenProgram)__instance).R.width / 2 - 72), (float)(((ScreenProgram)__instance).R.height / 2 - 64));
				object? value = nav.GetValue(__instance);
				GamepadNavigation pnav = (GamepadNavigation)((value is GamepadNavigation) ? value : null);
				UIUtil uIUtil = new UIUtil(((ScreenProgram)__instance).R, (ScreenProgram)(object)__instance, pnav);
				if (!sSaveSystem.HasKey("deliveryMoney"))
				{
					string text = "";
					bool smol = false;
					if (uIUtil.Button("delete", val.x + 8f, val.y + 138f, smol))
					{
						NewGame.Invoke(__instance, Array.Empty<object>());
					}
				}
				string[] array = EasyAPI.ModdedSaveHandlers.Keys.ToArray();
				if (array.Length != 0)
				{
					((ScreenProgram)__instance).R.put("Mods:", (float)(((ScreenProgram)__instance).R.width / 2 + 72), (float)(((ScreenProgram)__instance).R.height / 2 - 64));
					int num = 12;
					string[] array2 = array;
					foreach (string text2 in array2)
					{
						((ScreenProgram)__instance).R.put(text2, (float)(((ScreenProgram)__instance).R.width / 2 + 72), (float)(((ScreenProgram)__instance).R.height / 2 - 64 + num));
						num += 12;
					}
				}
				uIUtil.DrawInput(EasyAPI.RenameSaveFileInput, "File Name", ((ScreenProgram)__instance).R.width / 2 - 64, ((ScreenProgram)__instance).R.height / 2 - 80);
			}
		}

		[HarmonyPatch(typeof(sSaveSystem), "SaveData")]
		private class SaveDataPatch : HarmonyPatch
		{
			private static void Postfix(sSaveSystem __instance)
			{
				string path = Application.persistentDataPath + "/modded-" + sSaveSystem.instance.saveFileName + ".json";
				Dictionary<string, string> dictionary = new Dictionary<string, string>();
				EasyAPI.OnSave?.Invoke();
				sSaveSystem.SetString("timeLastSaved", DateTime.Now.ToString());
				string text = JsonConvert.SerializeObject((object)EasyAPI.ModdedSaveHandlers);
				if (!File.Exists(path))
				{
					File.WriteAllText(path, text);
					Debug.Log((object)"Making new modded file - Saved Successfuwwy :3");
					return;
				}
				using (StreamWriter streamWriter = new StreamWriter(path, append: false))
				{
					streamWriter.Write(text);
				}
				Debug.Log((object)"Mods saved Successfuwwy :3");
			}
		}

		[HarmonyPatch]
		private class LoadDataPatch : HarmonyPatch
		{
			private static MethodInfo TargetMethod()
			{
				return typeof(sSaveSystem).GetMethod("ParseFileContents", BindingFlags.Instance | BindingFlags.NonPublic);
			}

			private static void Postfix(sSaveSystem __instance)
			{
				EasyAPI.ModdedSaveHandlers.Clear();
				string path = Application.persistentDataPath + "/modded-" + sSaveSystem.instance.saveFileName + ".json";
				if (!File.Exists(path))
				{
					return;
				}
				StreamReader streamReader = new StreamReader(path);
				string text = streamReader.ReadToEnd();
				streamReader.Close();
				Dictionary<string, string> dictionary = JsonConvert.DeserializeObject<Dictionary<string, string>>(text);
				foreach (KeyValuePair<string, string> item in dictionary)
				{
					if (!EasyAPI.ModsLoaded.ContainsKey(item.Key) || !EasyAPI.ModsLoaded[item.Key])
					{
						EasyAPI.ModdedSaveHandlers[item.Key] = item.Value;
					}
				}
				EasyAPI.OnLoad?.Invoke(dictionary);
			}
		}

		private static FieldInfo nav = typeof(IntroDotExe).GetField("nav", BindingFlags.Instance | BindingFlags.NonPublic);

		private static MethodInfo FileButton = typeof(IntroDotExe).GetMethod("FileButton", BindingFlags.Instance | BindingFlags.NonPublic);

		private static MethodInfo GoBack = typeof(IntroDotExe).GetMethod("GoBack", BindingFlags.Instance | BindingFlags.NonPublic);

		private static FieldInfo selectedSaveFile = typeof(IntroDotExe).GetField("selectedSaveFile", BindingFlags.Instance | BindingFlags.NonPublic);

		private static MethodInfo ToNextScreen = typeof(IntroDotExe).GetMethod("ToNextScreen", BindingFlags.Instance | BindingFlags.NonPublic);

		private static MethodInfo DeleteSaveAndGoBack = typeof(IntroDotExe).GetMethod("DeleteSaveAndGoBack", BindingFlags.Instance | BindingFlags.NonPublic);

		private static FieldInfo deleteConfirmation = typeof(IntroDotExe).GetField("deleteConfirmation", BindingFlags.Instance | BindingFlags.NonPublic);

		private static MethodInfo stopDeleteConfirmation = typeof(IntroDotExe).GetMethod("stopDeleteConfirmation", BindingFlags.Instance | BindingFlags.NonPublic);

		private static MethodInfo startDeleteConfirmation = typeof(IntroDotExe).GetMethod("startDeleteConfirmation", BindingFlags.Instance | BindingFlags.NonPublic);

		private static MethodInfo NewGame = typeof(IntroDotExe).GetMethod("NewGame", BindingFlags.Instance | BindingFlags.NonPublic);

		private static int PageNum = 0;

		private static Transform Parent;
	}
	internal class sHUDPatches : MonoBehaviour
	{
		[HarmonyPatch(typeof(sHUD), "Init")]
		private class InitPatch : HarmonyPatch
		{
			private static void Postfix(DesktopDotExe __instance)
			{
				foreach (GameObject listener in EasyAPI.Listeners)
				{
					GameObject val = Object.Instantiate<GameObject>(listener, ((Component)__instance).transform);
					((Object)val).name = ((Object)listener).name;
					((Object)val).hideFlags = (HideFlags)0;
				}
			}
		}

		[HarmonyPatch(typeof(sHUD), "FrameUpdate")]
		private class FramePatch : HarmonyPatch
		{
			private static void Postfix(sHUD __instance)
			{
				foreach (GameObject sHUDListener in EasyAPI.sHUDListeners)
				{
					GameObject.Find(((Object)sHUDListener).name).gameObject.SendMessage("FrameUpdate", (object)__instance);
				}
			}
		}

		internal static FieldInfo heldFile = typeof(DesktopDotExe).GetField("heldFile", BindingFlags.Instance | BindingFlags.NonPublic);

		internal static FieldInfo clickedOn = typeof(File).GetField("clickedOn", BindingFlags.Instance | BindingFlags.NonPublic);
	}
	internal class UIPatches
	{
		[HarmonyPatch(typeof(GamepadNavigation), "GetZone")]
		private class GamepadPatch : HarmonyPatch
		{
			private static bool Prefix(GamepadNavigation __instance, Vector2 input, out Rect __result)
			{
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_0033: Unknown result type (might be due to invalid IL or missing references)
				//IL_0034: Unknown result type (might be due to invalid IL or missing references)
				//IL_0070: Unknown result type (might be due to invalid IL or missing references)
				//IL_0084: Unknown result type (might be due to invalid IL or missing references)
				//IL_0089: Unknown result type (might be due to invalid IL or missing references)
				//IL_0091: Unknown result type (might be due to invalid IL or missing references)
				//IL_0092: Unknown result type (might be due to invalid IL or missing references)
				//IL_0060: Unknown result type (might be due to invalid IL or missing references)
				//IL_0061: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
				//IL_0105: Unknown result type (might be due to invalid IL or missing references)
				//IL_0127: Unknown result type (might be due to invalid IL or missing references)
				//IL_012b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0130: Unknown result type (might be due to invalid IL or missing references)
				//IL_0135: Unknown result type (might be due to invalid IL or missing references)
				//IL_0136: Unknown result type (might be due to invalid IL or missing references)
				//IL_013b: Unknown result type (might be due to invalid IL or missing references)
				//IL_013d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0141: Unknown result type (might be due to invalid IL or missing references)
				//IL_0146: Unknown result type (might be due to invalid IL or missing references)
				//IL_014b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0151: Unknown result type (might be due to invalid IL or missing references)
				//IL_0157: Unknown result type (might be due to invalid IL or missing references)
				//IL_015c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0161: Unknown result type (might be due to invalid IL or missing references)
				//IL_0177: Unknown result type (might be due to invalid IL or missing references)
				//IL_017c: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
				//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
				Rect val = (hoveredZones.GetValue(__instance) as List<Rect>)[0];
				if ((double)((Vector2)(ref input)).magnitude < 0.4)
				{
					__result = val;
					return false;
				}
				object? value = program.GetValue(__instance);
				ScreenProgram val2 = (ScreenProgram)((value is ScreenProgram) ? value : null);
				if (val2.mouseButton)
				{
					__result = val;
					return false;
				}
				input.y = 0f - input.y;
				List<(Rect, float, float)> list = new List<(Rect, float, float)>();
				Vector2 normalized = ((Vector2)(ref input)).normalized;
				float num = 10000f;
				Rect val3 = val;
				Vector2 val4 = default(Vector2);
				foreach (Rect zone in __instance.zones)
				{
					Rect current = zone;
					if (!((double)Vector2.Dot(((Rect)(ref current)).center - ((Rect)(ref val)).center, normalized) < 0.1))
					{
						((Vector2)(ref val4))..ctor(Mathf.Clamp(((Rect)(ref val)).center.x, ((Rect)(ref current)).xMin, ((Rect)(ref current)).xMax), Mathf.Clamp(((Rect)(ref val)).center.y, ((Rect)(ref current)).yMin, ((Rect)(ref current)).yMax));
						Vector2 val5 = (val4 - ((Rect)(ref val)).center) * normalized;
						Vector2 val6 = (val4 - ((Rect)(ref val)).center) * new Vector2(normalized.y, normalized.x);
						Vector2 val7 = new Vector2(((Vector2)(ref val6)).magnitude * 100f, ((Vector2)(ref val5)).magnitude);
						float magnitude = ((Vector2)(ref val7)).magnitude;
						if (!(magnitude < 1f) && magnitude < num)
						{
							num = magnitude;
							val3 = current;
						}
					}
				}
				__result = val3;
				return false;
			}
		}

		[HarmonyPatch(typeof(GamepadNavigation), "GoToZone")]
		private class DragPatch : HarmonyPatch
		{
			private static bool Prefix(GamepadNavigation __instance)
			{
				//IL_003d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0043: Unknown result type (might be due to invalid IL or missing references)
				//IL_004d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0057: Unknown result type (might be due to invalid IL or missing references)
				//IL_0066: Unknown result type (might be due to invalid IL or missing references)
				//IL_006b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0070: Unknown result type (might be due to invalid IL or missing references)
				//IL_0075: Unknown result type (might be due to invalid IL or missing references)
				if ((double)((Vector2)(ref __instance.menuInput)).magnitude < 0.4)
				{
					return false;
				}
				object? value = program.GetValue(__instance);
				ScreenProgram val = (ScreenProgram)((value is ScreenProgram) ? value : null);
				if (val.mouseButton)
				{
					ScreenSystem.mouse += __instance.menuInput * Time.deltaTime * 100f * new Vector2(1f, -1f);
					return false;
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(GamepadNavigation), "DoZones")]
		private class DragPatch2 : HarmonyPatch
		{
			private static void Postfix(GamepadNavigation __instance)
			{
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				//IL_002e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0038: Unknown result type (might be due to invalid IL or missing references)
				//IL_0042: Unknown result type (might be due to invalid IL or missing references)
				//IL_0051: Unknown result type (might be due to invalid IL or missing references)
				//IL_0056: Unknown result type (might be due to invalid IL or missing references)
				//IL_005b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0060: Unknown result type (might be due to invalid IL or missing references)
				object? value = program.GetValue(__instance);
				ScreenProgram val = (ScreenProgram)((value is ScreenProgram) ? value : null);
				if (!__instance.menuInputChanged && val.mouseButton)
				{
					ScreenSystem.mouse += __instance.menuInput * Time.deltaTime * 100f * new Vector2(1f, -1f);
				}
			}
		}

		[HarmonyPatch]
		private class SliderFix : HarmonyPatch
		{
			private static MethodInfo TargetMethod()
			{
				return typeof(sOptionsMenu).GetMethod("Slider", BindingFlags.Instance | BindingFlags.NonPublic);
			}

			private static bool Prefix(sOptionsMenu __instance, string name, float value, float x, float y, Action<float> action)
			{
				object? value2 = R.GetValue(__instance);
				MiniRenderer val = (MiniRenderer)((value2 is MiniRenderer) ? value2 : null);
				object? value3 = M.GetValue(__instance);
				DesktopDotExe val2 = (DesktopDotExe)((value3 is DesktopDotExe) ? value3 : null);
				int num = 10;
				for (int i = 0; i < num; i++)
				{
					val.spr(32f, 0f, x + 4f + (float)(i * 8), y, 8f, 8f);
				}
				float num2 = x + value * (float)num * 8f;
				val.spr(0f, 24f, num2, y, 8f, 8f);
				if (val2.MouseOver((int)x - 8, (int)y, num * 8 + 16, 8))
				{
					((ScreenProgram)val2).mouseIcon = 128;
					name = ">" + name;
					if (((ScreenProgram)val2).mouseButton)
					{
						if (val2.nav.menuInput.x < 0f)
						{
							action(Mathf.Clamp01(value - Time.unscaledDeltaTime / 2f));
						}
						if (val2.nav.menuInput.x > 0f)
						{
							action(Mathf.Clamp01(value + Time.unscaledDeltaTime / 2f));
						}
						((ScreenProgram)val2).mouseIcon = 160;
						value = Mathf.InverseLerp(x + 4f, x + 4f + (float)(num * 8), ((ScreenProgram)val2).mouse.x);
						value = Mathf.Clamp01(value);
						action(value);
					}
				}
				val.put(name, x - (float)(name.Length * 8) - 4f, y);
				return false;
			}
		}

		[HarmonyPatch]
		private class OptionsPatch : HarmonyPatch
		{
			private static MethodInfo TargetMethod()
			{
				return typeof(sOptionsMenu).GetMethod("DrawMenu", BindingFlags.Instance | BindingFlags.NonPublic);
			}

			private static void Prefix(sOptionsMenu __instance, Rect p)
			{
				object? value = M.GetValue(__instance);
				DesktopDotExe val = (DesktopDotExe)((value is DesktopDotExe) ? value : null);
				object? value2 = R.GetValue(__instance);
				MiniRenderer pR = (MiniRenderer)((value2 is MiniRenderer) ? value2 : null);
				UIUtil uIUtil = new UIUtil(pR, (ScreenProgram)(object)val, val.nav);
				float num = ((Rect)(ref p)).x + ((Rect)(ref p)).width / 2f - 16f;
				float num2 = ((Rect)(ref p)).y + 10f;
				uIUtil.nav.Add(((Rect)(ref p)).x + ((Rect)(ref p)).width - 40f, ((Rect)(ref p)).y + ((Rect)(ref p)).height - 84f, 1000f, 8f);
				if (uIUtil.Button("mods", ((Rect)(ref p)).x + ((Rect)(ref p)).width - 40f, ((Rect)(ref p)).y + ((Rect)(ref p)).height - 8f, smol: true))
				{
					EasyAPI.ChangeWindow(val, "modded settings", "modsettingslist");
				}
			}
		}

		private static FieldInfo M = typeof(sOptionsMenu).GetField("M", BindingFlags.Instance | BindingFlags.NonPublic);

		private static FieldInfo R = typeof(sOptionsMenu).GetField("R", BindingFlags.Instance | BindingFlags.NonPublic);

		private static FieldInfo hoveredZones = typeof(GamepadNavigation).GetField("hoveredZones", BindingFlags.Instance | BindingFlags.NonPublic);

		private static FieldInfo program = typeof(GamepadNavigation).GetField("program", BindingFlags.Instance | BindingFlags.NonPublic);
	}
	public class UIUtil
	{
		private static MethodInfo ActivateInputFieldInternal = typeof(InputField).GetMethod("ActivateInputFieldInternal", BindingFlags.Instance | BindingFlags.NonPublic);

		public bool NavEnabled;

		public ScreenProgram M;

		public GamepadNavigation nav;

		public MiniRenderer R;

		public bool MouseOver(float x, float y, float w, float h)
		{
			bool flag = M.mouse.x > x && M.mouse.x < x + w;
			bool flag2 = M.mouse.y > y && M.mouse.y < y + h;
			nav.Add(x, y, w, h);
			return flag && flag2;
		}

		public bool MouseOver(int x, int y, int w, int h)
		{
			bool flag = M.mouse.x > (float)x && M.mouse.x < (float)(x + w);
			bool flag2 = M.mouse.y > (float)y && M.mouse.y < (float)(y + h);
			nav.Add((float)x, (float)y, (float)w, (float)h);
			return flag && flag2;
		}

		public float? Adjustable(string name, string value, float delta, float x, float y)
		{
			bool Hovered;
			return Adjustable(name, value, delta, x, y, out Hovered);
		}

		public float? Adjustable(string name, string value, float delta, float x, float y, out bool Hovered)
		{
			x -= 4f;
			Hovered = false;
			float? result = null;
			R.put(name, x - (float)(name.Length * 8), y);
			if (Button("[-]", x - (float)(name.Length * 8) - 24f, y, out Hovered, smol: true))
			{
				result = delta * -1f;
			}
			x += 32f;
			R.put(value, x - (float)(value.Length * 8), y);
			string name2 = "[+]";
			if (Button(name2, x, y, out Hovered, smol: true))
			{
				result = delta;
			}
			return result;
		}

		public bool Button(string name, float x, float y, bool smol = false, bool manualhover = false)
		{
			bool Hovered;
			return Button(name, x, y, out Hovered, smol, manualhover);
		}

		public bool Button(string name, float x, float y, out bool Hovered, bool smol = false, bool manualhover = false)
		{
			Hovered = false;
			bool result = false;
			if (MouseOver((int)x - 2, (int)y, name.Length * 8 + 4, 8))
			{
				Hovered = true;
				if (!smol)
				{
					x += 4f;
					name = ">" + name;
				}
				M.mouseIcon = 128;
				if (M.mouseButton)
				{
					M.mouseIcon = 160;
				}
				if (M.mouseButtonUp)
				{
					result = true;
				}
			}
			else if (manualhover)
			{
				x += 4f;
				name = ">" + name;
			}
			R.put(name, x, y);
			return result;
		}

		public void DrawInput(InputField Field, string PlaceholderText, float x, float y)
		{
			DrawInput(Field, PlaceholderText, x, y, out var _);
		}

		public void DrawInput(InputField Field, string PlaceholderText, float x, float y, out bool Hovered)
		{
			Hovered = false;
			if (Button((Field.text == "") ? PlaceholderText : Field.text, x, y, out Hovered, smol: false, Field.isFocused))
			{
				ActivateInputFieldInternal.Invoke(Field, Array.Empty<object>());
			}
		}

		public string Dropdown(string name, int value, string[] options, float x, float y)
		{
			bool Hovered;
			return Dropdown(name, value, options, x, y, out Hovered);
		}

		public string Dropdown(string name, int value, string[] options, float x, float y, out bool Hovered)
		{
			Hovered = false;
			string result = null;
			string text = "[" + options[value] + "]";
			R.put(text, x + 4f, y);
			if (MouseOver((int)x - 2, (int)y, text.Length * 8 + 4, 8))
			{
				Hovered = true;
				M.mouseIcon = 128;
				name = ">" + name;
				if (M.mouseButton)
				{
					M.mouseIcon = 160;
				}
				if (M.mouseButtonUp)
				{
					result = options[(value + 1) % options.Length];
				}
			}
			R.put(name, x - (float)(name.Length * 8) - 4f, y);
			return result;
		}

		public bool? Toggle(string name, bool state, float x, float y, out bool Hovered)
		{
			Hovered = false;
			return Toggle(name, state, x, y, "on", "off", out Hovered);
		}

		public bool? Toggle(string name, bool state, float x, float y)
		{
			bool Hovered;
			return Toggle(name, state, x, y, "on", "off", out Hovered);
		}

		public bool? Toggle(string name, bool state, float x, float y, string on, string off)
		{
			bool Hovered;
			return Toggle(name, state, x, y, on, off, out Hovered);
		}

		public bool? Toggle(string name, bool state, float x, float y, string on, string off, out bool Hovered)
		{
			Hovered = false;
			bool? result = null;
			string text = "[" + (state ? on : off) + "]";
			R.put(text, x + 4f, y);
			if (MouseOver((int)x - 2, (int)y, text.Length * 8 + 4, 8))
			{
				Hovered = true;
				M.mouseIcon = 128;
				name = ">" + name;
				if (M.mouseButton)
				{
					M.mouseIcon = 160;
				}
				if (M.mouseButtonUp)
				{
					result = !state;
				}
			}
			R.put(name, x - (float)(name.Length * 8) - 4f, y);
			return result;
		}

		public float? Slider(string name, float value, float x, float y)
		{
			bool Hovered;
			return Slider(name, value, x, y, out Hovered);
		}

		public float? Slider(string name, float value, float x, float y, out bool Hovered)
		{
			Hovered = false;
			float? result = null;
			int num = 10;
			for (int i = 0; i < num; i++)
			{
				R.spr(32f, 0f, x + 4f + (float)(i * 8), y, 8f, 8f);
			}
			float num2 = x + value * (float)num * 8f;
			R.spr(0f, 24f, num2, y, 8f, 8f);
			if (MouseOver((int)x - 8, (int)y, num * 8 + 16, 8))
			{
				Hovered = true;
				M.mouseIcon = 128;
				name = ">" + name;
				if (M.mouseButton)
				{
					if (nav.menuInput.x < 0f)
					{
						result = Mathf.Clamp01(value - Time.unscaledDeltaTime / 2f);
					}
					if (nav.menuInput.x > 0f)
					{
						result = Mathf.Clamp01(value + Time.unscaledDeltaTime / 2f);
					}
					M.mouseIcon = 160;
					value = Mathf.InverseLerp(x + 4f, x + 4f + (float)(num * 8), M.mouse.x);
					value = Mathf.Clamp01(value);
					result = value;
				}
			}
			R.put(name, x - (float)(name.Length * 8) - 4f, y);
			return result;
		}

		public static string FormatLine(string input, float w)
		{
			string[] array = input.Split(new char[1] { ' ' });
			string text = array[0];
			string text2 = "";
			for (int i = 1; i < array.Length; i++)
			{
				if ((float)(text.Length + array[i].Length) <= w)
				{
					text = text + " " + array[i];
					continue;
				}
				text2 = text2 + "\n" + text;
				text = array[i];
			}
			return text2 + "\n" + text;
		}

		public void tile(float sx, float sy, float x, float y)
		{
			R.spr(sx, sy, x * 8f, y * 8f, 8f, 8f);
		}

		public static void tile(MiniRenderer R, float sx, float sy, float x, float y)
		{
			R.spr(sx, sy, x * 8f, y * 8f, 8f, 8f);
		}

		public void drawBox(float x, float y, float w, float h, bool hasTop)
		{
			int num = (hasTop ? 24 : 0);
			int num2 = (hasTop ? 16 : 0);
			for (int i = (int)x + 1; (float)i < x + w; i++)
			{
				tile(8 + num, num2, i, y);
				tile(8f, 16f, i, y + h);
			}
			for (int j = (int)y + 1; (float)j < y + h; j++)
			{
				tile(0f, 8f, x, j);
				tile(16f, 8f, x + w, j);
			}
			tile(0f, 16f, x, y + h);
			tile(16f, 16f, x + w, y + h);
			tile(num, num2, x, y);
			tile(16 + num, num2, x + w, y);
		}

		public static void drawBox(MiniRenderer R, float x, float y, float w, float h, bool hasTop)
		{
			int num = (hasTop ? 24 : 0);
			int num2 = (hasTop ? 16 : 0);
			for (int i = (int)x + 1; (float)i < x + w; i++)
			{
				tile(R, 8 + num, num2, i, y);
				tile(R, 8f, 16f, i, y + h);
			}
			for (int j = (int)y + 1; (float)j < y + h; j++)
			{
				tile(R, 0f, 8f, x, j);
				tile(R, 16f, 8f, x + w, j);
			}
			tile(R, 0f, 16f, x, y + h);
			tile(R, 16f, 16f, x + w, y + h);
			tile(R, num, num2, x, y);
			tile(R, 16 + num, num2, x + w, y);
		}

		public static void drawBox(MiniRenderer R, float x, float y, float w, float h, bool hasTop, string title)
		{
			drawBox(R, x, y, w, h, hasTop);
			R.put(title, x * 8f + 8f, y * 8f);
		}

		public void drawBox(float x, float y, float w, float h, bool hasTop, string title)
		{
			drawBox(x, y, w, h, hasTop);
			R.put(title, x * 8f + 8f, y * 8f);
		}

		public UIUtil(MiniRenderer PR, ScreenProgram PM, GamepadNavigation pnav)
		{
			R = PR;
			M = PM;
			nav = pnav;
		}

		public UIUtil()
		{
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "EasyDeliveryAPI";

		public const string PLUGIN_NAME = "EasyDeliveryAPI";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}

plugins/Newtonsoft.Json.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Data;
using System.Data.SqlTypes;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Dynamic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Numerics;
using System.Reflection;
using System.Reflection.Emit;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Linq;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json.Bson;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Linq.JsonPath;
using Newtonsoft.Json.Schema;
using Newtonsoft.Json.Serialization;
using Newtonsoft.Json.Utilities;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AllowPartiallyTrustedCallers]
[assembly: InternalsVisibleTo("Newtonsoft.Json.Schema, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f561df277c6c0b497d629032b410cdcf286e537c054724f7ffa0164345f62b3e642029d7a80cc351918955328c4adc8a048823ef90b0cf38ea7db0d729caf2b633c3babe08b0310198c1081995c19029bc675193744eab9d7345b8a67258ec17d112cebdbbb2a281487dceeafb9d83aa930f32103fbe1d2911425bc5744002c7")]
[assembly: InternalsVisibleTo("Newtonsoft.Json.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f561df277c6c0b497d629032b410cdcf286e537c054724f7ffa0164345f62b3e642029d7a80cc351918955328c4adc8a048823ef90b0cf38ea7db0d729caf2b633c3babe08b0310198c1081995c19029bc675193744eab9d7345b8a67258ec17d112cebdbbb2a281487dceeafb9d83aa930f32103fbe1d2911425bc5744002c7")]
[assembly: InternalsVisibleTo("Newtonsoft.Json.Dynamic, PublicKey=0024000004800000940000000602000000240000525341310004000001000100cbd8d53b9d7de30f1f1278f636ec462cf9c254991291e66ebb157a885638a517887633b898ccbcf0d5c5ff7be85a6abe9e765d0ac7cd33c68dac67e7e64530e8222101109f154ab14a941c490ac155cd1d4fcba0fabb49016b4ef28593b015cab5937da31172f03f67d09edda404b88a60023f062ae71d0b2e4438b74cc11dc9")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("9ca358aa-317b-4925-8ada-4a29e943a363")]
[assembly: CLSCompliant(true)]
[assembly: TargetFramework(".NETFramework,Version=v4.5", FrameworkDisplayName = ".NET Framework 4.5")]
[assembly: AssemblyCompany("Newtonsoft")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("Copyright © James Newton-King 2008")]
[assembly: AssemblyDescription("Json.NET is a popular high-performance JSON framework for .NET")]
[assembly: AssemblyFileVersion("13.0.4.30916")]
[assembly: AssemblyInformationalVersion("13.0.4+4e13299d4b0ec96bd4df9954ef646bd2d1b5bf2a")]
[assembly: AssemblyProduct("Json.NET")]
[assembly: AssemblyTitle("Json.NET .NET 4.5")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/JamesNK/Newtonsoft.Json")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: AssemblyVersion("13.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class IsReadOnlyAttribute : Attribute
	{
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace System.Diagnostics.CodeAnalysis
{
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Interface | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, Inherited = false)]
	internal sealed class DynamicallyAccessedMembersAttribute : Attribute
	{
		public DynamicallyAccessedMemberTypes MemberTypes { get; }

		public DynamicallyAccessedMembersAttribute(DynamicallyAccessedMemberTypes memberTypes)
		{
			MemberTypes = memberTypes;
		}
	}
	[Flags]
	internal enum DynamicallyAccessedMemberTypes
	{
		None = 0,
		PublicParameterlessConstructor = 1,
		PublicConstructors = 3,
		NonPublicConstructors = 4,
		PublicMethods = 8,
		NonPublicMethods = 0x10,
		PublicFields = 0x20,
		NonPublicFields = 0x40,
		PublicNestedTypes = 0x80,
		NonPublicNestedTypes = 0x100,
		PublicProperties = 0x200,
		NonPublicProperties = 0x400,
		PublicEvents = 0x800,
		NonPublicEvents = 0x1000,
		Interfaces = 0x2000,
		All = -1
	}
	[AttributeUsage(AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
	internal sealed class FeatureGuardAttribute : Attribute
	{
		public Type FeatureType { get; }

		public FeatureGuardAttribute(Type featureType)
		{
			FeatureType = featureType;
		}
	}
	[AttributeUsage(AttributeTargets.Property, Inherited = false)]
	internal sealed class FeatureSwitchDefinitionAttribute : Attribute
	{
		public string SwitchName { get; }

		public FeatureSwitchDefinitionAttribute(string switchName)
		{
			SwitchName = switchName;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = true)]
	internal sealed class NotNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false)]
	internal sealed class NotNullWhenAttribute : Attribute
	{
		public bool ReturnValue { get; }

		public NotNullWhenAttribute(bool returnValue)
		{
			ReturnValue = returnValue;
		}
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, Inherited = false)]
	internal sealed class MaybeNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)]
	internal sealed class AllowNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	internal class DoesNotReturnIfAttribute : Attribute
	{
		public bool ParameterValue { get; }

		public DoesNotReturnIfAttribute(bool parameterValue)
		{
			ParameterValue = parameterValue;
		}
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Method, Inherited = false)]
	internal sealed class RequiresDynamicCodeAttribute : Attribute
	{
		public string Message { get; }

		public string? Url { get; set; }

		public RequiresDynamicCodeAttribute(string message)
		{
			Message = message;
		}
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Method, Inherited = false)]
	internal sealed class RequiresUnreferencedCodeAttribute : Attribute
	{
		public string Message { get; }

		public string? Url { get; set; }

		public RequiresUnreferencedCodeAttribute(string message)
		{
			Message = message;
		}
	}
	[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
	internal sealed class UnconditionalSuppressMessageAttribute : Attribute
	{
		public string Category { get; }

		public string CheckId { get; }

		public string? Scope { get; set; }

		public string? Target { get; set; }

		public string? MessageId { get; set; }

		public string? Justification { get; set; }

		public UnconditionalSuppressMessageAttribute(string category, string checkId)
		{
			Category = category;
			CheckId = checkId;
		}
	}
}
namespace Newtonsoft.Json
{
	public enum ConstructorHandling
	{
		Default,
		AllowNonPublicDefaultConstructor
	}
	public enum DateFormatHandling
	{
		IsoDateFormat,
		MicrosoftDateFormat
	}
	public enum DateParseHandling
	{
		None,
		DateTime,
		DateTimeOffset
	}
	public enum DateTimeZoneHandling
	{
		Local,
		Utc,
		Unspecified,
		RoundtripKind
	}
	public class DefaultJsonNameTable : JsonNameTable
	{
		private class Entry
		{
			internal readonly string Value;

			internal readonly int HashCode;

			internal Entry Next;

			internal Entry(string value, int hashCode, Entry next)
			{
				Value = value;
				HashCode = hashCode;
				Next = next;
			}
		}

		private static readonly int HashCodeRandomizer;

		private int _count;

		private Entry[] _entries;

		private int _mask = 31;

		static DefaultJsonNameTable()
		{
			HashCodeRandomizer = Environment.TickCount;
		}

		public DefaultJsonNameTable()
		{
			_entries = new Entry[_mask + 1];
		}

		public override string? Get(char[] key, int start, int length)
		{
			if (length == 0)
			{
				return string.Empty;
			}
			int num = length + HashCodeRandomizer;
			num += (num << 7) ^ key[start];
			int num2 = start + length;
			for (int i = start + 1; i < num2; i++)
			{
				num += (num << 7) ^ key[i];
			}
			num -= num >> 17;
			num -= num >> 11;
			num -= num >> 5;
			int num3 = Volatile.Read(ref _mask);
			int num4 = num & num3;
			for (Entry entry = _entries[num4]; entry != null; entry = entry.Next)
			{
				if (entry.HashCode == num && TextEquals(entry.Value, key, start, length))
				{
					return entry.Value;
				}
			}
			return null;
		}

		public string Add(string key)
		{
			if (key == null)
			{
				throw new ArgumentNullException("key");
			}
			int length = key.Length;
			if (length == 0)
			{
				return string.Empty;
			}
			int num = length + HashCodeRandomizer;
			for (int i = 0; i < key.Length; i++)
			{
				num += (num << 7) ^ key[i];
			}
			num -= num >> 17;
			num -= num >> 11;
			num -= num >> 5;
			for (Entry entry = _entries[num & _mask]; entry != null; entry = entry.Next)
			{
				if (entry.HashCode == num && entry.Value.Equals(key, StringComparison.Ordinal))
				{
					return entry.Value;
				}
			}
			return AddEntry(key, num);
		}

		private string AddEntry(string str, int hashCode)
		{
			int num = hashCode & _mask;
			Entry entry = new Entry(str, hashCode, _entries[num]);
			_entries[num] = entry;
			if (_count++ == _mask)
			{
				Grow();
			}
			return entry.Value;
		}

		private void Grow()
		{
			Entry[] entries = _entries;
			int num = _mask * 2 + 1;
			Entry[] array = new Entry[num + 1];
			for (int i = 0; i < entries.Length; i++)
			{
				Entry entry = entries[i];
				while (entry != null)
				{
					int num2 = entry.HashCode & num;
					Entry next = entry.Next;
					entry.Next = array[num2];
					array[num2] = entry;
					entry = next;
				}
			}
			_entries = array;
			Volatile.Write(ref _mask, num);
		}

		private static bool TextEquals(string str1, char[] str2, int str2Start, int str2Length)
		{
			if (str1.Length != str2Length)
			{
				return false;
			}
			for (int i = 0; i < str1.Length; i++)
			{
				if (str1[i] != str2[str2Start + i])
				{
					return false;
				}
			}
			return true;
		}
	}
	[Flags]
	public enum DefaultValueHandling
	{
		Include = 0,
		Ignore = 1,
		Populate = 2,
		IgnoreAndPopulate = 3
	}
	public enum FloatFormatHandling
	{
		String,
		Symbol,
		DefaultValue
	}
	public enum FloatParseHandling
	{
		Double,
		Decimal
	}
	public enum Formatting
	{
		None,
		Indented
	}
	public interface IArrayPool<T>
	{
		T[] Rent(int minimumLength);

		void Return(T[]? array);
	}
	public interface IJsonLineInfo
	{
		int LineNumber { get; }

		int LinePosition { get; }

		bool HasLineInfo();
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = false)]
	public sealed class JsonArrayAttribute : JsonContainerAttribute
	{
		private bool _allowNullItems;

		public bool AllowNullItems
		{
			get
			{
				return _allowNullItems;
			}
			set
			{
				_allowNullItems = value;
			}
		}

		public JsonArrayAttribute()
		{
		}

		public JsonArrayAttribute(bool allowNullItems)
		{
			_allowNullItems = allowNullItems;
		}

		public JsonArrayAttribute(string id)
			: base(id)
		{
		}
	}
	[AttributeUsage(AttributeTargets.Constructor, AllowMultiple = false)]
	public sealed class JsonConstructorAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = false)]
	public abstract class JsonContainerAttribute : Attribute
	{
		internal bool? _isReference;

		internal bool? _itemIsReference;

		internal ReferenceLoopHandling? _itemReferenceLoopHandling;

		internal TypeNameHandling? _itemTypeNameHandling;

		private Type? _namingStrategyType;

		private object[]? _namingStrategyParameters;

		public string? Id { get; set; }

		public string? Title { get; set; }

		public string? Description { get; set; }

		public Type? ItemConverterType { get; set; }

		public object[]? ItemConverterParameters { get; set; }

		public Type? NamingStrategyType
		{
			get
			{
				return _namingStrategyType;
			}
			set
			{
				_namingStrategyType = value;
				NamingStrategyInstance = null;
			}
		}

		public object[]? NamingStrategyParameters
		{
			get
			{
				return _namingStrategyParameters;
			}
			set
			{
				_namingStrategyParameters = value;
				NamingStrategyInstance = null;
			}
		}

		internal NamingStrategy? NamingStrategyInstance { get; set; }

		public bool IsReference
		{
			get
			{
				return _isReference.GetValueOrDefault();
			}
			set
			{
				_isReference = value;
			}
		}

		public bool ItemIsReference
		{
			get
			{
				return _itemIsReference.GetValueOrDefault();
			}
			set
			{
				_itemIsReference = value;
			}
		}

		public ReferenceLoopHandling ItemReferenceLoopHandling
		{
			get
			{
				return _itemReferenceLoopHandling.GetValueOrDefault();
			}
			set
			{
				_itemReferenceLoopHandling = value;
			}
		}

		public TypeNameHandling ItemTypeNameHandling
		{
			get
			{
				return _itemTypeNameHandling.GetValueOrDefault();
			}
			set
			{
				_itemTypeNameHandling = value;
			}
		}

		protected JsonContainerAttribute()
		{
		}

		protected JsonContainerAttribute(string id)
		{
			Id = id;
		}
	}
	public static class JsonConvert
	{
		public static readonly string True = "true";

		public static readonly string False = "false";

		public static readonly string Null = "null";

		public static readonly string Undefined = "undefined";

		public static readonly string PositiveInfinity = "Infinity";

		public static readonly string NegativeInfinity = "-Infinity";

		public static readonly string NaN = "NaN";

		public static Func<JsonSerializerSettings>? DefaultSettings { get; set; }

		public static string ToString(DateTime value)
		{
			return ToString(value, DateFormatHandling.IsoDateFormat, DateTimeZoneHandling.RoundtripKind);
		}

		public static string ToString(DateTime value, DateFormatHandling format, DateTimeZoneHandling timeZoneHandling)
		{
			DateTime value2 = DateTimeUtils.EnsureDateTime(value, timeZoneHandling);
			using StringWriter stringWriter = StringUtils.CreateStringWriter(64);
			stringWriter.Write('"');
			DateTimeUtils.WriteDateTimeString(stringWriter, value2, format, null, CultureInfo.InvariantCulture);
			stringWriter.Write('"');
			return stringWriter.ToString();
		}

		public static string ToString(DateTimeOffset value)
		{
			return ToString(value, DateFormatHandling.IsoDateFormat);
		}

		public static string ToString(DateTimeOffset value, DateFormatHandling format)
		{
			using StringWriter stringWriter = StringUtils.CreateStringWriter(64);
			stringWriter.Write('"');
			DateTimeUtils.WriteDateTimeOffsetString(stringWriter, value, format, null, CultureInfo.InvariantCulture);
			stringWriter.Write('"');
			return stringWriter.ToString();
		}

		public static string ToString(bool value)
		{
			if (!value)
			{
				return False;
			}
			return True;
		}

		public static string ToString(char value)
		{
			return ToString(char.ToString(value));
		}

		public static string ToString(Enum value)
		{
			return value.ToString("D");
		}

		public static string ToString(int value)
		{
			return value.ToString(null, CultureInfo.InvariantCulture);
		}

		public static string ToString(short value)
		{
			return value.ToString(null, CultureInfo.InvariantCulture);
		}

		[CLSCompliant(false)]
		public static string ToString(ushort value)
		{
			return value.ToString(null, CultureInfo.InvariantCulture);
		}

		[CLSCompliant(false)]
		public static string ToString(uint value)
		{
			return value.ToString(null, CultureInfo.InvariantCulture);
		}

		public static string ToString(long value)
		{
			return value.ToString(null, CultureInfo.InvariantCulture);
		}

		private static string ToStringInternal(BigInteger value)
		{
			return value.ToString(null, CultureInfo.InvariantCulture);
		}

		[CLSCompliant(false)]
		public static string ToString(ulong value)
		{
			return value.ToString(null, CultureInfo.InvariantCulture);
		}

		public static string ToString(float value)
		{
			return EnsureDecimalPlace(value, value.ToString("R", CultureInfo.InvariantCulture));
		}

		internal static string ToString(float value, FloatFormatHandling floatFormatHandling, char quoteChar, bool nullable)
		{
			return EnsureFloatFormat(value, EnsureDecimalPlace(value, value.ToString("R", CultureInfo.InvariantCulture)), floatFormatHandling, quoteChar, nullable);
		}

		private static string EnsureFloatFormat(double value, string text, FloatFormatHandling floatFormatHandling, char quoteChar, bool nullable)
		{
			if (floatFormatHandling == FloatFormatHandling.Symbol || (!double.IsInfinity(value) && !double.IsNaN(value)))
			{
				return text;
			}
			if (floatFormatHandling == FloatFormatHandling.DefaultValue)
			{
				if (nullable)
				{
					return Null;
				}
				return "0.0";
			}
			return quoteChar + text + quoteChar;
		}

		public static string ToString(double value)
		{
			return EnsureDecimalPlace(value, value.ToString("R", CultureInfo.InvariantCulture));
		}

		internal static string ToString(double value, FloatFormatHandling floatFormatHandling, char quoteChar, bool nullable)
		{
			return EnsureFloatFormat(value, EnsureDecimalPlace(value, value.ToString("R", CultureInfo.InvariantCulture)), floatFormatHandling, quoteChar, nullable);
		}

		private static string EnsureDecimalPlace(double value, string text)
		{
			if (double.IsNaN(value) || double.IsInfinity(value) || StringUtils.IndexOf(text, '.') != -1 || StringUtils.IndexOf(text, 'E') != -1 || StringUtils.IndexOf(text, 'e') != -1)
			{
				return text;
			}
			return text + ".0";
		}

		private static string EnsureDecimalPlace(string text)
		{
			if (StringUtils.IndexOf(text, '.') != -1)
			{
				return text;
			}
			return text + ".0";
		}

		public static string ToString(byte value)
		{
			return value.ToString(null, CultureInfo.InvariantCulture);
		}

		[CLSCompliant(false)]
		public static string ToString(sbyte value)
		{
			return value.ToString(null, CultureInfo.InvariantCulture);
		}

		public static string ToString(decimal value)
		{
			return EnsureDecimalPlace(value.ToString(null, CultureInfo.InvariantCulture));
		}

		public static string ToString(Guid value)
		{
			return ToString(value, '"');
		}

		internal static string ToString(Guid value, char quoteChar)
		{
			string text = value.ToString("D", CultureInfo.InvariantCulture);
			string text2 = quoteChar.ToString(CultureInfo.InvariantCulture);
			return text2 + text + text2;
		}

		public static string ToString(TimeSpan value)
		{
			return ToString(value, '"');
		}

		internal static string ToString(TimeSpan value, char quoteChar)
		{
			return ToString(value.ToString(), quoteChar);
		}

		public static string ToString(Uri? value)
		{
			if (value == null)
			{
				return Null;
			}
			return ToString(value, '"');
		}

		internal static string ToString(Uri value, char quoteChar)
		{
			return ToString(value.OriginalString, quoteChar);
		}

		public static string ToString(string? value)
		{
			return ToString(value, '"');
		}

		public static string ToString(string? value, char delimiter)
		{
			return ToString(value, delimiter, StringEscapeHandling.Default);
		}

		public static string ToString(string? value, char delimiter, StringEscapeHandling stringEscapeHandling)
		{
			if (delimiter != '"' && delimiter != '\'')
			{
				throw new ArgumentException("Delimiter must be a single or double quote.", "delimiter");
			}
			return JavaScriptUtils.ToEscapedJavaScriptString(value, delimiter, appendDelimiters: true, stringEscapeHandling);
		}

		public static string ToString(object? value)
		{
			if (value == null)
			{
				return Null;
			}
			return ConvertUtils.GetTypeCode(value.GetType()) switch
			{
				PrimitiveTypeCode.String => ToString((string)value), 
				PrimitiveTypeCode.Char => ToString((char)value), 
				PrimitiveTypeCode.Boolean => ToString((bool)value), 
				PrimitiveTypeCode.SByte => ToString((sbyte)value), 
				PrimitiveTypeCode.Int16 => ToString((short)value), 
				PrimitiveTypeCode.UInt16 => ToString((ushort)value), 
				PrimitiveTypeCode.Int32 => ToString((int)value), 
				PrimitiveTypeCode.Byte => ToString((byte)value), 
				PrimitiveTypeCode.UInt32 => ToString((uint)value), 
				PrimitiveTypeCode.Int64 => ToString((long)value), 
				PrimitiveTypeCode.UInt64 => ToString((ulong)value), 
				PrimitiveTypeCode.Single => ToString((float)value), 
				PrimitiveTypeCode.Double => ToString((double)value), 
				PrimitiveTypeCode.DateTime => ToString((DateTime)value), 
				PrimitiveTypeCode.Decimal => ToString((decimal)value), 
				PrimitiveTypeCode.DBNull => Null, 
				PrimitiveTypeCode.DateTimeOffset => ToString((DateTimeOffset)value), 
				PrimitiveTypeCode.Guid => ToString((Guid)value), 
				PrimitiveTypeCode.Uri => ToString((Uri)value), 
				PrimitiveTypeCode.TimeSpan => ToString((TimeSpan)value), 
				PrimitiveTypeCode.BigInteger => ToStringInternal((BigInteger)value), 
				_ => throw new ArgumentException("Unsupported type: {0}. Use the JsonSerializer class to get the object's JSON representation.".FormatWith(CultureInfo.InvariantCulture, value.GetType())), 
			};
		}

		[DebuggerStepThrough]
		[RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")]
		[RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")]
		public static string SerializeObject(object? value)
		{
			return SerializeObject(value, (Type?)null, (JsonSerializerSettings?)null);
		}

		[DebuggerStepThrough]
		[RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")]
		[RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")]
		public static string SerializeObject(object? value, Formatting formatting)
		{
			return SerializeObject(value, formatting, (JsonSerializerSettings?)null);
		}

		[DebuggerStepThrough]
		[RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")]
		[RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")]
		public static string SerializeObject(object? value, params JsonConverter[] converters)
		{
			JsonSerializerSettings settings = ((converters != null && converters.Length != 0) ? new JsonSerializerSettings
			{
				Converters = converters
			} : null);
			return SerializeObject(value, null, settings);
		}

		[DebuggerStepThrough]
		[RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")]
		[RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")]
		public static string SerializeObject(object? value, Formatting formatting, params JsonConverter[] converters)
		{
			JsonSerializerSettings settings = ((converters != null && converters.Length != 0) ? new JsonSerializerSettings
			{
				Converters = converters
			} : null);
			return SerializeObject(value, null, formatting, settings);
		}

		[DebuggerStepThrough]
		[RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")]
		[RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")]
		public static string SerializeObject(object? value, JsonSerializerSettings? settings)
		{
			return SerializeObject(value, null, settings);
		}

		[DebuggerStepThrough]
		[RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")]
		[RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")]
		public static string SerializeObject(object? value, Type? type, JsonSerializerSettings? settings)
		{
			JsonSerializer jsonSerializer = JsonSerializer.CreateDefault(settings);
			return SerializeObjectInternal(value, type, jsonSerializer);
		}

		[DebuggerStepThrough]
		[RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")]
		[RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")]
		public static string SerializeObject(object? value, Formatting formatting, JsonSerializerSettings? settings)
		{
			return SerializeObject(value, null, formatting, settings);
		}

		[DebuggerStepThrough]
		[RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")]
		[RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")]
		public static string SerializeObject(object? value, Type? type, Formatting formatting, JsonSerializerSettings? settings)
		{
			JsonSerializer jsonSerializer = JsonSerializer.CreateDefault(settings);
			jsonSerializer.Formatting = formatting;
			return SerializeObjectInternal(value, type, jsonSerializer);
		}

		[RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")]
		[RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")]
		private static string SerializeObjectInternal(object? value, Type? type, JsonSerializer jsonSerializer)
		{
			StringWriter stringWriter = new StringWriter(new StringBuilder(256), CultureInfo.InvariantCulture);
			using (JsonTextWriter jsonTextWriter = new JsonTextWriter(stringWriter))
			{
				jsonTextWriter.Formatting = jsonSerializer.Formatting;
				jsonSerializer.Serialize(jsonTextWriter, value, type);
			}
			return stringWriter.ToString();
		}

		[DebuggerStepThrough]
		[RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")]
		[RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")]
		public static object? DeserializeObject(string value)
		{
			return DeserializeObject(value, (Type?)null, (JsonSerializerSettings?)null);
		}

		[DebuggerStepThrough]
		[RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")]
		[RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")]
		public static object? DeserializeObject(string value, JsonSerializerSettings settings)
		{
			return DeserializeObject(value, null, settings);
		}

		[DebuggerStepThrough]
		[RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")]
		[RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")]
		public static object? DeserializeObject(string value, Type type)
		{
			return DeserializeObject(value, type, (JsonSerializerSettings?)null);
		}

		[DebuggerStepThrough]
		[RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")]
		[RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")]
		public static T? DeserializeObject<T>(string value)
		{
			return JsonConvert.DeserializeObject<T>(value, (JsonSerializerSettings?)null);
		}

		[DebuggerStepThrough]
		[RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")]
		[RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")]
		public static T? DeserializeAnonymousType<T>(string value, T anonymousTypeObject)
		{
			return DeserializeObject<T>(value);
		}

		[DebuggerStepThrough]
		[RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")]
		[RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")]
		public static T? DeserializeAnonymousType<T>(string value, T anonymousTypeObject, JsonSerializerSettings settings)
		{
			return DeserializeObject<T>(value, settings);
		}

		[DebuggerStepThrough]
		[RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")]
		[RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")]
		public static T? DeserializeObject<T>(string value, params JsonConverter[] converters)
		{
			return (T)DeserializeObject(value, typeof(T), converters);
		}

		[DebuggerStepThrough]
		[RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")]
		[RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")]
		public static T? DeserializeObject<T>(string value, JsonSerializerSettings? settings)
		{
			return (T)DeserializeObject(value, typeof(T), settings);
		}

		[DebuggerStepThrough]
		[RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")]
		[RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")]
		public static object? DeserializeObject(string value, Type type, params JsonConverter[] converters)
		{
			JsonSerializerSettings settings = ((converters != null && converters.Length != 0) ? new JsonSerializerSettings
			{
				Converters = converters
			} : null);
			return DeserializeObject(value, type, settings);
		}

		[RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")]
		[RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")]
		public static object? DeserializeObject(string value, Type? type, JsonSerializerSettings? settings)
		{
			ValidationUtils.ArgumentNotNull(value, "value");
			JsonSerializer jsonSerializer = JsonSerializer.CreateDefault(settings);
			if (!jsonSerializer.IsCheckAdditionalContentSet())
			{
				jsonSerializer.CheckAdditionalContent = true;
			}
			using JsonTextReader reader = new JsonTextReader(new StringReader(value));
			return jsonSerializer.Deserialize(reader, type);
		}

		[DebuggerStepThrough]
		[RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")]
		[RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")]
		public static void PopulateObject(string value, object target)
		{
			PopulateObject(value, target, null);
		}

		[RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")]
		[RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")]
		public static void PopulateObject(string value, object target, JsonSerializerSettings? settings)
		{
			JsonSerializer jsonSerializer = JsonSerializer.CreateDefault(settings);
			using JsonReader jsonReader = new JsonTextReader(new StringReader(value));
			jsonSerializer.Populate(jsonReader, target);
			if (settings == null || !settings.CheckAdditionalContent)
			{
				return;
			}
			while (jsonReader.Read())
			{
				if (jsonReader.TokenType != JsonToken.Comment)
				{
					throw JsonSerializationException.Create(jsonReader, "Additional text found in JSON string after finishing deserializing object.");
				}
			}
		}

		[RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")]
		[RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")]
		public static string SerializeXmlNode(XmlNode? node)
		{
			return SerializeXmlNode(node, Formatting.None);
		}

		[RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")]
		[RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")]
		public static string SerializeXmlNode(XmlNode? node, Formatting formatting)
		{
			XmlNodeConverter xmlNodeConverter = new XmlNodeConverter();
			return SerializeObject(node, formatting, xmlNodeConverter);
		}

		[RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")]
		[RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")]
		public static string SerializeXmlNode(XmlNode? node, Formatting formatting, bool omitRootObject)
		{
			XmlNodeConverter xmlNodeConverter = new XmlNodeConverter
			{
				OmitRootObject = omitRootObject
			};
			return SerializeObject(node, formatting, xmlNodeConverter);
		}

		[RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")]
		[RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")]
		public static XmlDocument? DeserializeXmlNode(string value)
		{
			return DeserializeXmlNode(value, null);
		}

		[RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")]
		[RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")]
		public static XmlDocument? DeserializeXmlNode(string value, string? deserializeRootElementName)
		{
			return DeserializeXmlNode(value, deserializeRootElementName, writeArrayAttribute: false);
		}

		[RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")]
		[RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")]
		public static XmlDocument? DeserializeXmlNode(string value, string? deserializeRootElementName, bool writeArrayAttribute)
		{
			return DeserializeXmlNode(value, deserializeRootElementName, writeArrayAttribute, encodeSpecialCharacters: false);
		}

		[RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")]
		[RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")]
		public static XmlDocument? DeserializeXmlNode(string value, string? deserializeRootElementName, bool writeArrayAttribute, bool encodeSpecialCharacters)
		{
			XmlNodeConverter xmlNodeConverter = new XmlNodeConverter();
			xmlNodeConverter.DeserializeRootElementName = deserializeRootElementName;
			xmlNodeConverter.WriteArrayAttribute = writeArrayAttribute;
			xmlNodeConverter.EncodeSpecialCharacters = encodeSpecialCharacters;
			return (XmlDocument)DeserializeObject(value, typeof(XmlDocument), xmlNodeConverter);
		}

		[RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")]
		[RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")]
		public static string SerializeXNode(XObject? node)
		{
			return SerializeXNode(node, Formatting.None);
		}

		[RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")]
		[RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")]
		public static string SerializeXNode(XObject? node, Formatting formatting)
		{
			return SerializeXNode(node, formatting, omitRootObject: false);
		}

		[RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")]
		[RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")]
		public static string SerializeXNode(XObject? node, Formatting formatting, bool omitRootObject)
		{
			XmlNodeConverter xmlNodeConverter = new XmlNodeConverter
			{
				OmitRootObject = omitRootObject
			};
			return SerializeObject(node, formatting, xmlNodeConverter);
		}

		[RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")]
		[RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")]
		public static XDocument? DeserializeXNode(string value)
		{
			return DeserializeXNode(value, null);
		}

		[RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")]
		[RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")]
		public static XDocument? DeserializeXNode(string value, string? deserializeRootElementName)
		{
			return DeserializeXNode(value, deserializeRootElementName, writeArrayAttribute: false);
		}

		[RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")]
		[RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")]
		public static XDocument? DeserializeXNode(string value, string? deserializeRootElementName, bool writeArrayAttribute)
		{
			return DeserializeXNode(value, deserializeRootElementName, writeArrayAttribute, encodeSpecialCharacters: false);
		}

		[RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")]
		[RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")]
		public static XDocument? DeserializeXNode(string value, string? deserializeRootElementName, bool writeArrayAttribute, bool encodeSpecialCharacters)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			XmlNodeConverter xmlNodeConverter = new XmlNodeConverter();
			xmlNodeConverter.DeserializeRootElementName = deserializeRootElementName;
			xmlNodeConverter.WriteArrayAttribute = writeArrayAttribute;
			xmlNodeConverter.EncodeSpecialCharacters = encodeSpecialCharacters;
			return (XDocument)DeserializeObject(value, typeof(XDocument), xmlNodeConverter);
		}
	}
	public abstract class JsonConverter
	{
		public virtual bool CanRead => true;

		public virtual bool CanWrite => true;

		public abstract void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer);

		public abstract object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer);

		public abstract bool CanConvert(Type objectType);
	}
	public abstract class JsonConverter<T> : JsonConverter
	{
		public sealed override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer)
		{
			if (!((value != null) ? (value is T) : ReflectionUtils.IsNullable(typeof(T))))
			{
				throw new JsonSerializationException("Converter cannot write specified value to JSON. {0} is required.".FormatWith(CultureInfo.InvariantCulture, typeof(T)));
			}
			WriteJson(writer, (T)value, serializer);
		}

		public abstract void WriteJson(JsonWriter writer, T? value, JsonSerializer serializer);

		public sealed override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer)
		{
			bool flag = existingValue == null;
			if (!flag && !(existingValue is T))
			{
				throw new JsonSerializationException("Converter cannot read JSON with the specified existing value. {0} is required.".FormatWith(CultureInfo.InvariantCulture, typeof(T)));
			}
			return ReadJson(reader, objectType, flag ? default(T) : ((T)existingValue), !flag, serializer);
		}

		public abstract T? ReadJson(JsonReader reader, Type objectType, T? existingValue, bool hasExistingValue, JsonSerializer serializer);

		public sealed override bool CanConvert(Type objectType)
		{
			return typeof(T).IsAssignableFrom(objectType);
		}
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Interface | AttributeTargets.Parameter, AllowMultiple = false)]
	public sealed class JsonConverterAttribute : Attribute
	{
		private readonly Type _converterType;

		public Type ConverterType => _converterType;

		public object[]? ConverterParameters { get; }

		public JsonConverterAttribute(Type converterType)
		{
			if (converterType == null)
			{
				throw new ArgumentNullException("converterType");
			}
			_converterType = converterType;
		}

		public JsonConverterAttribute(Type converterType, params object[] converterParameters)
			: this(converterType)
		{
			ConverterParameters = converterParameters;
		}
	}
	public class JsonConverterCollection : Collection<JsonConverter>
	{
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = false)]
	public sealed class JsonDictionaryAttribute : JsonContainerAttribute
	{
		public JsonDictionaryAttribute()
		{
		}

		public JsonDictionaryAttribute(string id)
			: base(id)
		{
		}
	}
	[Serializable]
	public class JsonException : Exception
	{
		public JsonException()
		{
		}

		public JsonException(string message)
			: base(message)
		{
		}

		public JsonException(string message, Exception? innerException)
			: base(message, innerException)
		{
		}

		public JsonException(SerializationInfo info, StreamingContext context)
			: base(info, context)
		{
		}

		internal static JsonException Create(IJsonLineInfo lineInfo, string path, string message)
		{
			message = JsonPosition.FormatMessage(lineInfo, path, message);
			return new JsonException(message);
		}
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)]
	public class JsonExtensionDataAttribute : Attribute
	{
		public bool WriteData { get; set; }

		public bool ReadData { get; set; }

		public JsonExtensionDataAttribute()
		{
			WriteData = true;
			ReadData = true;
		}
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)]
	public sealed class JsonIgnoreAttribute : Attribute
	{
	}
	public abstract class JsonNameTable
	{
		public abstract string? Get(char[] key, int start, int length);
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface, AllowMultiple = false)]
	public sealed class JsonObjectAttribute : JsonContainerAttribute
	{
		private MemberSerialization _memberSerialization;

		internal MissingMemberHandling? _missingMemberHandling;

		internal Required? _itemRequired;

		internal NullValueHandling? _itemNullValueHandling;

		public MemberSerialization MemberSerialization
		{
			get
			{
				return _memberSerialization;
			}
			set
			{
				_memberSerialization = value;
			}
		}

		public MissingMemberHandling MissingMemberHandling
		{
			get
			{
				return _missingMemberHandling.GetValueOrDefault();
			}
			set
			{
				_missingMemberHandling = value;
			}
		}

		public NullValueHandling ItemNullValueHandling
		{
			get
			{
				return _itemNullValueHandling.GetValueOrDefault();
			}
			set
			{
				_itemNullValueHandling = value;
			}
		}

		public Required ItemRequired
		{
			get
			{
				return _itemRequired.GetValueOrDefault();
			}
			set
			{
				_itemRequired = value;
			}
		}

		public JsonObjectAttribute()
		{
		}

		public JsonObjectAttribute(MemberSerialization memberSerialization)
		{
			MemberSerialization = memberSerialization;
		}

		public JsonObjectAttribute(string id)
			: base(id)
		{
		}
	}
	internal enum JsonContainerType
	{
		None,
		Object,
		Array,
		Constructor
	}
	internal struct JsonPosition
	{
		private static readonly char[] SpecialCharacters = new char[18]
		{
			'.', ' ', '\'', '/', '"', '[', ']', '(', ')', '\t',
			'\n', '\r', '\f', '\b', '\\', '\u0085', '\u2028', '\u2029'
		};

		internal JsonContainerType Type;

		internal int Position;

		internal string? PropertyName;

		internal bool HasIndex;

		public JsonPosition(JsonContainerType type)
		{
			Type = type;
			HasIndex = TypeHasIndex(type);
			Position = -1;
			PropertyName = null;
		}

		internal int CalculateLength()
		{
			switch (Type)
			{
			case JsonContainerType.Object:
				return PropertyName.Length + 5;
			case JsonContainerType.Array:
			case JsonContainerType.Constructor:
				return MathUtils.IntLength((ulong)Position) + 2;
			default:
				throw new ArgumentOutOfRangeException("Type");
			}
		}

		internal void WriteTo(StringBuilder sb, ref StringWriter? writer, ref char[]? buffer)
		{
			switch (Type)
			{
			case JsonContainerType.Object:
			{
				string propertyName = PropertyName;
				if (propertyName.IndexOfAny(SpecialCharacters) != -1)
				{
					sb.Append("['");
					if (writer == null)
					{
						writer = new StringWriter(sb);
					}
					JavaScriptUtils.WriteEscapedJavaScriptString(writer, propertyName, '\'', appendDelimiters: false, JavaScriptUtils.SingleQuoteCharEscapeFlags, StringEscapeHandling.Default, null, ref buffer);
					sb.Append("']");
				}
				else
				{
					if (sb.Length > 0)
					{
						sb.Append('.');
					}
					sb.Append(propertyName);
				}
				break;
			}
			case JsonContainerType.Array:
			case JsonContainerType.Constructor:
				sb.Append('[');
				sb.Append(Position);
				sb.Append(']');
				break;
			}
		}

		internal static bool TypeHasIndex(JsonContainerType type)
		{
			if (type != JsonContainerType.Array)
			{
				return type == JsonContainerType.Constructor;
			}
			return true;
		}

		internal static string BuildPath(List<JsonPosition> positions, JsonPosition? currentPosition)
		{
			int num = 0;
			if (positions != null)
			{
				for (int i = 0; i < positions.Count; i++)
				{
					num += positions[i].CalculateLength();
				}
			}
			if (currentPosition.HasValue)
			{
				num += currentPosition.GetValueOrDefault().CalculateLength();
			}
			StringBuilder stringBuilder = new StringBuilder(num);
			StringWriter writer = null;
			char[] buffer = null;
			if (positions != null)
			{
				foreach (JsonPosition position in positions)
				{
					position.WriteTo(stringBuilder, ref writer, ref buffer);
				}
			}
			currentPosition?.WriteTo(stringBuilder, ref writer, ref buffer);
			return stringBuilder.ToString();
		}

		internal static string FormatMessage(IJsonLineInfo? lineInfo, string path, string message)
		{
			if (!message.EndsWith(Environment.NewLine, StringComparison.Ordinal))
			{
				message = message.Trim();
				if (!StringUtils.EndsWith(message, '.'))
				{
					message += ".";
				}
				message += " ";
			}
			message += "Path '{0}'".FormatWith(CultureInfo.InvariantCulture, path);
			if (lineInfo != null && lineInfo.HasLineInfo())
			{
				message += ", line {0}, position {1}".FormatWith(CultureInfo.InvariantCulture, lineInfo.LineNumber, lineInfo.LinePosition);
			}
			message += ".";
			return message;
		}
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false)]
	public sealed class JsonPropertyAttribute : Attribute
	{
		internal NullValueHandling? _nullValueHandling;

		internal DefaultValueHandling? _defaultValueHandling;

		internal ReferenceLoopHandling? _referenceLoopHandling;

		internal ObjectCreationHandling? _objectCreationHandling;

		internal TypeNameHandling? _typeNameHandling;

		internal bool? _isReference;

		internal int? _order;

		internal Required? _required;

		internal bool? _itemIsReference;

		internal ReferenceLoopHandling? _itemReferenceLoopHandling;

		internal TypeNameHandling? _itemTypeNameHandling;

		public Type? ItemConverterType { get; set; }

		public object[]? ItemConverterParameters { get; set; }

		public Type? NamingStrategyType { get; set; }

		public object[]? NamingStrategyParameters { get; set; }

		public NullValueHandling NullValueHandling
		{
			get
			{
				return _nullValueHandling.GetValueOrDefault();
			}
			set
			{
				_nullValueHandling = value;
			}
		}

		public DefaultValueHandling DefaultValueHandling
		{
			get
			{
				return _defaultValueHandling.GetValueOrDefault();
			}
			set
			{
				_defaultValueHandling = value;
			}
		}

		public ReferenceLoopHandling ReferenceLoopHandling
		{
			get
			{
				return _referenceLoopHandling.GetValueOrDefault();
			}
			set
			{
				_referenceLoopHandling = value;
			}
		}

		public ObjectCreationHandling ObjectCreationHandling
		{
			get
			{
				return _objectCreationHandling.GetValueOrDefault();
			}
			set
			{
				_objectCreationHandling = value;
			}
		}

		public TypeNameHandling TypeNameHandling
		{
			get
			{
				return _typeNameHandling.GetValueOrDefault();
			}
			set
			{
				_typeNameHandling = value;
			}
		}

		public bool IsReference
		{
			get
			{
				return _isReference.GetValueOrDefault();
			}
			set
			{
				_isReference = value;
			}
		}

		public int Order
		{
			get
			{
				return _order.GetValueOrDefault();
			}
			set
			{
				_order = value;
			}
		}

		public Required Required
		{
			get
			{
				return _required.GetValueOrDefault();
			}
			set
			{
				_required = value;
			}
		}

		public string? PropertyName { get; set; }

		public ReferenceLoopHandling ItemReferenceLoopHandling
		{
			get
			{
				return _itemReferenceLoopHandling.GetValueOrDefault();
			}
			set
			{
				_itemReferenceLoopHandling = value;
			}
		}

		public TypeNameHandling ItemTypeNameHandling
		{
			get
			{
				return _itemTypeNameHandling.GetValueOrDefault();
			}
			set
			{
				_itemTypeNameHandling = value;
			}
		}

		public bool ItemIsReference
		{
			get
			{
				return _itemIsReference.GetValueOrDefault();
			}
			set
			{
				_itemIsReference = value;
			}
		}

		public JsonPropertyAttribute()
		{
		}

		public JsonPropertyAttribute(string propertyName)
		{
			PropertyName = propertyName;
		}
	}
	public abstract class JsonReader : IDisposable
	{
		protected internal enum State
		{
			Start,
			Complete,
			Property,
			ObjectStart,
			Object,
			ArrayStart,
			Array,
			Closed,
			PostValue,
			ConstructorStart,
			Constructor,
			Error,
			Finished
		}

		private JsonToken _tokenType;

		private object? _value;

		internal char _quoteChar;

		internal State _currentState;

		private JsonPosition _currentPosition;

		private CultureInfo? _culture;

		private DateTimeZoneHandling _dateTimeZoneHandling;

		private int? _maxDepth;

		private bool _hasExceededMaxDepth;

		internal DateParseHandling _dateParseHandling;

		internal FloatParseHandling _floatParseHandling;

		private string? _dateFormatString;

		private List<JsonPosition>? _stack;

		protected State CurrentState => _currentState;

		public bool CloseInput { get; set; }

		public bool SupportMultipleContent { get; set; }

		public virtual char QuoteChar
		{
			get
			{
				return _quoteChar;
			}
			protected internal set
			{
				_quoteChar = value;
			}
		}

		public DateTimeZoneHandling DateTimeZoneHandling
		{
			get
			{
				return _dateTimeZoneHandling;
			}
			set
			{
				if (value < DateTimeZoneHandling.Local || value > DateTimeZoneHandling.RoundtripKind)
				{
					throw new ArgumentOutOfRangeException("value");
				}
				_dateTimeZoneHandling = value;
			}
		}

		public DateParseHandling DateParseHandling
		{
			get
			{
				return _dateParseHandling;
			}
			set
			{
				if (value < DateParseHandling.None || value > DateParseHandling.DateTimeOffset)
				{
					throw new ArgumentOutOfRangeException("value");
				}
				_dateParseHandling = value;
			}
		}

		public FloatParseHandling FloatParseHandling
		{
			get
			{
				return _floatParseHandling;
			}
			set
			{
				if (value < FloatParseHandling.Double || value > FloatParseHandling.Decimal)
				{
					throw new ArgumentOutOfRangeException("value");
				}
				_floatParseHandling = value;
			}
		}

		public string? DateFormatString
		{
			get
			{
				return _dateFormatString;
			}
			set
			{
				_dateFormatString = value;
			}
		}

		public int? MaxDepth
		{
			get
			{
				return _maxDepth;
			}
			set
			{
				if (value <= 0)
				{
					throw new ArgumentException("Value must be positive.", "value");
				}
				_maxDepth = value;
			}
		}

		public virtual JsonToken TokenType => _tokenType;

		public virtual object? Value => _value;

		public virtual Type? ValueType => _value?.GetType();

		public virtual int Depth
		{
			get
			{
				int num = _stack?.Count ?? 0;
				if (JsonTokenUtils.IsStartToken(TokenType) || _currentPosition.Type == JsonContainerType.None)
				{
					return num;
				}
				return num + 1;
			}
		}

		public virtual string Path
		{
			get
			{
				if (_currentPosition.Type == JsonContainerType.None)
				{
					return string.Empty;
				}
				JsonPosition? currentPosition = ((_currentState != State.ArrayStart && _currentState != State.ConstructorStart && _currentState != State.ObjectStart) ? new JsonPosition?(_currentPosition) : null);
				return JsonPosition.BuildPath(_stack, currentPosition);
			}
		}

		public CultureInfo Culture
		{
			get
			{
				return _culture ?? CultureInfo.InvariantCulture;
			}
			set
			{
				_culture = value;
			}
		}

		public virtual Task<bool> ReadAsync(CancellationToken cancellationToken = default(CancellationToken))
		{
			return cancellationToken.CancelIfRequestedAsync<bool>() ?? Read().ToAsync();
		}

		public async Task SkipAsync(CancellationToken cancellationToken = default(CancellationToken))
		{
			if (TokenType == JsonToken.PropertyName)
			{
				await ReadAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
			}
			if (JsonTokenUtils.IsStartToken(TokenType))
			{
				int depth = Depth;
				while (await ReadAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false) && depth < Depth)
				{
				}
			}
		}

		internal async Task ReaderReadAndAssertAsync(CancellationToken cancellationToken)
		{
			if (!(await ReadAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false)))
			{
				throw CreateUnexpectedEndException();
			}
		}

		public virtual Task<bool?> ReadAsBooleanAsync(CancellationToken cancellationToken = default(CancellationToken))
		{
			return cancellationToken.CancelIfRequestedAsync<bool?>() ?? Task.FromResult(ReadAsBoolean());
		}

		public virtual Task<byte[]?> ReadAsBytesAsync(CancellationToken cancellationToken = default(CancellationToken))
		{
			return cancellationToken.CancelIfRequestedAsync<byte[]>() ?? Task.FromResult(ReadAsBytes());
		}

		internal async Task<byte[]?> ReadArrayIntoByteArrayAsync(CancellationToken cancellationToken)
		{
			List<byte> buffer = new List<byte>();
			do
			{
				if (!(await ReadAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false)))
				{
					SetToken(JsonToken.None);
				}
			}
			while (!ReadArrayElementIntoByteArrayReportDone(buffer));
			byte[] array = buffer.ToArray();
			SetToken(JsonToken.Bytes, array, updateIndex: false);
			return array;
		}

		public virtual Task<DateTime?> ReadAsDateTimeAsync(CancellationToken cancellationToken = default(CancellationToken))
		{
			return cancellationToken.CancelIfRequestedAsync<DateTime?>() ?? Task.FromResult(ReadAsDateTime());
		}

		public virtual Task<DateTimeOffset?> ReadAsDateTimeOffsetAsync(CancellationToken cancellationToken = default(CancellationToken))
		{
			return cancellationToken.CancelIfRequestedAsync<DateTimeOffset?>() ?? Task.FromResult(ReadAsDateTimeOffset());
		}

		public virtual Task<decimal?> ReadAsDecimalAsync(CancellationToken cancellationToken = default(CancellationToken))
		{
			return cancellationToken.CancelIfRequestedAsync<decimal?>() ?? Task.FromResult(ReadAsDecimal());
		}

		public virtual Task<double?> ReadAsDoubleAsync(CancellationToken cancellationToken = default(CancellationToken))
		{
			return Task.FromResult(ReadAsDouble());
		}

		public virtual Task<int?> ReadAsInt32Async(CancellationToken cancellationToken = default(CancellationToken))
		{
			return cancellationToken.CancelIfRequestedAsync<int?>() ?? Task.FromResult(ReadAsInt32());
		}

		public virtual Task<string?> ReadAsStringAsync(CancellationToken cancellationToken = default(CancellationToken))
		{
			return cancellationToken.CancelIfRequestedAsync<string>() ?? Task.FromResult(ReadAsString());
		}

		internal async Task<bool> ReadAndMoveToContentAsync(CancellationToken cancellationToken)
		{
			bool flag = await ReadAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
			if (flag)
			{
				flag = await MoveToContentAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
			}
			return flag;
		}

		internal Task<bool> MoveToContentAsync(CancellationToken cancellationToken)
		{
			JsonToken tokenType = TokenType;
			if (tokenType == JsonToken.None || tokenType == JsonToken.Comment)
			{
				return MoveToContentFromNonContentAsync(cancellationToken);
			}
			return AsyncUtils.True;
		}

		private async Task<bool> MoveToContentFromNonContentAsync(CancellationToken cancellationToken)
		{
			JsonToken tokenType;
			do
			{
				if (!(await ReadAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false)))
				{
					return false;
				}
				tokenType = TokenType;
			}
			while (tokenType == JsonToken.None || tokenType == JsonToken.Comment);
			return true;
		}

		internal JsonPosition GetPosition(int depth)
		{
			if (_stack != null && depth < _stack.Count)
			{
				return _stack[depth];
			}
			return _currentPosition;
		}

		protected JsonReader()
		{
			_currentState = State.Start;
			_dateTimeZoneHandling = DateTimeZoneHandling.RoundtripKind;
			_dateParseHandling = DateParseHandling.DateTime;
			_floatParseHandling = FloatParseHandling.Double;
			_maxDepth = 64;
			CloseInput = true;
		}

		private void Push(JsonContainerType value)
		{
			UpdateScopeWithFinishedValue();
			if (_currentPosition.Type == JsonContainerType.None)
			{
				_currentPosition = new JsonPosition(value);
				return;
			}
			if (_stack == null)
			{
				_stack = new List<JsonPosition>();
			}
			_stack.Add(_currentPosition);
			_currentPosition = new JsonPosition(value);
			if (!_maxDepth.HasValue || !(Depth + 1 > _maxDepth) || _hasExceededMaxDepth)
			{
				return;
			}
			_hasExceededMaxDepth = true;
			throw JsonReaderException.Create(this, "The reader's MaxDepth of {0} has been exceeded.".FormatWith(CultureInfo.InvariantCulture, _maxDepth));
		}

		private JsonContainerType Pop()
		{
			JsonPosition currentPosition;
			if (_stack != null && _stack.Count > 0)
			{
				currentPosition = _currentPosition;
				_currentPosition = _stack[_stack.Count - 1];
				_stack.RemoveAt(_stack.Count - 1);
			}
			else
			{
				currentPosition = _currentPosition;
				_currentPosition = default(JsonPosition);
			}
			if (_maxDepth.HasValue && Depth <= _maxDepth)
			{
				_hasExceededMaxDepth = false;
			}
			return currentPosition.Type;
		}

		private JsonContainerType Peek()
		{
			return _currentPosition.Type;
		}

		public abstract bool Read();

		public virtual int? ReadAsInt32()
		{
			JsonToken contentToken = GetContentToken();
			switch (contentToken)
			{
			case JsonToken.None:
			case JsonToken.Null:
			case JsonToken.EndArray:
				return null;
			case JsonToken.Integer:
			case JsonToken.Float:
			{
				object value = Value;
				if (value is int)
				{
					return (int)value;
				}
				int num;
				if (value is BigInteger bigInteger)
				{
					num = (int)bigInteger;
				}
				else
				{
					try
					{
						num = Convert.ToInt32(value, CultureInfo.InvariantCulture);
					}
					catch (Exception ex)
					{
						throw JsonReaderException.Create(this, "Could not convert to integer: {0}.".FormatWith(CultureInfo.InvariantCulture, value), ex);
					}
				}
				SetToken(JsonToken.Integer, num, updateIndex: false);
				return num;
			}
			case JsonToken.String:
			{
				string s = (string)Value;
				return ReadInt32String(s);
			}
			default:
				throw JsonReaderException.Create(this, "Error reading integer. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, contentToken));
			}
		}

		internal int? ReadInt32String(string? s)
		{
			if (StringUtils.IsNullOrEmpty(s))
			{
				SetToken(JsonToken.Null, null, updateIndex: false);
				return null;
			}
			if (int.TryParse(s, NumberStyles.Integer, Culture, out var result))
			{
				SetToken(JsonToken.Integer, result, updateIndex: false);
				return result;
			}
			SetToken(JsonToken.String, s, updateIndex: false);
			throw JsonReaderException.Create(this, "Could not convert string to integer: {0}.".FormatWith(CultureInfo.InvariantCulture, s));
		}

		public virtual string? ReadAsString()
		{
			JsonToken contentToken = GetContentToken();
			switch (contentToken)
			{
			case JsonToken.None:
			case JsonToken.Null:
			case JsonToken.EndArray:
				return null;
			case JsonToken.String:
				return (string)Value;
			default:
				if (JsonTokenUtils.IsPrimitiveToken(contentToken))
				{
					object value = Value;
					if (value != null)
					{
						string text = ((!(value is IFormattable formattable)) ? ((value is Uri uri) ? uri.OriginalString : value.ToString()) : formattable.ToString(null, Culture));
						SetToken(JsonToken.String, text, updateIndex: false);
						return text;
					}
				}
				throw JsonReaderException.Create(this, "Error reading string. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, contentToken));
			}
		}

		public virtual byte[]? ReadAsBytes()
		{
			JsonToken contentToken = GetContentToken();
			switch (contentToken)
			{
			case JsonToken.StartObject:
			{
				ReadIntoWrappedTypeObject();
				byte[] array2 = ReadAsBytes();
				ReaderReadAndAssert();
				if (TokenType != JsonToken.EndObject)
				{
					throw JsonReaderException.Create(this, "Error reading bytes. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, TokenType));
				}
				SetToken(JsonToken.Bytes, array2, updateIndex: false);
				return array2;
			}
			case JsonToken.String:
			{
				string text = (string)Value;
				Guid g;
				byte[] array3 = ((text.Length == 0) ? CollectionUtils.ArrayEmpty<byte>() : ((!ConvertUtils.TryConvertGuid(text, out g)) ? Convert.FromBase64String(text) : g.ToByteArray()));
				SetToken(JsonToken.Bytes, array3, updateIndex: false);
				return array3;
			}
			case JsonToken.None:
			case JsonToken.Null:
			case JsonToken.EndArray:
				return null;
			case JsonToken.Bytes:
				if (Value is Guid guid)
				{
					byte[] array = guid.ToByteArray();
					SetToken(JsonToken.Bytes, array, updateIndex: false);
					return array;
				}
				return (byte[])Value;
			case JsonToken.StartArray:
				return ReadArrayIntoByteArray();
			default:
				throw JsonReaderException.Create(this, "Error reading bytes. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, contentToken));
			}
		}

		internal byte[] ReadArrayIntoByteArray()
		{
			List<byte> list = new List<byte>();
			do
			{
				if (!Read())
				{
					SetToken(JsonToken.None);
				}
			}
			while (!ReadArrayElementIntoByteArrayReportDone(list));
			byte[] array = list.ToArray();
			SetToken(JsonToken.Bytes, array, updateIndex: false);
			return array;
		}

		private bool ReadArrayElementIntoByteArrayReportDone(List<byte> buffer)
		{
			switch (TokenType)
			{
			case JsonToken.None:
				throw JsonReaderException.Create(this, "Unexpected end when reading bytes.");
			case JsonToken.Integer:
				buffer.Add(Convert.ToByte(Value, CultureInfo.InvariantCulture));
				return false;
			case JsonToken.EndArray:
				return true;
			case JsonToken.Comment:
				return false;
			default:
				throw JsonReaderException.Create(this, "Unexpected token when reading bytes: {0}.".FormatWith(CultureInfo.InvariantCulture, TokenType));
			}
		}

		public virtual double? ReadAsDouble()
		{
			JsonToken contentToken = GetContentToken();
			switch (contentToken)
			{
			case JsonToken.None:
			case JsonToken.Null:
			case JsonToken.EndArray:
				return null;
			case JsonToken.Integer:
			case JsonToken.Float:
			{
				object value = Value;
				if (value is double)
				{
					return (double)value;
				}
				double num = ((!(value is BigInteger bigInteger)) ? Convert.ToDouble(value, CultureInfo.InvariantCulture) : ((double)bigInteger));
				SetToken(JsonToken.Float, num, updateIndex: false);
				return num;
			}
			case JsonToken.String:
				return ReadDoubleString((string)Value);
			default:
				throw JsonReaderException.Create(this, "Error reading double. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, contentToken));
			}
		}

		internal double? ReadDoubleString(string? s)
		{
			if (StringUtils.IsNullOrEmpty(s))
			{
				SetToken(JsonToken.Null, null, updateIndex: false);
				return null;
			}
			if (double.TryParse(s, NumberStyles.Float | NumberStyles.AllowThousands, Culture, out var result))
			{
				SetToken(JsonToken.Float, result, updateIndex: false);
				return result;
			}
			SetToken(JsonToken.String, s, updateIndex: false);
			throw JsonReaderException.Create(this, "Could not convert string to double: {0}.".FormatWith(CultureInfo.InvariantCulture, s));
		}

		public virtual bool? ReadAsBoolean()
		{
			JsonToken contentToken = GetContentToken();
			switch (contentToken)
			{
			case JsonToken.None:
			case JsonToken.Null:
			case JsonToken.EndArray:
				return null;
			case JsonToken.Integer:
			case JsonToken.Float:
			{
				bool flag = ((!(Value is BigInteger bigInteger)) ? Convert.ToBoolean(Value, CultureInfo.InvariantCulture) : (bigInteger != 0L));
				SetToken(JsonToken.Boolean, flag, updateIndex: false);
				return flag;
			}
			case JsonToken.String:
				return ReadBooleanString((string)Value);
			case JsonToken.Boolean:
				return (bool)Value;
			default:
				throw JsonReaderException.Create(this, "Error reading boolean. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, contentToken));
			}
		}

		internal bool? ReadBooleanString(string? s)
		{
			if (StringUtils.IsNullOrEmpty(s))
			{
				SetToken(JsonToken.Null, null, updateIndex: false);
				return null;
			}
			if (bool.TryParse(s, out var result))
			{
				SetToken(JsonToken.Boolean, result, updateIndex: false);
				return result;
			}
			SetToken(JsonToken.String, s, updateIndex: false);
			throw JsonReaderException.Create(this, "Could not convert string to boolean: {0}.".FormatWith(CultureInfo.InvariantCulture, s));
		}

		public virtual decimal? ReadAsDecimal()
		{
			JsonToken contentToken = GetContentToken();
			switch (contentToken)
			{
			case JsonToken.None:
			case JsonToken.Null:
			case JsonToken.EndArray:
				return null;
			case JsonToken.Integer:
			case JsonToken.Float:
			{
				object value = Value;
				if (value is decimal)
				{
					return (decimal)value;
				}
				decimal num;
				if (value is BigInteger bigInteger)
				{
					num = (decimal)bigInteger;
				}
				else
				{
					try
					{
						num = Convert.ToDecimal(value, CultureInfo.InvariantCulture);
					}
					catch (Exception ex)
					{
						throw JsonReaderException.Create(this, "Could not convert to decimal: {0}.".FormatWith(CultureInfo.InvariantCulture, value), ex);
					}
				}
				SetToken(JsonToken.Float, num, updateIndex: false);
				return num;
			}
			case JsonToken.String:
				return ReadDecimalString((string)Value);
			default:
				throw JsonReaderException.Create(this, "Error reading decimal. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, contentToken));
			}
		}

		internal decimal? ReadDecimalString(string? s)
		{
			if (StringUtils.IsNullOrEmpty(s))
			{
				SetToken(JsonToken.Null, null, updateIndex: false);
				return null;
			}
			if (decimal.TryParse(s, NumberStyles.Number, Culture, out var result))
			{
				SetToken(JsonToken.Float, result, updateIndex: false);
				return result;
			}
			if (ConvertUtils.DecimalTryParse(s.ToCharArray(), 0, s.Length, out result) == ParseResult.Success)
			{
				SetToken(JsonToken.Float, result, updateIndex: false);
				return result;
			}
			SetToken(JsonToken.String, s, updateIndex: false);
			throw JsonReaderException.Create(this, "Could not convert string to decimal: {0}.".FormatWith(CultureInfo.InvariantCulture, s));
		}

		public virtual DateTime? ReadAsDateTime()
		{
			switch (GetContentToken())
			{
			case JsonToken.None:
			case JsonToken.Null:
			case JsonToken.EndArray:
				return null;
			case JsonToken.Date:
				if (Value is DateTimeOffset dateTimeOffset)
				{
					SetToken(JsonToken.Date, dateTimeOffset.DateTime, updateIndex: false);
				}
				return (DateTime)Value;
			case JsonToken.String:
				return ReadDateTimeString((string)Value);
			default:
				throw JsonReaderException.Create(this, "Error reading date. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, TokenType));
			}
		}

		internal DateTime? ReadDateTimeString(string? s)
		{
			if (StringUtils.IsNullOrEmpty(s))
			{
				SetToken(JsonToken.Null, null, updateIndex: false);
				return null;
			}
			if (DateTimeUtils.TryParseDateTime(s, DateTimeZoneHandling, _dateFormatString, Culture, out var dt))
			{
				dt = DateTimeUtils.EnsureDateTime(dt, DateTimeZoneHandling);
				SetToken(JsonToken.Date, dt, updateIndex: false);
				return dt;
			}
			if (DateTime.TryParse(s, Culture, DateTimeStyles.RoundtripKind, out dt))
			{
				dt = DateTimeUtils.EnsureDateTime(dt, DateTimeZoneHandling);
				SetToken(JsonToken.Date, dt, updateIndex: false);
				return dt;
			}
			throw JsonReaderException.Create(this, "Could not convert string to DateTime: {0}.".FormatWith(CultureInfo.InvariantCulture, s));
		}

		public virtual DateTimeOffset? ReadAsDateTimeOffset()
		{
			JsonToken contentToken = GetContentToken();
			switch (contentToken)
			{
			case JsonToken.None:
			case JsonToken.Null:
			case JsonToken.EndArray:
				return null;
			case JsonToken.Date:
				if (Value is DateTime dateTime)
				{
					SetToken(JsonToken.Date, new DateTimeOffset(dateTime), updateIndex: false);
				}
				return (DateTimeOffset)Value;
			case JsonToken.String:
			{
				string s = (string)Value;
				return ReadDateTimeOffsetString(s);
			}
			default:
				throw JsonReaderException.Create(this, "Error reading date. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, contentToken));
			}
		}

		internal DateTimeOffset? ReadDateTimeOffsetString(string? s)
		{
			if (StringUtils.IsNullOrEmpty(s))
			{
				SetToken(JsonToken.Null, null, updateIndex: false);
				return null;
			}
			if (DateTimeUtils.TryParseDateTimeOffset(s, _dateFormatString, Culture, out var dt))
			{
				SetToken(JsonToken.Date, dt, updateIndex: false);
				return dt;
			}
			if (DateTimeOffset.TryParse(s, Culture, DateTimeStyles.RoundtripKind, out dt))
			{
				SetToken(JsonToken.Date, dt, updateIndex: false);
				return dt;
			}
			SetToken(JsonToken.String, s, updateIndex: false);
			throw JsonReaderException.Create(this, "Could not convert string to DateTimeOffset: {0}.".FormatWith(CultureInfo.InvariantCulture, s));
		}

		internal void ReaderReadAndAssert()
		{
			if (!Read())
			{
				throw CreateUnexpectedEndException();
			}
		}

		internal JsonReaderException CreateUnexpectedEndException()
		{
			return JsonReaderException.Create(this, "Unexpected end when reading JSON.");
		}

		internal void ReadIntoWrappedTypeObject()
		{
			ReaderReadAndAssert();
			if (Value != null && Value.ToString() == "$type")
			{
				ReaderReadAndAssert();
				if (Value != null && Value.ToString().StartsWith("System.Byte[]", StringComparison.Ordinal))
				{
					ReaderReadAndAssert();
					if (Value.ToString() == "$value")
					{
						return;
					}
				}
			}
			throw JsonReaderException.Create(this, "Error reading bytes. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, JsonToken.StartObject));
		}

		public void Skip()
		{
			if (TokenType == JsonToken.PropertyName)
			{
				Read();
			}
			if (JsonTokenUtils.IsStartToken(TokenType))
			{
				int depth = Depth;
				while (Read() && depth < Depth)
				{
				}
			}
		}

		protected void SetToken(JsonToken newToken)
		{
			SetToken(newToken, null, updateIndex: true);
		}

		protected void SetToken(JsonToken newToken, object? value)
		{
			SetToken(newToken, value, updateIndex: true);
		}

		protected void SetToken(JsonToken newToken, object? value, bool updateIndex)
		{
			_tokenType = newToken;
			_value = value;
			switch (newToken)
			{
			case JsonToken.StartObject:
				_currentState = State.ObjectStart;
				Push(JsonContainerType.Object);
				break;
			case JsonToken.StartArray:
				_currentState = State.ArrayStart;
				Push(JsonContainerType.Array);
				break;
			case JsonToken.StartConstructor:
				_currentState = State.ConstructorStart;
				Push(JsonContainerType.Constructor);
				break;
			case JsonToken.EndObject:
				ValidateEnd(JsonToken.EndObject);
				break;
			case JsonToken.EndArray:
				ValidateEnd(JsonToken.EndArray);
				break;
			case JsonToken.EndConstructor:
				ValidateEnd(JsonToken.EndConstructor);
				break;
			case JsonToken.PropertyName:
				_currentState = State.Property;
				_currentPosition.PropertyName = (string)value;
				break;
			case JsonToken.Raw:
			case JsonToken.Integer:
			case JsonToken.Float:
			case JsonToken.String:
			case JsonToken.Boolean:
			case JsonToken.Null:
			case JsonToken.Undefined:
			case JsonToken.Date:
			case JsonToken.Bytes:
				SetPostValueState(updateIndex);
				break;
			case JsonToken.Comment:
				break;
			}
		}

		internal void SetPostValueState(bool updateIndex)
		{
			if (Peek() != 0 || SupportMultipleContent)
			{
				_currentState = State.PostValue;
			}
			else
			{
				SetFinished();
			}
			if (updateIndex)
			{
				UpdateScopeWithFinishedValue();
			}
		}

		private void UpdateScopeWithFinishedValue()
		{
			if (_currentPosition.HasIndex)
			{
				_currentPosition.Position++;
			}
		}

		private void ValidateEnd(JsonToken endToken)
		{
			JsonContainerType jsonContainerType = Pop();
			if (GetTypeForCloseToken(endToken) != jsonContainerType)
			{
				throw JsonReaderException.Create(this, "JsonToken {0} is not valid for closing JsonType {1}.".FormatWith(CultureInfo.InvariantCulture, endToken, jsonContainerType));
			}
			if (Peek() != 0 || SupportMultipleContent)
			{
				_currentState = State.PostValue;
			}
			else
			{
				SetFinished();
			}
		}

		protected void SetStateBasedOnCurrent()
		{
			JsonContainerType jsonContainerType = Peek();
			switch (jsonContainerType)
			{
			case JsonContainerType.Object:
				_currentState = State.Object;
				break;
			case JsonContainerType.Array:
				_currentState = State.Array;
				break;
			case JsonContainerType.Constructor:
				_currentState = State.Constructor;
				break;
			case JsonContainerType.None:
				SetFinished();
				break;
			default:
				throw JsonReaderException.Create(this, "While setting the reader state back to current object an unexpected JsonType was encountered: {0}".FormatWith(CultureInfo.InvariantCulture, jsonContainerType));
			}
		}

		private void SetFinished()
		{
			_currentState = ((!SupportMultipleContent) ? State.Finished : State.Start);
		}

		private JsonContainerType GetTypeForCloseToken(JsonToken token)
		{
			return token switch
			{
				JsonToken.EndObject => JsonContainerType.Object, 
				JsonToken.EndArray => JsonContainerType.Array, 
				JsonToken.EndConstructor => JsonContainerType.Constructor, 
				_ => throw JsonReaderException.Create(this, "Not a valid close JsonToken: {0}".FormatWith(CultureInfo.InvariantCulture, token)), 
			};
		}

		void IDisposable.Dispose()
		{
			Dispose(disposing: true);
			GC.SuppressFinalize(this);
		}

		protected virtual void Dispose(bool disposing)
		{
			if (_currentState != State.Closed && disposing)
			{
				Close();
			}
		}

		public virtual void Close()
		{
			_currentState = State.Closed;
			_tokenType = JsonToken.None;
			_value = null;
		}

		internal void ReadAndAssert()
		{
			if (!Read())
			{
				throw JsonSerializationException.Create(this, "Unexpected end when reading JSON.");
			}
		}

		internal void ReadForTypeAndAssert(JsonContract? contract, bool hasConverter)
		{
			if (!ReadForType(contract, hasConverter))
			{
				throw JsonSerializationException.Create(this, "Unexpected end when reading JSON.");
			}
		}

		internal bool ReadForType(JsonContract? contract, bool hasConverter)
		{
			if (hasConverter)
			{
				return Read();
			}
			switch (contract?.InternalReadType ?? ReadType.Read)
			{
			case ReadType.Read:
				return ReadAndMoveToContent();
			case ReadType.ReadAsInt32:
				ReadAsInt32();
				break;
			case ReadType.ReadAsInt64:
			{
				bool result = ReadAndMoveToContent();
				if (TokenType == JsonToken.Undefined)
				{
					throw JsonReaderException.Create(this, "An undefined token is not a valid {0}.".FormatWith(CultureInfo.InvariantCulture, contract?.UnderlyingType ?? typeof(long)));
				}
				return result;
			}
			case ReadType.ReadAsDecimal:
				ReadAsDecimal();
				break;
			case ReadType.ReadAsDouble:
				ReadAsDouble();
				break;
			case ReadType.ReadAsBytes:
				ReadAsBytes();
				break;
			case ReadType.ReadAsBoolean:
				ReadAsBoolean();
				break;
			case ReadType.ReadAsString:
				ReadAsString();
				break;
			case ReadType.ReadAsDateTime:
				ReadAsDateTime();
				break;
			case ReadType.ReadAsDateTimeOffset:
				ReadAsDateTimeOffset();
				break;
			default:
				throw new ArgumentOutOfRangeException();
			}
			return TokenType != JsonToken.None;
		}

		internal bool ReadAndMoveToContent()
		{
			if (Read())
			{
				return MoveToContent();
			}
			return false;
		}

		internal bool MoveToContent()
		{
			JsonToken tokenType = TokenType;
			while (tokenType == JsonToken.None || tokenType == JsonToken.Comment)
			{
				if (!Read())
				{
					return false;
				}
				tokenType = TokenType;
			}
			return true;
		}

		private JsonToken GetContentToken()
		{
			JsonToken tokenType;
			do
			{
				if (!Read())
				{
					SetToken(JsonToken.None);
					return JsonToken.None;
				}
				tokenType = TokenType;
			}
			while (tokenType == JsonToken.Comment);
			return tokenType;
		}
	}
	[Serializable]
	public class JsonReaderException : JsonException
	{
		public int LineNumber { get; }

		public int LinePosition { get; }

		public string? Path { get; }

		public JsonReaderException()
		{
		}

		public JsonReaderException(string message)
			: base(message)
		{
		}

		public JsonReaderException(string message, Exception innerException)
			: base(message, innerException)
		{
		}

		public JsonReaderException(SerializationInfo info, StreamingContext context)
			: base(info, context)
		{
		}

		public JsonReaderException(string message, string path, int lineNumber, int linePosition, Exception? innerException)
			: base(message, innerException)
		{
			Path = path;
			LineNumber = lineNumber;
			LinePosition = linePosition;
		}

		internal static JsonReaderException Create(JsonReader reader, string message)
		{
			return Create(reader, message, null);
		}

		internal static JsonReaderException Create(JsonReader reader, string message, Exception? ex)
		{
			return Create(reader as IJsonLineInfo, reader.Path, message, ex);
		}

		internal static JsonReaderException Create(IJsonLineInfo? lineInfo, string path, string message, Exception? ex)
		{
			message = JsonPosition.FormatMessage(lineInfo, path, message);
			int lineNumber;
			int linePosition;
			if (lineInfo != null && lineInfo.HasLineInfo())
			{
				lineNumber = lineInfo.LineNumber;
				linePosition = lineInfo.LinePosition;
			}
			else
			{
				lineNumber = 0;
				linePosition = 0;
			}
			return new JsonReaderException(message, path, lineNumber, linePosition, ex);
		}
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)]
	public sealed class JsonRequiredAttribute : Attribute
	{
	}
	[Serializable]
	public class JsonSerializationException : JsonException
	{
		public int LineNumber { get; }

		public int LinePosition { get; }

		public string? Path { get; }

		public JsonSerializationException()
		{
		}

		public JsonSerializationException(string message)
			: base(message)
		{
		}

		public JsonSerializationException(string message, Exception innerException)
			: base(message, innerException)
		{
		}

		public JsonSerializationException(SerializationInfo info, StreamingContext context)
			: base(info, context)
		{
		}

		public JsonSerializationException(string message, string path, int lineNumber, int linePosition, Exception? innerException)
			: base(message, innerException)
		{
			Path = path;
			LineNumber = lineNumber;
			LinePosition = linePosition;
		}

		internal static JsonSerializationException Create(JsonReader reader, string message)
		{
			return Create(reader, message, null);
		}

		internal static JsonSerializationException Create(JsonReader reader, string message, Exception? ex)
		{
			return Create(reader as IJsonLineInfo, reader.Path, message, ex);
		}

		internal static JsonSerializationException Create(IJsonLineInfo? lineInfo, string path, string message, Exception? ex)
		{
			message = JsonPosition.FormatMessage(lineInfo, path, message);
			int lineNumber;
			int linePosition;
			if (lineInfo != null && lineInfo.HasLineInfo())
			{
				lineNumber = lineInfo.LineNumber;
				linePosition = lineInfo.LinePosition;
			}
			else
			{
				lineNumber = 0;
				linePosition = 0;
			}
			return new JsonSerializationException(message, path, lineNumber, linePosition, ex);
		}
	}
	[RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")]
	[RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")]
	public class JsonSerializer
	{
		internal TypeNameHandling _typeNameHandling;

		internal TypeNameAssemblyFormatHandling _typeNameAssemblyFormatHandling;

		internal PreserveReferencesHandling _preserveReferencesHandling;

		internal ReferenceLoopHandling _referenceLoopHandling;

		internal MissingMemberHandling _missingMemberHandling;

		internal ObjectCreationHandling _objectCreationHandling;

		internal NullValueHandling _nullValueHandling;

		internal DefaultValueHandling _defaultValueHandling;

		internal ConstructorHandling _constructorHandling;

		internal MetadataPropertyHandling _metadataPropertyHandling;

		internal JsonConverterCollection? _converters;

		internal IContractResolver _contractResolver;

		internal ITraceWriter? _traceWriter;

		internal IEqualityComparer? _equalityComparer;

		internal ISerializationBinder _serializationBinder;

		internal StreamingContext _context;

		private IReferenceResolver? _referenceResolver;

		private Formatting? _formatting;

		private DateFormatHandling? _dateFormatHandling;

		private DateTimeZoneHandling? _dateTimeZoneHandling;

		private DateParseHandling? _dateParseHandling;

		private FloatFormatHandling? _floatFormatHandling;

		private FloatParseHandling? _floatParseHandling;

		private StringEscapeHandling? _stringEscapeHandling;

		private CultureInfo _culture;

		private int? _maxDepth;

		private bool _maxDepthSet;

		private bool? _checkAdditionalContent;

		private string? _dateFormatString;

		private bool _dateFormatStringSet;

		public virtual IReferenceResolver? ReferenceResolver
		{
			get
			{
				return GetReferenceResolver();
			}
			set
			{
				if (value == null)
				{
					throw new ArgumentNullException("value", "Reference resolver cannot be null.");
				}
				_referenceResolver = value;
			}
		}

		[Obsolete("Binder is obsolete. Use SerializationBinder instead.")]
		public virtual SerializationBinder Binder
		{
			get
			{
				if (_serializationBinder is SerializationBinder result)
				{
					return result;
				}
				if (_serializationBinder is SerializationBinderAdapter serializationBinderAdapter)
				{
					return serializationBinderAdapter.SerializationBinder;
				}
				throw new InvalidOperationException("Cannot get SerializationBinder because an ISerializationBinder was previously set.");
			}
			set
			{
				if (value == null)
				{
					throw new ArgumentNullException("value", "Serialization binder cannot be null.");
				}
				_serializationBinder = (value as ISerializationBinder) ?? new SerializationBinderAdapter(value);
			}
		}

		public virtual ISerializationBinder SerializationBinder
		{
			get
			{
				return _serializationBinder;
			}
			set
			{
				if (value == null)
				{
					throw new ArgumentNullException("value", "Serialization binder cannot be null.");
				}
				_serializationBinder = value;
			}
		}

		public virtual ITraceWriter? TraceWriter
		{
			get
			{
				return _traceWriter;
			}
			set
			{
				_traceWriter = value;
			}
		}

		public virtual IEqualityComparer? EqualityComparer
		{
			get
			{
				return _equalityComparer;
			}
			set
			{
				_equalityComparer = value;
			}
		}

		public virtual TypeNameHandling TypeNameHandling
		{
			get
			{
				return _typeNameHandling;
			}
			set
			{
				if (value < TypeNameHandling.None || value > TypeNameHandling.Auto)
				{
					throw new ArgumentOutOfRangeException("value");
				}
				_typeNameHandling = value;
			}
		}

		[Obsolete("TypeNameAssemblyFormat is obsolete. Use TypeNameAssemblyFormatHandling instead.")]
		public virtual FormatterAssemblyStyle TypeNameAssemblyFormat
		{
			get
			{
				return (FormatterAssemblyStyle)_typeNameAssemblyFormatHandling;
			}
			set
			{
				if (value < FormatterAssemblyStyle.Simple || value > FormatterAssemblyStyle.Full)
				{
					throw new ArgumentOutOfRangeException("value");
				}
				_typeNameAssemblyFormatHandling = (TypeNameAssemblyFormatHandling)value;
			}
		}

		public virtual TypeNameAssemblyFormatHandling TypeNameAssemblyFormatHandling
		{
			get
			{
				return _typeNameAssemblyFormatHandling;
			}
			set
			{
				if (value < TypeNameAssemblyFormatHandling.Simple || value > TypeNameAssemblyFormatHandling.Full)
				{
					throw new ArgumentOutOfRangeException("value");
				}
				_typeNameAssemblyFormatHandling = value;
			}
		}

		public virtual PreserveReferencesHandling PreserveReferencesHandling
		{
			get
			{
				return _preserveReferencesHandling;
			}
			set
			{
				if (value < PreserveReferencesHandling.None || value > PreserveReferencesHandling.All)
				{
					throw new ArgumentOutOfRangeException("value");
				}
				_preserveReferencesHandling = value;
			}
		}

		public virtual ReferenceLoopHandling ReferenceLoopHandling
		{
			get
			{
				return _referenceLoopHandling;
			}
			set
			{
				if (value < ReferenceLoopHandling.Error || value > ReferenceLoopHandling.Serialize)
				{
					throw new ArgumentOutOfRangeException("value");
				}
				_referenceLoopHandling = value;
			}
		}

		public virtual MissingMemberHandling MissingMemberHandling
		{
			get
			{
				return _missingMemberHandling;
			}
			set
			{
				if (value < MissingMemberHandling.Ignore || value > MissingMemberHandling.Error)
				{
					throw new ArgumentOutOfRangeException("value");
				}
				_missingMemberHandling = value;
			}
		}

		public virtual NullValueHandling NullValueHandling
		{
			get
			{
				return _nullValueHandling;
			}
			set
			{
				if (value < NullValueHandling.Include || value > NullValueHandling.Ignore)
				{
					throw new ArgumentOutOfRangeException("value");
				}
				_nullValueHandling = value;
			}
		}

		public virtual DefaultValueHandling DefaultValueHandling
		{
			get
			{
				return _defaultValueHandling;
			}
			set
			{
				if (value < DefaultValueHandling.Include || value > DefaultValueHandling.IgnoreAndPopulate)
				{
					throw new ArgumentOutOfRangeException("value");
				}
				_defaultValueHandling = value;
			}
		}

		public virtual ObjectCreationHandling ObjectCreationHandling
		{
			get
			{
				return _objectCreationHandling;
			}
			set
			{
				if (value < ObjectCreationHandling.Auto || value > ObjectCreationHandling.Replace)
				{
					throw new ArgumentOutOfRangeException("value");
				}
				_objectCreationHandling = value;
			}
		}

		public virtual ConstructorHandling ConstructorHandling
		{
			get
			{
				return _constructorHandling;
			}
			set
			{
				if (value < ConstructorHandling.Default || value > ConstructorHandling.AllowNonPublicDefaultConstructor)
				{
					throw new ArgumentOutOfRangeException("value");
				}
				_constructorHandling = value;
			}
		}

		public virtual MetadataPropertyHandling MetadataPropertyHandling
		{
			get
			{
				return _metadataPropertyHandling;
			}
			set
			{
				if (value < MetadataPropertyHandling.Default || value > MetadataPropertyHandling.Ignore)
				{
					throw new ArgumentOutOfRangeException("value");
				}
				_metadataPropertyHandling = value;
			}
		}

		public virtual JsonConverterCollection Converters
		{
			get
			{
				if (_converters == null)
				{
					_converters = new JsonConverterCollection();
				}
				return _converters;
			}
		}

		public virtual IContractResolver ContractResolver
		{
			get
			{
				return _contractResolver;
			}
			set
			{
				_contractResolver = value ?? DefaultContractResolver.Instance;
			}
		}

		public virtual StreamingContext Context
		{
			get
			{
				return _context;
			}
			set
			{
				_context = value;
			}
		}

		public virtual Formatting Formatting
		{
			get
			{
				return _formatting.GetValueOrDefault();
			}
			set
			{
				_formatting = value;
			}
		}

		public virtual DateFormatHandling DateFormatHandling
		{
			get
			{
				return _dateFormatHandling.GetValueOrDefault();
			}
			set
			{
				_dateFormatHandling = value;
			}
		}

		public virtual DateTimeZoneHandling DateTimeZoneHandling
		{
			get
			{
				return _dateTimeZoneHandling.GetValueOrDefault(DateTimeZoneHandling.RoundtripKind);
			}
			set
			{
				_dateTimeZoneHandling = value;
			}
		}

		public virtual DateParseHandling DateParseHandling
		{
			get
			{
				return _dateParseHandling.GetValueOrDefault(DateParseHandling.DateTime);
			}
			set
			{
				_dateParseHandling = value;
			}
		}

		public virtual FloatParseHandling FloatParseHandling
		{
			get
			{
				return _floatParseHandling.GetValueOrDefault();
			}
			set
			{
				_floatParseHandling = value;
			}
		}

		public virtual FloatFormatHandling FloatFormatHandling
		{
			get
			{
				return _floatFormatHandling.GetValueOrDefault();
			}
			set
			{
				_floatFormatHandling = value;
			}
		}

		public virtual StringEscapeHandling StringEscapeHandling
		{
			get
			{
				return _stringEscapeHandling.GetValueOrDefault();
			}
			set
			{
				_stringEscapeHandling = value;
			}
		}

		public virtual string DateFormatString
		{
			get
			{
				return _dateFormatString ?? "yyyy'-'MM'-'dd'T'HH':'mm':'ss.FFFFFFFK";
			}
			set
			{
				_dateFormatString = value;
				_dateFormatStringSet = true;
			}
		}

		public virtual CultureInfo Culture
		{
			get
			{
				return _culture ?? JsonSerializerSettings.DefaultCulture;
			}
			set
			{
				_culture = value;
			}
		}

		public virtual int? MaxDepth
		{
			get
			{
				return _maxDepth;
			}
			set
			{
				if (value <= 0)
				{
					throw new ArgumentException("Value must be positive.", "value");
				}
				_maxDepth = value;
				_maxDepthSet = true;
			}
		}

		public virtual bool CheckAdditionalContent
		{
			get
			{
				return _checkAdditionalContent.GetValueOrDefault();
			}
			set
			{
				_checkAdditionalContent = value;
			}
		}

		public virtual event EventHandler<Newtonsoft.Json.Serialization.ErrorEventArgs>? Error;

		internal bool IsCheckAdditionalContentSet()
		{
			return _checkAdditionalContent.HasValue;
		}

		public JsonSerializer()
		{
			_referenceLoopHandling = ReferenceLoopHandling.Error;
			_missingMemberHandling = MissingMemberHandling.Ignore;
			_nullValueHandling = NullValueHandling.Include;
			_defaultValueHandling = DefaultValueHandling.Include;
			_objectCreationHandling = ObjectCreationHandling.Auto;
			_preserveReferencesHandling = PreserveReferencesHandling.None;
			_constructorHandling = ConstructorHandling.Default;
			_typeNameHandling = TypeNameHandling.None;
			_metadataPropertyHandling = MetadataPropertyHandling.Default;
			_context = JsonSerializerSettings.DefaultContext;
			_serializationBinder = DefaultSerializationBinder.Instance;
			_culture = JsonSerializerSettings.DefaultCulture;
			_contractResolver = DefaultContractResolver.Instance;
		}

		public static JsonSerializer Create()
		{
			return new JsonSerializer();
		}

		public static JsonSerializer Create(JsonSerializerSettings? settings)
		{
			JsonSerializer jsonSerializer = Create();
			if (settings != null)
			{
				ApplySerializerSettings(jsonSerializer, settings);
			}
			return jsonSerializer;
		}

		public static JsonSerializer CreateDefault()
		{
			return Create(JsonConvert.DefaultSettings?.Invoke());
		}

		public static JsonSerializer CreateDefault(JsonSerializerSettings? settings)
		{
			JsonSerializer jsonSerializer = CreateDefault();
			if (settings != null)
			{
				ApplySerializerSettings(jsonSerializer, settings);
			}
			return jsonSerializer;
		}

		private static void ApplySerializerSettings(JsonSerializer serializer, JsonSerializerSettings settings)
		{
			if (!CollectionUtils.IsNullOrEmpty(settings.Converters))
			{
				for (int i = 0; i < settings.Converters.Count; i++)
				{
					serializer.Converters.Insert(i, settings.Converters[i]);
				}
			}
			if (settings._typeNameHandling.HasValue)
			{
				serializer.TypeNameHandling = settings.TypeNameHandling;
			}
			if (settings._metadataPropertyHandling.HasValue)
			{
				serializer.MetadataPropertyHandling = settings.MetadataPropertyHandling;
			}
			if (settings._typeNameAssemblyFormatHandling.HasValue)
			{
				serializer.TypeNameAssemblyFormatHandling = settings.TypeNameAssemblyFormatHandling;
			}
			if (settings._preserveReferencesHandling.HasValue)
			{
				serializer.PreserveReferencesHandling = settings.PreserveReferencesHandling;
			}
			if (settings._referenceLoopHandling.HasValue)
			{
				serializer.ReferenceLoopHandling = settings.ReferenceLoopHandling;
			}
			if (settings._missingMemberHandling.HasValue)
			{
				serializer.MissingMemberHandling = settings.MissingMemberHandling;
			}
			if (settings._objectCreationHandling.HasValue)
			{
				serializer.ObjectCreationHandling = settings.ObjectCreationHandling;
			}
			if (settings._nullValueHandling.HasValue)
			{
				serializer.NullValueHandling = settings.NullValueHandling;
			}
			if (settings._defaultValueHandling.HasValue)
			{
				serializer.DefaultValueHandling = settings.DefaultValueHandling;
			}
			if (settings._constructorHandling.HasValue)
			{
				serializer.ConstructorHandling = settings.ConstructorHandling;
			}
			if (settings._context.HasValue)
			{
				serializer.Context = settings.Context;
			}
			if (settings._checkAdditionalContent.HasValue)
			{
				serializer._checkAdditionalContent = settings._checkAdditionalContent;
			}
			if (settings.Error != null)
			{
				serializer.Error += settings.Error;
			}
			if (settings.ContractResolver != null)
			{
				serializer.ContractResolver = settings.ContractResolver;
			}
			if (settings.ReferenceResolverProvider != null)
			{
				serializer.ReferenceResolver = settings.ReferenceResolverProvider();
			}
			if (settings.TraceWriter != null)
			{
				serializer.TraceWriter = settings.TraceWriter;
			}
			if (settings.EqualityComparer != null)
			{
				serializer.EqualityComparer = settings.EqualityComparer;
			}
			if (settings.SerializationBinder != null)
			{
				serializer.SerializationBinder = settings.SerializationBinder;
			}
			if (settings._formatting.HasValue)
			{
				serializer._formatting = settings._formatting;
			}
			if (settings._dateFormatHandling.HasValue)
			{
				serializer._dateFormatHandling = settings._dateFormatHandling;
			}
			if (settings._dateTimeZoneHandling.HasValue)
			{
				serializer._dateTimeZoneHandling = settings._dateTimeZoneHandling;
			}
			if (settings._dateParseHandling.HasValue)
			{
				serializer._dateParseHandling = settings._dateParseHandling;
			}
			if (settings._dateFormatStringSet)
			{
				serializer._dateFormatString = settings._dateFormatString;
				serializer._dateFormatStringSet = settings._dateFormatStringSet;
			}
			if (settings._floatFormatHandling.HasValue)
			{
				serializer._floatFormatHandling = settings._floatFormatHandling;
			}
			if (settings._floatParseHandling.HasValue)
			{
				serializer._floatParseHandling = settings._floatParseHandling;
			}
			if (settings._stringEscapeHandling.HasValue)
			{
				serializer._stringEscapeHandling = settings._stringEscapeHandling;
			}
			if (settings._culture != null)
			{
				serializer._culture = settings._culture;
			}
			if (settings._maxDepthSet)
			{
				serializer._maxDepth = settings._maxDepth;
				serializer._maxDepthSet = settings._maxDepthSet;
			}
		}

		[DebuggerStepThrough]
		public void Populate(TextReader reader, object target)
		{
			Populate(new JsonTextReader(reader), target);
		}

		[DebuggerStepThrough]
		public void Populate(JsonReader reader, object target)
		{
			PopulateInternal(reader, target);
		}

		internal virtual void PopulateInternal(JsonReader reader, object target)
		{
			ValidationUtils.ArgumentNotNull(reader, "reader");
			ValidationUtils.ArgumentNotNull(target, "target");
			SetupReader(reader, out CultureInfo previousCulture, out DateTimeZoneHandling? previousDateTimeZoneHandling, out DateParseHandling? previousDateParseHandling, out FloatParseHandling? previousFloatParseHandling, out int? previousMaxDepth, out string previousDateFormatString);
			TraceJsonReader traceJsonReader = ((TraceWriter != null && TraceWriter.LevelFilter >= TraceLevel.Verbose) ? CreateTraceJsonReader(reader) : null);
			new JsonSerializerInternalReader(this).Populate(traceJsonReader ?? reader, target);
			if (traceJsonReader != null)
			{
				TraceWriter.Trace(TraceLevel.Verbose, traceJsonReader.GetDeserializedJsonMessage(), null);
			}
			ResetReader(reader, previousCulture, previousDateTimeZoneHandling, previousDateParseHandling, previousFloatParseHandling, previousMaxDepth, previousDateFormatString);
		}

		[DebuggerStepThrough]
		public object? Deserialize(JsonReader reader)
		{
			return Deserialize(reader, null);
		}

		[DebuggerStepThrough]
		public object? Deserialize(TextReader reader, Type objectType)
		{
			return Deserialize(new JsonTextReader(reader), objectType);
		}

		[DebuggerStepThrough]
		public T? Deserialize<T>(JsonReader reader)
		{
			return (T)Deserialize(reader, typeof(T));
		}

		[DebuggerStepThrough]
		public object? Deserialize(JsonReader reader, Type? objectType)
		{
			return DeserializeInternal(reader, objectType);
		}

		internal virtual object? DeserializeInternal(JsonReader reader, Type? objectType)
		{
			ValidationUtils.ArgumentNotNull(reader, "reader");
			SetupReader(reader, out CultureInfo previousCulture, out DateTimeZoneHandling? previousDateTimeZoneHandling, out DateParseHandling? previousDateParseHandling, out FloatParseHandling? previousFloatParseHandling, out int? previousMaxDepth, out string previousDateFormatString);
			TraceJsonReader traceJsonReader = ((TraceWriter != null && TraceWriter.LevelFilter >= TraceLevel.Verbose) ? CreateTraceJsonReader(reader) : null);
			object? result = new JsonSerializerInternalReader(this).Deserialize(traceJsonReader ?? reader, objectType, CheckAdditionalContent);
			if (traceJsonReader != null)
			{
				TraceWriter.Trace(TraceLevel.Verbose, traceJsonReader.GetDeserializedJsonMessage(), null);
			}
			ResetReader(reader, previousCulture, previousDateTimeZoneHandling, previousDateParseHandling, previousFloatParseHandling, previousMaxDepth, previousDateFormatString);
			return result;
		}

		internal void SetupReader(JsonReader reader, out CultureInfo? previousCulture, out DateTimeZoneHandling? previousDateTimeZoneHandling, out DateParseHandling? previousDateParseHandling, out FloatParseHandling? previousFloatParseHandling, out int? previousMaxDepth, out string? previousDateFormatString)
		{
			if (_culture != null && !_culture.Equals(reader.Culture))
			{
				previousCulture = reader.Culture;
				reader.Culture = _culture