Decompiled source of ModAge v1.0.6

ModAge.dll

Decompiled 6 months ago
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using JetBrains.Annotations;
using LocalizationManager;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.UI;
using YamlDotNet.Core;
using YamlDotNet.Core.Events;
using YamlDotNet.Core.Tokens;
using YamlDotNet.Helpers;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.BufferedDeserialization;
using YamlDotNet.Serialization.BufferedDeserialization.TypeDiscriminators;
using YamlDotNet.Serialization.Converters;
using YamlDotNet.Serialization.EventEmitters;
using YamlDotNet.Serialization.NamingConventions;
using YamlDotNet.Serialization.NodeDeserializers;
using YamlDotNet.Serialization.NodeTypeResolvers;
using YamlDotNet.Serialization.ObjectFactories;
using YamlDotNet.Serialization.ObjectGraphTraversalStrategies;
using YamlDotNet.Serialization.ObjectGraphVisitors;
using YamlDotNet.Serialization.Schemas;
using YamlDotNet.Serialization.TypeInspectors;
using YamlDotNet.Serialization.TypeResolvers;
using YamlDotNet.Serialization.Utilities;
using YamlDotNet.Serialization.ValueDeserializers;

[assembly: AssemblyFileVersion("1.0.6")]
[assembly: Guid("4358610B-F3F4-4843-B7AF-98B7BC60DCDE")]
[assembly: ComVisible(false)]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyProduct("ModAge")]
[assembly: AssemblyCompany("Azumatt")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyTitle("ModAge")]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: CompilationRelaxations(8)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.6.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[<610b26c2-7fad-4366-85d0-5cadc8fcd92f>Embedded]
	internal sealed class <610b26c2-7fad-4366-85d0-5cadc8fcd92f>EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	[CompilerGenerated]
	[<610b26c2-7fad-4366-85d0-5cadc8fcd92f>Embedded]
	internal sealed class <cc7b1332-106c-4569-876f-ed00c5dd5a7b>NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public <cc7b1332-106c-4569-876f-ed00c5dd5a7b>NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public <cc7b1332-106c-4569-876f-ed00c5dd5a7b>NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[<610b26c2-7fad-4366-85d0-5cadc8fcd92f>Embedded]
	[CompilerGenerated]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class <33a407d1-2201-4877-920e-f2f8c79530e2>NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public <33a407d1-2201-4877-920e-f2f8c79530e2>NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace LocalizationManager
{
	[<33a407d1-2201-4877-920e-f2f8c79530e2>NullableContext(1)]
	[PublicAPI]
	[<cc7b1332-106c-4569-876f-ed00c5dd5a7b>Nullable(0)]
	public class Localizer
	{
		private static readonly Dictionary<string, Dictionary<string, Func<string>>> PlaceholderProcessors;

		private static readonly Dictionary<string, Dictionary<string, string>> loadedTexts;

		private static readonly ConditionalWeakTable<Localization, string> localizationLanguage;

		private static readonly List<WeakReference<Localization>> localizationObjects;

		[<cc7b1332-106c-4569-876f-ed00c5dd5a7b>Nullable(2)]
		private static BaseUnityPlugin _plugin;

		private static readonly List<string> fileExtensions;

		private static BaseUnityPlugin plugin
		{
			get
			{
				//IL_009b: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a5: Expected O, but got Unknown
				if (_plugin == null)
				{
					IEnumerable<TypeInfo> source;
					try
					{
						source = Assembly.GetExecutingAssembly().DefinedTypes.ToList();
					}
					catch (ReflectionTypeLoadException ex)
					{
						source = from t in ex.Types
							where t != null
							select t.GetTypeInfo();
					}
					_plugin = (BaseUnityPlugin)Chainloader.ManagerObject.GetComponent((Type)source.First([<33a407d1-2201-4877-920e-f2f8c79530e2>NullableContext(0)] (TypeInfo t) => t.IsClass && typeof(BaseUnityPlugin).IsAssignableFrom(t)));
				}
				return _plugin;
			}
		}

		private static void UpdatePlaceholderText(Localization localization, string key)
		{
			localizationLanguage.TryGetValue(localization, out var value);
			string text = loadedTexts[value][key];
			if (PlaceholderProcessors.TryGetValue(key, out var value2))
			{
				text = value2.Aggregate(text, [<33a407d1-2201-4877-920e-f2f8c79530e2>NullableContext(0)] (string current, KeyValuePair<string, Func<string>> kv) => current.Replace("{" + kv.Key + "}", kv.Value()));
			}
			localization.AddWord(key, text);
		}

		public static void AddPlaceholder<T>(string key, string placeholder, ConfigEntry<T> config, [<cc7b1332-106c-4569-876f-ed00c5dd5a7b>Nullable(new byte[] { 2, 1, 1 })] Func<T, string> convertConfigValue = null)
		{
			if (convertConfigValue == null)
			{
				convertConfigValue = (T val) => val.ToString();
			}
			if (!PlaceholderProcessors.ContainsKey(key))
			{
				PlaceholderProcessors[key] = new Dictionary<string, Func<string>>();
			}
			config.SettingChanged += [<33a407d1-2201-4877-920e-f2f8c79530e2>NullableContext(0)] (object _, EventArgs _) =>
			{
				UpdatePlaceholder();
			};
			if (loadedTexts.ContainsKey(Localization.instance.GetSelectedLanguage()))
			{
				UpdatePlaceholder();
			}
			void UpdatePlaceholder()
			{
				PlaceholderProcessors[key][placeholder] = () => convertConfigValue(config.Value);
				UpdatePlaceholderText(Localization.instance, key);
			}
		}

		public static void AddText(string key, string text)
		{
			List<WeakReference<Localization>> list = new List<WeakReference<Localization>>();
			foreach (WeakReference<Localization> localizationObject in localizationObjects)
			{
				if (localizationObject.TryGetTarget(out var target))
				{
					Dictionary<string, string> dictionary = loadedTexts[localizationLanguage.GetOrCreateValue(target)];
					if (!target.m_translations.ContainsKey(key))
					{
						dictionary[key] = text;
						target.AddWord(key, text);
					}
				}
				else
				{
					list.Add(localizationObject);
				}
			}
			foreach (WeakReference<Localization> item in list)
			{
				localizationObjects.Remove(item);
			}
		}

		public static void Load()
		{
			LoadLocalization(Localization.instance, Localization.instance.GetSelectedLanguage());
		}

		private static void LoadLocalization(Localization __instance, string language)
		{
			if (!localizationLanguage.Remove(__instance))
			{
				localizationObjects.Add(new WeakReference<Localization>(__instance));
			}
			localizationLanguage.Add(__instance, language);
			Dictionary<string, string> dictionary = new Dictionary<string, string>();
			foreach (string item in from f in Directory.GetFiles(Path.GetDirectoryName(Paths.PluginPath), plugin.Info.Metadata.Name + ".*", SearchOption.AllDirectories)
				where fileExtensions.IndexOf(Path.GetExtension(f)) >= 0
				select f)
			{
				string text = Path.GetFileNameWithoutExtension(item).Split(new char[1] { '.' })[1];
				if (dictionary.ContainsKey(text))
				{
					Debug.LogWarning((object)("Duplicate key " + text + " found for " + plugin.Info.Metadata.Name + ". The duplicate file found at " + item + " will be skipped."));
				}
				else
				{
					dictionary[text] = item;
				}
			}
			byte[] array = LoadTranslationFromAssembly("English");
			if (array == null)
			{
				throw new Exception("Found no English localizations in mod " + plugin.Info.Metadata.Name + ". Expected an embedded resource translations/English.json or translations/English.yml.");
			}
			Dictionary<string, string> dictionary2 = new DeserializerBuilder().IgnoreFields().Build().Deserialize<Dictionary<string, string>>(Encoding.UTF8.GetString(array));
			if (dictionary2 == null)
			{
				throw new Exception("Localization for mod " + plugin.Info.Metadata.Name + " failed: Localization file was empty.");
			}
			string text2 = null;
			if (language != "English")
			{
				if (dictionary.ContainsKey(language))
				{
					text2 = File.ReadAllText(dictionary[language]);
				}
				else
				{
					byte[] array2 = LoadTranslationFromAssembly(language);
					if (array2 != null)
					{
						text2 = Encoding.UTF8.GetString(array2);
					}
				}
			}
			if (text2 == null && dictionary.ContainsKey("English"))
			{
				text2 = File.ReadAllText(dictionary["English"]);
			}
			if (text2 != null)
			{
				foreach (KeyValuePair<string, string> item2 in new DeserializerBuilder().IgnoreFields().Build().Deserialize<Dictionary<string, string>>(text2) ?? new Dictionary<string, string>())
				{
					dictionary2[item2.Key] = item2.Value;
				}
			}
			loadedTexts[language] = dictionary2;
			foreach (KeyValuePair<string, string> item3 in dictionary2)
			{
				UpdatePlaceholderText(__instance, item3.Key);
			}
		}

		static Localizer()
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			PlaceholderProcessors = new Dictionary<string, Dictionary<string, Func<string>>>();
			loadedTexts = new Dictionary<string, Dictionary<string, string>>();
			localizationLanguage = new ConditionalWeakTable<Localization, string>();
			localizationObjects = new List<WeakReference<Localization>>();
			fileExtensions = new List<string> { ".json", ".yml" };
			new Harmony("org.bepinex.helpers.LocalizationManager").Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Localization), "LoadCSV", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Localizer), "LoadLocalization", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}

		[return: <cc7b1332-106c-4569-876f-ed00c5dd5a7b>Nullable(2)]
		private static byte[] LoadTranslationFromAssembly(string language)
		{
			foreach (string fileExtension in fileExtensions)
			{
				byte[] array = ReadEmbeddedFileBytes("translations." + language + fileExtension);
				if (array != null)
				{
					return array;
				}
			}
			return null;
		}

		[<33a407d1-2201-4877-920e-f2f8c79530e2>NullableContext(2)]
		public static byte[] ReadEmbeddedFileBytes([<cc7b1332-106c-4569-876f-ed00c5dd5a7b>Nullable(1)] string resourceFileName, Assembly containingAssembly = null)
		{
			using MemoryStream memoryStream = new MemoryStream();
			if ((object)containingAssembly == null)
			{
				containingAssembly = Assembly.GetCallingAssembly();
			}
			string text = containingAssembly.GetManifestResourceNames().FirstOrDefault([<33a407d1-2201-4877-920e-f2f8c79530e2>NullableContext(0)] (string str) => str.EndsWith(resourceFileName, StringComparison.Ordinal));
			if (text != null)
			{
				containingAssembly.GetManifestResourceStream(text)?.CopyTo(memoryStream);
			}
			return (memoryStream.Length == 0L) ? null : memoryStream.ToArray();
		}
	}
}
namespace ModAge
{
	[HarmonyPatch(typeof(FejdStartup), "LoadMainScene")]
	internal static class FejdStartupLoadMainScenePatch
	{
		[<33a407d1-2201-4877-920e-f2f8c79530e2>NullableContext(1)]
		private static void Prefix(FejdStartup __instance)
		{
			if ((Object)(object)ModAgePlugin.modAgeUIFinal != (Object)null)
			{
				Object.Destroy((Object)(object)ModAgePlugin.modAgeUIFinal);
				ModAgePlugin.modAgeUIFinal = null;
			}
		}
	}
	[<33a407d1-2201-4877-920e-f2f8c79530e2>NullableContext(1)]
	[<cc7b1332-106c-4569-876f-ed00c5dd5a7b>Nullable(0)]
	[HarmonyPatch(typeof(FejdStartup), "SetupGui")]
	internal static class FejdStartupSetupGuiPatch
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			[<cc7b1332-106c-4569-876f-ed00c5dd5a7b>Nullable(0)]
			public static readonly <>c <>9 = new <>c();

			[<cc7b1332-106c-4569-876f-ed00c5dd5a7b>Nullable(0)]
			public static UnityAction <>9__1_0;

			internal void <CreateMenu>b__1_0()
			{
				try
				{
					ModAgePlugin.modAgeUIFinal.SetActive(!ModAgePlugin.modAgeUIFinal.activeSelf);
				}
				catch (Exception arg)
				{
					ModAgePlugin.ModAgeLogger.LogWarning((object)$"Exception caught while showing the Mod Age window: {arg}");
				}
			}
		}

		private static void Postfix(FejdStartup __instance)
		{
			try
			{
				if ((Object)(object)__instance.m_mainMenu.transform != (Object)null && (Object)(object)ModAgePlugin.modAgeUIFinal != (Object)null)
				{
					ModAgePlugin.modAgeUIFinal.transform.SetParent(__instance.m_mainMenu.transform, false);
					CreateMenu(Utils.FindChild(__instance.m_mainMenu.transform, "MenuEntries", (IterativeSearchType)0));
				}
				else if ((Object)(object)__instance.m_mainMenu.transform != (Object)null && (Object)(object)ModAgePlugin.modAgeUIFinal == (Object)null)
				{
					ModAgePlugin.modAgeUIcomp = (ModAgePlugin.modAgeUIFinal = Object.Instantiate<GameObject>(ModAgePlugin.modAgeUIAsset)).GetComponent<ModAgeUI>();
					Object.DontDestroyOnLoad((Object)(object)ModAgePlugin.modAgeUIFinal);
					ModAgePlugin.modAgeUIFinal.transform.SetParent(__instance.m_mainMenu.transform, false);
					CreateMenu(Utils.FindChild(__instance.m_mainMenu.transform, "MenuEntries", (IterativeSearchType)0));
					Utilities.CompareLocalModsToThunderstore();
				}
			}
			catch (Exception arg)
			{
				ModAgePlugin.ModAgeLogger.LogWarning((object)$"Exception caught while creating the Mod Age Menu Option: {arg}");
			}
		}

		internal static void CreateMenu(Transform menuList)
		{
			//IL_01cb: 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_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: 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_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Expected O, but got Unknown
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: 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_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: 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)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			ModAgePlugin.ModAgeLogger.LogDebug((object)"Instantiating Mod Age");
			bool flag = false;
			List<Button> list = new List<Button>();
			Button item = default(Button);
			for (int i = 0; i < menuList.childCount; i++)
			{
				if (((Component)menuList.GetChild(i)).gameObject.activeInHierarchy && ((Object)menuList.GetChild(i)).name != "ModAge" && ((Component)menuList.GetChild(i)).TryGetComponent<Button>(ref item))
				{
					list.Add(item);
				}
				if (((Object)menuList.GetChild(i)).name == "Settings")
				{
					Transform val = Object.Instantiate<Transform>(menuList.GetChild(i), menuList);
					((Object)val).name = "ModAge";
					((TMP_Text)((Component)val).GetComponentInChildren<TextMeshProUGUI>()).text = Localization.instance.Localize("$menu_title");
					Button component = ((Component)val).GetComponent<Button>();
					for (int j = 0; j < ((UnityEventBase)component.onClick).GetPersistentEventCount(); j++)
					{
						((UnityEventBase)component.onClick).SetPersistentListenerState(j, (UnityEventCallState)0);
					}
					((UnityEventBase)component.onClick).RemoveAllListeners();
					ButtonClickedEvent onClick = component.onClick;
					object obj = <>c.<>9__1_0;
					if (obj == null)
					{
						UnityAction val2 = delegate
						{
							try
							{
								ModAgePlugin.modAgeUIFinal.SetActive(!ModAgePlugin.modAgeUIFinal.activeSelf);
							}
							catch (Exception arg)
							{
								ModAgePlugin.ModAgeLogger.LogWarning((object)$"Exception caught while showing the Mod Age window: {arg}");
							}
						};
						<>c.<>9__1_0 = val2;
						obj = (object)val2;
					}
					((UnityEvent)onClick).AddListener((UnityAction)obj);
					list.Add(component);
					Transform val3 = val.Find("LeftKnot");
					if ((Object)(object)val3 != (Object)null)
					{
						Vector3 localPosition = val3.localPosition;
						localPosition = Vector2.op_Implicit(new Vector2(localPosition.x - 10f, localPosition.y));
						val3.localPosition = localPosition;
					}
					Transform val4 = val.Find("RightKnot");
					if ((Object)(object)val4 != (Object)null)
					{
						Vector3 localPosition2 = val4.localPosition;
						localPosition2 = Vector2.op_Implicit(new Vector2(localPosition2.x + 10f, localPosition2.y));
						val4.localPosition = localPosition2;
					}
					flag = true;
				}
				else if (flag)
				{
					RectTransform component2 = ((Component)menuList.GetChild(i)).GetComponent<RectTransform>();
					Vector2 anchoredPosition = component2.anchoredPosition;
					((Vector2)(ref anchoredPosition))..ctor(anchoredPosition.x, anchoredPosition.y - 40f);
					component2.anchoredPosition = anchoredPosition;
				}
			}
			if ((Object)(object)FejdStartup.instance != (Object)null)
			{
				FejdStartup.instance.m_menuButtons = list.ToArray();
			}
		}
	}
	[<33a407d1-2201-4877-920e-f2f8c79530e2>NullableContext(1)]
	[<cc7b1332-106c-4569-876f-ed00c5dd5a7b>Nullable(0)]
	[BepInPlugin("Azumatt.ModAge", "ModAge", "1.0.6")]
	public class ModAgePlugin : BaseUnityPlugin
	{
		[<33a407d1-2201-4877-920e-f2f8c79530e2>NullableContext(0)]
		public enum Toggle
		{
			Off,
			On
		}

		[<33a407d1-2201-4877-920e-f2f8c79530e2>NullableContext(0)]
		private class ConfigurationManagerAttributes
		{
			[UsedImplicitly]
			public int? Order;

			[UsedImplicitly]
			public bool? Browsable;

			[UsedImplicitly]
			[<cc7b1332-106c-4569-876f-ed00c5dd5a7b>Nullable(2)]
			public string Category;

			[UsedImplicitly]
			[<cc7b1332-106c-4569-876f-ed00c5dd5a7b>Nullable(new byte[] { 2, 1 })]
			public Action<ConfigEntryBase> CustomDrawer;
		}

		internal const string ModName = "ModAge";

		internal const string ModVersion = "1.0.6";

		internal const string Author = "Azumatt";

		private const string ModGUID = "Azumatt.ModAge";

		private readonly Harmony _harmony = new Harmony("Azumatt.ModAge");

		public static readonly ManualLogSource ModAgeLogger = Logger.CreateLogSource("ModAge");

		public static GameObject modAgeUIAsset = null;

		public static GameObject modAgeUIFinal = null;

		public static ModAgeUI modAgeUIcomp = null;

		public static GameObject modAgeUIObject = null;

		internal static ModAgePlugin Instance = null;

		[<cc7b1332-106c-4569-876f-ed00c5dd5a7b>Nullable(2)]
		private Coroutine modcheckerCoroutine;

		[<cc7b1332-106c-4569-876f-ed00c5dd5a7b>Nullable(2)]
		internal static Coroutine modcheckerImageCoroutine;

		[<cc7b1332-106c-4569-876f-ed00c5dd5a7b>Nullable(new byte[] { 2, 1 })]
		internal static List<PackageInfo> allPackagesInfo = null;

		[<cc7b1332-106c-4569-876f-ed00c5dd5a7b>Nullable(new byte[] { 2, 1, 1 })]
		internal static Dictionary<string, PreparedPackageInfo> allPreparedPackagesInfo = null;

		internal static bool CanCompareMods = false;

		internal Action RefreshModListDelegate;

		internal static ConfigEntry<Toggle> showAllMods = null;

		internal static ConfigEntry<int> yearConfig = null;

		internal static ConfigEntry<int> monthConfig = null;

		internal static ConfigEntry<int> dayConfig = null;

		internal static ConfigEntry<int> hourConfig = null;

		internal static ConfigEntry<int> minuteConfig = null;

		internal static ConfigEntry<int> secondConfig = null;

		public void Awake()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Expected O, but got Unknown
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Expected O, but got Unknown
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Expected O, but got Unknown
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Expected O, but got Unknown
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Expected O, but got Unknown
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Expected O, but got Unknown
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: Expected O, but got Unknown
			if ((int)SystemInfo.graphicsDeviceType == 4)
			{
				ModAgeLogger.LogWarning((object)"ModAge does not work in headless mode as it's a client only mod. ModAge will not be loaded.");
				return;
			}
			bool saveOnConfigSet = ((BaseUnityPlugin)this).Config.SaveOnConfigSet;
			((BaseUnityPlugin)this).Config.SaveOnConfigSet = false;
			showAllMods = config("1 - General", "ShowAllMods", Toggle.Off, new ConfigDescription("Show all mods, not just outdated ones.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 6
				}
			}));
			RefreshModListDelegate = RefreshModList;
			showAllMods.SettingChanged += OnShowAllModsChanged;
			yearConfig = config("1 - General", "YearToTarget", 2024, new ConfigDescription("Year to target. This is the year that the mods will be compared to.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 5
				}
			}));
			yearConfig.SettingChanged += OnShowAllModsChanged;
			monthConfig = config("1 - General", "MonthToTarget", 5, new ConfigDescription("Month to target. This is the month that the mods will be compared to.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 4
				}
			}));
			monthConfig.SettingChanged += OnShowAllModsChanged;
			dayConfig = config("1 - General", "DayToTarget", 14, new ConfigDescription("Day to target. This is the day that the mods will be compared to.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 3
				}
			}));
			dayConfig.SettingChanged += OnShowAllModsChanged;
			hourConfig = config("1 - General", "HourToTarget", 7, new ConfigDescription("Hour to target. It's advised to make this slightly after the update to be the most accurate. This is the hour that the mods will be compared to.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 2
				}
			}));
			hourConfig.SettingChanged += OnShowAllModsChanged;
			minuteConfig = config("1 - General", "MinuteToTarget", 30, new ConfigDescription("Minute to target. This is the minute that the mods will be compared to. It's advised to set this slightly after the expected update time for accuracy.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 1
				}
			}));
			minuteConfig.SettingChanged += OnShowAllModsChanged;
			secondConfig = config("1 - General", "SecondToTarget", 0, new ConfigDescription("Second to target. This is the second that the mods will be compared to. It's advised to set this slightly after the expected update time for accuracy.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 0
				}
			}));
			secondConfig.SettingChanged += OnShowAllModsChanged;
			Instance = this;
			Localizer.Load();
			Utilities.LoadAssets();
			modAgeUIcomp = (modAgeUIFinal = Object.Instantiate<GameObject>(modAgeUIAsset)).GetComponent<ModAgeUI>();
			Object.DontDestroyOnLoad((Object)(object)modAgeUIFinal);
			modAgeUIFinal.SetActive(false);
			modcheckerCoroutine = ((MonoBehaviour)this).StartCoroutine(Utilities.CheckModUpdates());
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			_harmony.PatchAll(executingAssembly);
			if (saveOnConfigSet)
			{
				((BaseUnityPlugin)this).Config.SaveOnConfigSet = true;
				((BaseUnityPlugin)this).Config.Save();
			}
		}

		public void Start()
		{
			if (CanCompareMods)
			{
				ModAgeLogger.LogDebug((object)"Comparing local mods to prepared packages");
				Utilities.CompareLocalModsToPreparedPackage();
			}
			else
			{
				ModAgeLogger.LogWarning((object)"CanCompareMods is false, not comparing local mods to prepared packages");
				((MonoBehaviour)this).Invoke("CompareLocalModsToPreparedPackage", 10f);
			}
		}

		private void OnShowAllModsChanged(object sender, EventArgs e)
		{
			RefreshModListDelegate?.Invoke();
		}

		public void RefreshModList()
		{
			if (modcheckerCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(modcheckerCoroutine);
			}
			if (modcheckerImageCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(modcheckerImageCoroutine);
			}
			ClearUI();
			modcheckerCoroutine = ((MonoBehaviour)this).StartCoroutine(Utilities.CheckModUpdates());
		}

		private void ClearUI()
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			if (!((Object)(object)modAgeUIcomp != (Object)null) || !((Object)(object)modAgeUIcomp.contentList != (Object)null))
			{
				return;
			}
			foreach (Transform item in ((Component)modAgeUIcomp.contentList).transform)
			{
				Transform val = item;
				if ((Object)(object)((Component)val).gameObject != (Object)(object)((Component)modAgeUIcomp.Placeholder).gameObject)
				{
					Object.Destroy((Object)(object)((Component)val).gameObject);
				}
			}
		}

		private void OnDestroy()
		{
			if (modcheckerCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(modcheckerCoroutine);
			}
			if (modcheckerImageCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(modcheckerImageCoroutine);
			}
			((BaseUnityPlugin)this).Config.Save();
		}

		private ConfigEntry<T> config<[<cc7b1332-106c-4569-876f-ed00c5dd5a7b>Nullable(2)] T>(string group, string name, T value, ConfigDescription description)
		{
			return ((BaseUnityPlugin)this).Config.Bind<T>(group, name, value, description);
		}

		private ConfigEntry<T> config<[<cc7b1332-106c-4569-876f-ed00c5dd5a7b>Nullable(2)] T>(string group, string name, T value, string description)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			return config(group, name, value, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>()));
		}
	}
	[<33a407d1-2201-4877-920e-f2f8c79530e2>NullableContext(1)]
	[<cc7b1332-106c-4569-876f-ed00c5dd5a7b>Nullable(0)]
	public class ModAgeUI : MonoBehaviour
	{
		public Canvas canvas;

		public RectTransform root;

		public Image BackgroundBack;

		public Button BackgroundBackButton;

		public Button BackgroundBackButtonImage;

		public Image Background;

		public RectTransform Header;

		public HorizontalLayoutGroup HeaderHLG;

		public Image HeaderImageLeft;

		public Image HeaderImageRight;

		public TextMeshProUGUI HeaderTMP;

		public RectTransform content;

		public ScrollRect contentScrollRect;

		public Image contentScrollRectImage;

		public RectTransform contentList;

		public VerticalLayoutGroup contentListVLG;

		public ContentSizeFitter contentListContentSizeFitter;

		[Header("Placeholder Object")]
		public ModAgeUIPlaceholder PlaceholderInstance;

		public RectTransform Placeholder;

		public RectTransform PlaceholderBack;

		public RectTransform PlaceholderBackBg;

		public RectTransform PlaceholderBackBgImg;

		public RectTransform PlaceholderBackBorder;

		public RectTransform ModRowPlaceholderBackBorderImg;

		public RectTransform PlaceholderContent;

		public RectTransform PlaceholderContentTopRow;

		public Image PlaceholderModImage;

		public TextMeshProUGUI PlaceholderModName;

		public TextMeshProUGUI PlaceholderLastUpdated;

		public TextMeshProUGUI PlaceholderGameUpdatedBool;

		public TextMeshProUGUI PlaceholderVersionInstalled;

		public TextMeshProUGUI PlaceholderVersionAvailable;

		public Button PlaceholderMoreInfoButton;

		[Header("Scrollarea")]
		public Scrollbar contentScrollbar;

		public RectTransform contentScrollbarSlidingArea;

		public Image contentScrollbarImage;

		public RectTransform contentScrollbarHandle;

		public Image contentScrollbarHandleImage;

		public void Awake()
		{
		}

		public void Start()
		{
		}

		public void Update()
		{
		}

		public void OnMoreInfoClicked()
		{
		}
	}
	[<33a407d1-2201-4877-920e-f2f8c79530e2>NullableContext(1)]
	[<cc7b1332-106c-4569-876f-ed00c5dd5a7b>Nullable(0)]
	public class ModAgeUIPlaceholder : MonoBehaviour
	{
		[Header("Placeholder Object")]
		public ModAgeUIPlaceholder PlaceholderInstance;

		public RectTransform Placeholder;

		public RectTransform PlaceholderBack;

		public RectTransform PlaceholderBackBg;

		public RectTransform PlaceholderBackBgImg;

		public RectTransform PlaceholderBackBorder;

		public RectTransform ModRowPlaceholderBackBorderImg;

		public RectTransform PlaceholderContent;

		public RectTransform PlaceholderContentTopRow;

		public Image PlaceholderModImage;

		public TextMeshProUGUI PlaceholderModName;

		public TextMeshProUGUI PlaceholderLastUpdated;

		public TextMeshProUGUI PlaceholderGameUpdatedBool;

		public TextMeshProUGUI PlaceholderVersionInstalled;

		public TextMeshProUGUI PlaceholderVersionAvailable;

		public Button PlaceholderMoreInfoButton;

		private void Awake()
		{
			PlaceholderInstance = this;
		}
	}
	[<33a407d1-2201-4877-920e-f2f8c79530e2>NullableContext(2)]
	[<cc7b1332-106c-4569-876f-ed00c5dd5a7b>Nullable(0)]
	public class VersionInfo
	{
		public string name { get; set; }

		public string full_name { get; set; }

		public string description { get; set; }

		public string icon { get; set; }

		public string version_number { get; set; }

		[<cc7b1332-106c-4569-876f-ed00c5dd5a7b>Nullable(new byte[] { 2, 1 })]
		[field: <cc7b1332-106c-4569-876f-ed00c5dd5a7b>Nullable(new byte[] { 2, 1 })]
		public List<string> dependencies
		{
			[return: <cc7b1332-106c-4569-876f-ed00c5dd5a7b>Nullable(new byte[] { 2, 1 })]
			get;
			[param: <cc7b1332-106c-4569-876f-ed00c5dd5a7b>Nullable(new byte[] { 2, 1 })]
			set;
		}

		public string download_url { get; set; }

		public int downloads { get; set; }

		public string date_created { get; set; }

		public string website_url { get; set; }

		public bool is_active { get; set; }

		public string uuid4 { get; set; }

		public int file_size { get; set; }
	}
	[<33a407d1-2201-4877-920e-f2f8c79530e2>NullableContext(2)]
	[<cc7b1332-106c-4569-876f-ed00c5dd5a7b>Nullable(0)]
	public class PackageInfo
	{
		public string name { get; set; }

		public string full_name { get; set; } = string.Empty;


		public string owner { get; set; }

		public string package_url { get; set; }

		public string donation_link { get; set; }

		public string date_created { get; set; }

		public string date_updated { get; set; }

		public string uuid4 { get; set; }

		public int rating_score { get; set; }

		public bool is_pinned { get; set; }

		public bool is_deprecated { get; set; }

		public bool has_nsfw_content { get; set; }

		[<cc7b1332-106c-4569-876f-ed00c5dd5a7b>Nullable(new byte[] { 2, 1 })]
		[field: <cc7b1332-106c-4569-876f-ed00c5dd5a7b>Nullable(new byte[] { 2, 1 })]
		public List<string> categories
		{
			[return: <cc7b1332-106c-4569-876f-ed00c5dd5a7b>Nullable(new byte[] { 2, 1 })]
			get;
			[param: <cc7b1332-106c-4569-876f-ed00c5dd5a7b>Nullable(new byte[] { 2, 1 })]
			set;
		}

		[<cc7b1332-106c-4569-876f-ed00c5dd5a7b>Nullable(new byte[] { 2, 1 })]
		[field: <cc7b1332-106c-4569-876f-ed00c5dd5a7b>Nullable(new byte[] { 2, 1 })]
		public List<VersionInfo> versions
		{
			[return: <cc7b1332-106c-4569-876f-ed00c5dd5a7b>Nullable(new byte[] { 2, 1 })]
			get;
			[param: <cc7b1332-106c-4569-876f-ed00c5dd5a7b>Nullable(new byte[] { 2, 1 })]
			set;
		}
	}
	[<cc7b1332-106c-4569-876f-ed00c5dd5a7b>Nullable(0)]
	[<33a407d1-2201-4877-920e-f2f8c79530e2>NullableContext(2)]
	public class PreparedPackageInfo
	{
		public string name { get; set; }

		public string clean_name { get; set; }

		public string icon_url { get; set; }

		public string version { get; set; }

		public string updated { get; set; }

		public bool? deprecated { get; set; }

		[<cc7b1332-106c-4569-876f-ed00c5dd5a7b>Nullable(new byte[] { 2, 1 })]
		[field: <cc7b1332-106c-4569-876f-ed00c5dd5a7b>Nullable(new byte[] { 2, 1 })]
		public string[] urls
		{
			[return: <cc7b1332-106c-4569-876f-ed00c5dd5a7b>Nullable(new byte[] { 2, 1 })]
			get;
			[param: <cc7b1332-106c-4569-876f-ed00c5dd5a7b>Nullable(new byte[] { 2, 1 })]
			set;
		}
	}
	[<33a407d1-2201-4877-920e-f2f8c79530e2>NullableContext(1)]
	[<cc7b1332-106c-4569-876f-ed00c5dd5a7b>Nullable(0)]
	public class Utilities
	{
		public static AssetBundle GetAssetBundleFromResources(string filename)
		{
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			string name = executingAssembly.GetManifestResourceNames().Single([<33a407d1-2201-4877-920e-f2f8c79530e2>NullableContext(0)] (string str) => str.EndsWith(filename));
			using Stream stream = executingAssembly.GetManifestResourceStream(name);
			return AssetBundle.LoadFromStream(stream);
		}

		public static void LoadAssets()
		{
			AssetBundle assetBundleFromResources = GetAssetBundleFromResources("modage");
			ModAgePlugin.modAgeUIAsset = assetBundleFromResources.LoadAsset<GameObject>("ModAgeUI");
			ModAgePlugin.modAgeUIAsset.AddComponent<Localize>();
			ModAgePlugin.modAgeUIcomp = ModAgePlugin.modAgeUIAsset.GetComponent<ModAgeUI>();
			if (assetBundleFromResources != null)
			{
				assetBundleFromResources.Unload(false);
			}
		}

		internal static IEnumerator LoadSpriteFromURL([<cc7b1332-106c-4569-876f-ed00c5dd5a7b>Nullable(2)] string imageURL, Action<Sprite> callback)
		{
			if (imageURL == null)
			{
				callback(null);
				yield break;
			}
			UnityWebRequest www = UnityWebRequestTexture.GetTexture(imageURL);
			yield return www.SendWebRequest();
			Result result = www.result;
			if (result - 2 <= 1)
			{
				ModAgePlugin.ModAgeLogger.LogError((object)("Error while fetching image: " + www.error));
				callback(null);
			}
			else
			{
				Texture2D content = DownloadHandlerTexture.GetContent(www);
				Sprite obj = Sprite.Create(content, new Rect(0f, 0f, (float)((Texture)content).width, (float)((Texture)content).height), new Vector2(0.5f, 0.5f));
				callback(obj);
			}
		}

		private static IEnumerator GetAllModsFromThunderstore([<cc7b1332-106c-4569-876f-ed00c5dd5a7b>Nullable(new byte[] { 1, 2, 1 })] Action<List<PackageInfo>> callback)
		{
			string text = "https://thunderstore.io/c/valheim/api/v1/package/";
			UnityWebRequest webRequest = UnityWebRequest.Get(text);
			try
			{
				webRequest.SetRequestHeader("Accept-Encoding", "gzip");
				yield return webRequest.SendWebRequest();
				Result result = webRequest.result;
				if (result - 2 <= 1)
				{
					ModAgePlugin.ModAgeLogger.LogError((object)webRequest.error);
					callback(null);
				}
				else
				{
					string text2 = webRequest.downloadHandler.text;
					ModAgePlugin.allPackagesInfo = new DeserializerBuilder().Build().Deserialize<List<PackageInfo>>(text2);
					callback(ModAgePlugin.allPackagesInfo);
				}
			}
			finally
			{
				((IDisposable)webRequest)?.Dispose();
			}
		}

		private static IEnumerator GetAllModsModVersionCheckBot([<cc7b1332-106c-4569-876f-ed00c5dd5a7b>Nullable(new byte[] { 1, 2, 1, 1 })] Action<Dictionary<string, PreparedPackageInfo>> callback)
		{
			string text = "https://mod-version-check.eu/api/experimental/prepared-mods";
			UnityWebRequest webRequest = UnityWebRequest.Get(text);
			try
			{
				webRequest.SetRequestHeader("Accept-Encoding", "gzip");
				yield return webRequest.SendWebRequest();
				Result result = webRequest.result;
				if (result - 2 <= 1)
				{
					ModAgePlugin.ModAgeLogger.LogError((object)webRequest.error);
					callback(null);
				}
				else
				{
					string text2 = webRequest.downloadHandler.text;
					ModAgePlugin.allPreparedPackagesInfo = new DeserializerBuilder().Build().Deserialize<Dictionary<string, PreparedPackageInfo>>(text2);
					callback(ModAgePlugin.allPreparedPackagesInfo);
				}
			}
			finally
			{
				((IDisposable)webRequest)?.Dispose();
			}
		}

		internal static string ConvertToThunderstoreFormat(string modName)
		{
			modName = modName.Replace(" ", "_");
			modName = new string(modName.Where((char c) => char.IsLetterOrDigit(c) || c == '_').ToArray());
			return modName;
		}

		internal static IEnumerator CheckModUpdates()
		{
			if (ModAgePlugin.allPreparedPackagesInfo == null)
			{
				yield return GetAllModsModVersionCheckBot(([<cc7b1332-106c-4569-876f-ed00c5dd5a7b>Nullable(new byte[] { 2, 1, 1 })] Dictionary<string, PreparedPackageInfo> result) =>
				{
					if (result != null)
					{
						ModAgePlugin.ModAgeLogger.LogDebug((object)"Got prepared mods from mod-version-check.eu");
						ModAgePlugin.CanCompareMods = true;
					}
					else
					{
						ModAgePlugin.ModAgeLogger.LogError((object)"Error: Could not get prepared mods from mod-version-check.eu");
					}
				});
			}
			else
			{
				CompareLocalModsToPreparedPackage();
			}
		}

		internal static void CompareLocalModsToThunderstore()
		{
			foreach (PluginInfo value in Chainloader.PluginInfos.Values)
			{
				string modNameInThunderstoreFormat = ConvertToThunderstoreFormat(value.Metadata.Name);
				PackageInfo packageInfo = ModAgePlugin.allPackagesInfo?.FirstOrDefault([<33a407d1-2201-4877-920e-f2f8c79530e2>NullableContext(0)] (PackageInfo x) => x.name != null && x.name.Equals(modNameInThunderstoreFormat, StringComparison.OrdinalIgnoreCase));
				ModAgePlugin.ModAgeLogger.LogDebug((object)("Original Mod Name: " + value.Metadata.Name));
				ModAgePlugin.ModAgeLogger.LogDebug((object)("Converted Mod Name: " + modNameInThunderstoreFormat));
				if (packageInfo != null)
				{
					List<VersionInfo> versions = packageInfo.versions;
					if (versions != null && versions.Count > 0)
					{
						string version_number = packageInfo.versions[0].version_number;
						UpdateUI(value.Metadata.Name, value.Metadata.Version.ToString(), version_number, packageInfo);
						ModAgePlugin.ModAgeLogger.LogDebug((object)("Match found for " + modNameInThunderstoreFormat));
						continue;
					}
				}
				ModAgePlugin.ModAgeLogger.LogWarning((object)("No match found for " + modNameInThunderstoreFormat));
			}
			ModAgePlugin.modAgeUIFinal.SetActive(false);
		}

		internal static void CompareLocalModsToPreparedPackage()
		{
			foreach (PluginInfo pluginInfo in Chainloader.PluginInfos.Values)
			{
				KeyValuePair<string, PreparedPackageInfo>? keyValuePair = ModAgePlugin.allPreparedPackagesInfo?.FirstOrDefault([<33a407d1-2201-4877-920e-f2f8c79530e2>NullableContext(0)] (KeyValuePair<string, PreparedPackageInfo> x) => x.Value.clean_name != null && x.Value.clean_name.Equals(pluginInfo.Metadata.Name.ToLower(), StringComparison.OrdinalIgnoreCase));
				PreparedPackageInfo preparedPackageInfo = keyValuePair?.Value;
				if (preparedPackageInfo != null)
				{
					string version = preparedPackageInfo.version;
					if (version != null && version.Length > 0)
					{
						string version2 = keyValuePair.Value.Value.version;
						UpdateUIPrepackaged(pluginInfo.Metadata.Name, pluginInfo.Metadata.Version.ToString(), version2, keyValuePair);
					}
				}
			}
		}

		private static void UpdateUI(string modName, [<cc7b1332-106c-4569-876f-ed00c5dd5a7b>Nullable(2)] string localVersion, [<cc7b1332-106c-4569-876f-ed00c5dd5a7b>Nullable(2)] string latestVersion, PackageInfo packageInfo)
		{
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Expected O, but got Unknown
			System.Version version = ParseVersion(localVersion);
			System.Version version2 = ParseVersion(latestVersion);
			if (version2 == version || ParseVersion(localVersion + ".0") == version2)
			{
				return;
			}
			RectTransform val = Object.Instantiate<RectTransform>(ModAgePlugin.modAgeUIcomp.Placeholder, ((Component)ModAgePlugin.modAgeUIcomp.contentList).transform, false);
			((Component)val).gameObject.SetActive(true);
			Transform obj = Utils.FindChild(((Component)val).transform, "Naming", (IterativeSearchType)0);
			Transform val2 = Utils.FindChild(((Component)val).transform, "Right column", (IterativeSearchType)0);
			TextMeshProUGUI component = ((Component)Utils.FindChild(((Component)obj).transform, "ModName", (IterativeSearchType)0)).GetComponent<TextMeshProUGUI>();
			TextMeshProUGUI component2 = ((Component)Utils.FindChild(((Component)obj).transform, "ModVersion", (IterativeSearchType)0)).GetComponent<TextMeshProUGUI>();
			TextMeshProUGUI component3 = ((Component)Utils.FindChild(((Component)obj).transform, "ModStatus", (IterativeSearchType)0)).GetComponent<TextMeshProUGUI>();
			TextMeshProUGUI component4 = ((Component)Utils.FindChild(((Component)val2).transform, "ModLinkButtonText", (IterativeSearchType)0)).GetComponent<TextMeshProUGUI>();
			Button component5 = ((Component)Utils.FindChild(((Component)val2).transform, "ModLinkButton", (IterativeSearchType)0)).GetComponent<Button>();
			TextMeshProUGUI component6 = ((Component)Utils.FindChild(((Component)val2).transform, "Placeholder", (IterativeSearchType)0)).GetComponent<TextMeshProUGUI>();
			Image modIcon = ((Component)Utils.FindChild(((Component)val).transform, "ModIcon", (IterativeSearchType)0)).GetComponent<Image>();
			((TMP_Text)component).text = packageInfo.full_name;
			((TMP_Text)component2).text = "Installed (" + localVersion + ")";
			((TMP_Text)component3).text = ((version2 > version) ? $"<color=red>Update available: {version2}</color>" : $"Test version: Live Version is {version2}");
			((TMP_Text)component4).text = packageInfo.name + " on Thunderstore";
			((UnityEvent)component5.onClick).AddListener((UnityAction)delegate
			{
				Application.OpenURL(packageInfo.package_url);
			});
			VersionInfo versionInfo = packageInfo.versions?.FirstOrDefault([<33a407d1-2201-4877-920e-f2f8c79530e2>NullableContext(0)] (VersionInfo x) => x.version_number == localVersion) ?? packageInfo.versions?[0];
			if (versionInfo == null)
			{
				ModAgePlugin.ModAgeLogger.LogError((object)("No version info found for " + packageInfo.name));
				return;
			}
			DateTime dateTime = DateTime.Parse(versionInfo.date_created, CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind);
			string text = dateTime.ToString("MMMM dd, yyyy hh:mm:ss tt", CultureInfo.InvariantCulture);
			((TMP_Text)component6).text = ((dateTime < new DateTime(ModAgePlugin.yearConfig.Value, ModAgePlugin.monthConfig.Value, ModAgePlugin.dayConfig.Value, ModAgePlugin.hourConfig.Value, ModAgePlugin.minuteConfig.Value, ModAgePlugin.secondConfig.Value)) ? ("Last Updated:\n " + text + "\n<color=red>This mod is older than the target Update!</color>") : ("Last Updated:\n " + text + "\n<color=green>This mod is newer than the target Update!</color>"));
			ModAgePlugin.modcheckerImageCoroutine = ((MonoBehaviour)ModAgePlugin.Instance).StartCoroutine(LoadSpriteFromURL(packageInfo.versions?[0].icon, delegate(Sprite sprite)
			{
				if ((Object)(object)sprite != (Object)null)
				{
					modIcon.sprite = sprite;
				}
			}));
		}

		[<33a407d1-2201-4877-920e-f2f8c79530e2>NullableContext(2)]
		private static void UpdateUIPrepackaged([<cc7b1332-106c-4569-876f-ed00c5dd5a7b>Nullable(1)] string modName, string localVersion, string latestVersion, [<cc7b1332-106c-4569-876f-ed00c5dd5a7b>Nullable(new byte[] { 0, 1, 1 })] KeyValuePair<string, PreparedPackageInfo>? packageInfo)
		{
			//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c4: Expected O, but got Unknown
			System.Version version = ParseVersion(localVersion);
			System.Version version2 = ParseVersion(latestVersion);
			DateTime dateTime = DateTime.Parse(packageInfo?.Value.updated, CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind).ToLocalTime();
			string text = dateTime.ToString("MMMM dd, yyyy hh:mm:ss tt", CultureInfo.InvariantCulture);
			DateTime dateTime2 = new DateTime(ModAgePlugin.yearConfig.Value, ModAgePlugin.monthConfig.Value, ModAgePlugin.dayConfig.Value, ModAgePlugin.hourConfig.Value, ModAgePlugin.minuteConfig.Value, ModAgePlugin.secondConfig.Value, DateTimeKind.Local);
			bool flag = dateTime < dateTime2;
			if (!(ModAgePlugin.showAllMods.Value == ModAgePlugin.Toggle.On || flag) && !(version2 > version))
			{
				return;
			}
			RectTransform val = Object.Instantiate<RectTransform>(ModAgePlugin.modAgeUIcomp.Placeholder, ((Component)ModAgePlugin.modAgeUIcomp.contentList).transform, false);
			((Component)val).gameObject.SetActive(true);
			ModAgeUIPlaceholder placeholder = default(ModAgeUIPlaceholder);
			((Component)val).TryGetComponent<ModAgeUIPlaceholder>(ref placeholder);
			if (!Object.op_Implicit((Object)(object)placeholder) || !packageInfo.HasValue)
			{
				return;
			}
			TextMeshProUGUI placeholderModName = placeholder.PlaceholderModName;
			string obj = packageInfo?.Value.name;
			ref KeyValuePair<string, PreparedPackageInfo>? reference = ref packageInfo;
			object obj2;
			if (!reference.HasValue)
			{
				obj2 = null;
			}
			else
			{
				string icon_url = reference.GetValueOrDefault().Value.icon_url;
				obj2 = ((icon_url != null) ? icon_url.Split(new char[1] { '/' }).Last().Split(new char[1] { '-' })[0] : null);
			}
			((TMP_Text)placeholderModName).text = obj + " <color=#DB8000>by " + (string?)obj2 + "</color>";
			if (version2 > version)
			{
				((TMP_Text)placeholder.PlaceholderVersionInstalled).text = "$modage_anewversionavailable";
				((TMP_Text)placeholder.PlaceholderVersionAvailable).text = $"<color=#CC5500>{version2}</color>";
			}
			else
			{
				((TMP_Text)placeholder.PlaceholderVersionInstalled).text = $"$modage_versioninstalled: {version}";
				((TMP_Text)placeholder.PlaceholderVersionAvailable).text = $"$modage_versionavailable: {version2}";
			}
			((TMP_Text)placeholder.PlaceholderLastUpdated).text = "$modage_lastupdated: " + text;
			((TMP_Text)placeholder.PlaceholderGameUpdatedBool).text = (flag ? "$modage_gameupdatemessage: <color=#CC5500>$menu_no</color>" : "$modage_gameupdatemessage: <color=#2b932e>$menu_yes</color>");
			((TMP_Text)((Component)placeholder.PlaceholderMoreInfoButton).GetComponentInChildren<TextMeshProUGUI>()).text = "$modage_moreinformation";
			((UnityEvent)placeholder.PlaceholderMoreInfoButton.onClick).AddListener((UnityAction)delegate
			{
				ref KeyValuePair<string, PreparedPackageInfo>? reference2 = ref packageInfo;
				object obj3;
				if (!reference2.HasValue)
				{
					obj3 = null;
				}
				else
				{
					string[] urls = reference2.GetValueOrDefault().Value.urls;
					obj3 = ((urls != null) ? urls[0] : null);
				}
				Application.OpenURL((string)obj3);
			});
			ModAgePlugin.modcheckerImageCoroutine = ((MonoBehaviour)ModAgePlugin.Instance).StartCoroutine(LoadSpriteFromURL(packageInfo?.Value.icon_url, delegate(Sprite sprite)
			{
				if ((Object)(object)sprite != (Object)null)
				{
					placeholder.PlaceholderModImage.sprite = sprite;
				}
			}));
			Localize val2 = default(Localize);
			if (((Component)val).gameObject.TryGetComponent<Localize>(ref val2))
			{
				val2.RelocalizeAllUponChange();
			}
			else
			{
				((Component)val).gameObject.AddComponent<Localize>().RelocalizeAllUponChange();
			}
		}

		internal static System.Version ParseVersion([<cc7b1332-106c-4569-876f-ed00c5dd5a7b>Nullable(2)] string input)
		{
			try
			{
				if (input != null)
				{
					return System.Version.Parse(input);
				}
			}
			catch (ArgumentNullException)
			{
				ModAgePlugin.ModAgeLogger.LogError((object)"Error: String to be parsed is null.");
			}
			catch (ArgumentOutOfRangeException)
			{
				ModAgePlugin.ModAgeLogger.LogError((object)("Error: Negative value in '" + input + "'."));
			}
			catch (ArgumentException)
			{
				ModAgePlugin.ModAgeLogger.LogError((object)("Error: Bad number of components in '" + input + "'."));
			}
			catch (FormatException)
			{
				ModAgePlugin.ModAgeLogger.LogError((object)("Error: Non-integer value in '" + input + "'."));
			}
			catch (OverflowException)
			{
				ModAgePlugin.ModAgeLogger.LogError((object)("Error: Number out of range in '" + input + "'."));
			}
			return System.Version.Parse("1.0.6");
		}
	}
}
namespace Microsoft.CodeAnalysis
{
	[Microsoft.CodeAnalysis.Embedded]
	[CompilerGenerated]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[Microsoft.CodeAnalysis.Embedded]
	[CompilerGenerated]
	internal sealed class IsReadOnlyAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	[Microsoft.CodeAnalysis.Embedded]
	[CompilerGenerated]
	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;
		}
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace YamlDotNet
{
	internal sealed class CultureInfoAdapter : CultureInfo
	{
		private readonly IFormatProvider provider;

		public CultureInfoAdapter(CultureInfo baseCulture, IFormatProvider provider)
			: base(baseCulture.LCID)
		{
			this.provider = provider;
		}

		public override object? GetFormat(Type? formatType)
		{
			return provider.GetFormat(formatType);
		}
	}
	internal static class ReflectionExtensions
	{
		private static readonly FieldInfo? RemoteStackTraceField = typeof(Exception).GetField("_remoteStackTraceString", BindingFlags.Instance | BindingFlags.NonPublic);

		public static Type? BaseType(this Type type)
		{
			return type.BaseType;
		}

		public static bool IsValueType(this Type type)
		{
			return type.IsValueType;
		}

		public static bool IsGenericType(this Type type)
		{
			return type.IsGenericType;
		}

		public static bool IsGenericTypeDefinition(this Type type)
		{
			return type.IsGenericTypeDefinition;
		}

		public static bool IsInterface(this Type type)
		{
			return type.IsInterface;
		}

		public static bool IsEnum(this Type type)
		{
			return type.IsEnum;
		}

		public static bool IsDbNull(this object value)
		{
			return value is DBNull;
		}

		public static bool HasDefaultConstructor(this Type type, bool allowPrivateConstructors)
		{
			BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.Public;
			if (allowPrivateConstructors)
			{
				bindingFlags |= BindingFlags.NonPublic;
			}
			if (!type.IsValueType)
			{
				return type.GetConstructor(bindingFlags, null, Type.EmptyTypes, null) != null;
			}
			return true;
		}

		public static TypeCode GetTypeCode(this Type type)
		{
			return Type.GetTypeCode(type);
		}

		public static PropertyInfo? GetPublicProperty(this Type type, string name)
		{
			return type.GetProperty(name);
		}

		public static FieldInfo? GetPublicStaticField(this Type type, string name)
		{
			return type.GetField(name, BindingFlags.Static | BindingFlags.Public);
		}

		public static IEnumerable<PropertyInfo> GetProperties(this Type type, bool includeNonPublic)
		{
			BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.Public;
			if (includeNonPublic)
			{
				bindingFlags |= BindingFlags.NonPublic;
			}
			if (!type.IsInterface)
			{
				return type.GetProperties(bindingFlags);
			}
			return new Type[1] { type }.Concat(type.GetInterfaces()).SelectMany((Type i) => i.GetProperties(bindingFlags));
		}

		public static IEnumerable<PropertyInfo> GetPublicProperties(this Type type)
		{
			return type.GetProperties(includeNonPublic: false);
		}

		public static IEnumerable<FieldInfo> GetPublicFields(this Type type)
		{
			return type.GetFields(BindingFlags.Instance | BindingFlags.Public);
		}

		public static IEnumerable<MethodInfo> GetPublicStaticMethods(this Type type)
		{
			return type.GetMethods(BindingFlags.Static | BindingFlags.Public);
		}

		public static MethodInfo GetPrivateStaticMethod(this Type type, string name)
		{
			return type.GetMethod(name, BindingFlags.Static | BindingFlags.NonPublic) ?? throw new MissingMethodException("Expected to find a method named '" + name + "' in '" + type.FullName + "'.");
		}

		public static MethodInfo? GetPublicStaticMethod(this Type type, string name, params Type[] parameterTypes)
		{
			return type.GetMethod(name, BindingFlags.Static | BindingFlags.Public, null, parameterTypes, null);
		}

		public static MethodInfo? GetPublicInstanceMethod(this Type type, string name)
		{
			return type.GetMethod(name, BindingFlags.Instance | BindingFlags.Public);
		}

		public static Exception Unwrap(this TargetInvocationException ex)
		{
			Exception innerException = ex.InnerException;
			if (innerException == null)
			{
				return ex;
			}
			if (RemoteStackTraceField != null)
			{
				RemoteStackTraceField.SetValue(innerException, innerException.StackTrace + "\r\n");
			}
			return innerException;
		}

		public static bool IsInstanceOf(this Type type, object o)
		{
			return type.IsInstanceOfType(o);
		}

		public static Attribute[] GetAllCustomAttributes<TAttribute>(this PropertyInfo property)
		{
			return Attribute.GetCustomAttributes(property, typeof(TAttribute), inherit: true);
		}
	}
	internal static class PropertyInfoExtensions
	{
		public static object? ReadValue(this PropertyInfo property, object target)
		{
			return property.GetValue(target, null);
		}
	}
	internal static class StandardRegexOptions
	{
		public const RegexOptions Compiled = RegexOptions.Compiled;
	}
}
namespace YamlDotNet.Serialization
{
	internal abstract class BuilderSkeleton<TBuilder> where TBuilder : BuilderSkeleton<TBuilder>
	{
		internal INamingConvention namingConvention = NullNamingConvention.Instance;

		internal ITypeResolver typeResolver;

		internal readonly YamlAttributeOverrides overrides;

		internal readonly LazyComponentRegistrationList<Nothing, IYamlTypeConverter> typeConverterFactories;

		internal readonly LazyComponentRegistrationList<ITypeInspector, ITypeInspector> typeInspectorFactories;

		internal bool ignoreFields;

		internal bool includeNonPublicProperties;

		internal Settings settings;

		protected abstract TBuilder Self { get; }

		internal BuilderSkeleton(ITypeResolver typeResolver)
		{
			overrides = new YamlAttributeOverrides();
			typeConverterFactories = new LazyComponentRegistrationList<Nothing, IYamlTypeConverter>
			{
				{
					typeof(YamlDotNet.Serialization.Converters.GuidConverter),
					(Nothing _) => new YamlDotNet.Serialization.Converters.GuidConverter(jsonCompatible: false)
				},
				{
					typeof(SystemTypeConverter),
					(Nothing _) => new SystemTypeConverter()
				}
			};
			typeInspectorFactories = new LazyComponentRegistrationList<ITypeInspector, ITypeInspector>();
			this.typeResolver = typeResolver ?? throw new ArgumentNullException("typeResolver");
			settings = new Settings();
		}

		public TBuilder IgnoreFields()
		{
			ignoreFields = true;
			return Self;
		}

		public TBuilder IncludeNonPublicProperties()
		{
			includeNonPublicProperties = true;
			return Self;
		}

		public TBuilder EnablePrivateConstructors()
		{
			settings.AllowPrivateConstructors = true;
			return Self;
		}

		public TBuilder WithNamingConvention(INamingConvention namingConvention)
		{
			this.namingConvention = namingConvention ?? throw new ArgumentNullException("namingConvention");
			return Self;
		}

		public TBuilder WithTypeResolver(ITypeResolver typeResolver)
		{
			this.typeResolver = typeResolver ?? throw new ArgumentNullException("typeResolver");
			return Self;
		}

		public abstract TBuilder WithTagMapping(TagName tag, Type type);

		public TBuilder WithAttributeOverride<TClass>(Expression<Func<TClass, object>> propertyAccessor, Attribute attribute)
		{
			overrides.Add(propertyAccessor, attribute);
			return Self;
		}

		public TBuilder WithAttributeOverride(Type type, string member, Attribute attribute)
		{
			overrides.Add(type, member, attribute);
			return Self;
		}

		public TBuilder WithTypeConverter(IYamlTypeConverter typeConverter)
		{
			return WithTypeConverter(typeConverter, delegate(IRegistrationLocationSelectionSyntax<IYamlTypeConverter> w)
			{
				w.OnTop();
			});
		}

		public TBuilder WithTypeConverter(IYamlTypeConverter typeConverter, Action<IRegistrationLocationSelectionSyntax<IYamlTypeConverter>> where)
		{
			IYamlTypeConverter typeConverter2 = typeConverter;
			if (typeConverter2 == null)
			{
				throw new ArgumentNullException("typeConverter");
			}
			if (where == null)
			{
				throw new ArgumentNullException("where");
			}
			where(typeConverterFactories.CreateRegistrationLocationSelector(typeConverter2.GetType(), (Nothing _) => typeConverter2));
			return Self;
		}

		public TBuilder WithTypeConverter<TYamlTypeConverter>(WrapperFactory<IYamlTypeConverter, IYamlTypeConverter> typeConverterFactory, Action<ITrackingRegistrationLocationSelectionSyntax<IYamlTypeConverter>> where) where TYamlTypeConverter : IYamlTypeConverter
		{
			WrapperFactory<IYamlTypeConverter, IYamlTypeConverter> typeConverterFactory2 = typeConverterFactory;
			if (typeConverterFactory2 == null)
			{
				throw new ArgumentNullException("typeConverterFactory");
			}
			if (where == null)
			{
				throw new ArgumentNullException("where");
			}
			where(typeConverterFactories.CreateTrackingRegistrationLocationSelector(typeof(TYamlTypeConverter), (IYamlTypeConverter wrapped, Nothing _) => typeConverterFactory2(wrapped)));
			return Self;
		}

		public TBuilder WithoutTypeConverter<TYamlTypeConverter>() where TYamlTypeConverter : IYamlTypeConverter
		{
			return WithoutTypeConverter(typeof(TYamlTypeConverter));
		}

		public TBuilder WithoutTypeConverter(Type converterType)
		{
			if (converterType == null)
			{
				throw new ArgumentNullException("converterType");
			}
			typeConverterFactories.Remove(converterType);
			return Self;
		}

		public TBuilder WithTypeInspector<TTypeInspector>(Func<ITypeInspector, TTypeInspector> typeInspectorFactory) where TTypeInspector : ITypeInspector
		{
			return WithTypeInspector(typeInspectorFactory, delegate(IRegistrationLocationSelectionSyntax<ITypeInspector> w)
			{
				w.OnTop();
			});
		}

		public TBuilder WithTypeInspector<TTypeInspector>(Func<ITypeInspector, TTypeInspector> typeInspectorFactory, Action<IRegistrationLocationSelectionSyntax<ITypeInspector>> where) where TTypeInspector : ITypeInspector
		{
			Func<ITypeInspector, TTypeInspector> typeInspectorFactory2 = typeInspectorFactory;
			if (typeInspectorFactory2 == null)
			{
				throw new ArgumentNullException("typeInspectorFactory");
			}
			if (where == null)
			{
				throw new ArgumentNullException("where");
			}
			where(typeInspectorFactories.CreateRegistrationLocationSelector(typeof(TTypeInspector), (ITypeInspector inner) => typeInspectorFactory2(inner)));
			return Self;
		}

		public TBuilder WithTypeInspector<TTypeInspector>(WrapperFactory<ITypeInspector, ITypeInspector, TTypeInspector> typeInspectorFactory, Action<ITrackingRegistrationLocationSelectionSyntax<ITypeInspector>> where) where TTypeInspector : ITypeInspector
		{
			WrapperFactory<ITypeInspector, ITypeInspector, TTypeInspector> typeInspectorFactory2 = typeInspectorFactory;
			if (typeInspectorFactory2 == null)
			{
				throw new ArgumentNullException("typeInspectorFactory");
			}
			if (where == null)
			{
				throw new ArgumentNullException("where");
			}
			where(typeInspectorFactories.CreateTrackingRegistrationLocationSelector(typeof(TTypeInspector), (ITypeInspector wrapped, ITypeInspector inner) => typeInspectorFactory2(wrapped, inner)));
			return Self;
		}

		public TBuilder WithoutTypeInspector<TTypeInspector>() where TTypeInspector : ITypeInspector
		{
			return WithoutTypeInspector(typeof(TTypeInspector));
		}

		public TBuilder WithoutTypeInspector(Type inspectorType)
		{
			if (inspectorType == null)
			{
				throw new ArgumentNullException("inspectorType");
			}
			typeInspectorFactories.Remove(inspectorType);
			return Self;
		}

		protected IEnumerable<IYamlTypeConverter> BuildTypeConverters()
		{
			return typeConverterFactories.BuildComponentList();
		}
	}
	internal delegate TComponent WrapperFactory<TComponentBase, TComponent>(TComponentBase wrapped) where TComponent : TComponentBase;
	internal delegate TComponent WrapperFactory<TArgument, TComponentBase, TComponent>(TComponentBase wrapped, TArgument argument) where TComponent : TComponentBase;
	[Flags]
	internal enum DefaultValuesHandling
	{
		Preserve = 0,
		OmitNull = 1,
		OmitDefaults = 2,
		OmitEmptyCollections = 4
	}
	internal sealed class Deserializer : IDeserializer
	{
		private readonly IValueDeserializer valueDeserializer;

		public Deserializer()
			: this(new DeserializerBuilder().BuildValueDeserializer())
		{
		}

		private Deserializer(IValueDeserializer valueDeserializer)
		{
			this.valueDeserializer = valueDeserializer ?? throw new ArgumentNullException("valueDeserializer");
		}

		public static Deserializer FromValueDeserializer(IValueDeserializer valueDeserializer)
		{
			return new Deserializer(valueDeserializer);
		}

		public T Deserialize<T>(string input)
		{
			using StringReader input2 = new StringReader(input);
			return Deserialize<T>(input2);
		}

		public T Deserialize<T>(TextReader input)
		{
			return Deserialize<T>(new Parser(input));
		}

		public object? Deserialize(TextReader input)
		{
			return Deserialize(input, typeof(object));
		}

		public object? Deserialize(string input, Type type)
		{
			using StringReader input2 = new StringReader(input);
			return Deserialize(input2, type);
		}

		public object? Deserialize(TextReader input, Type type)
		{
			return Deserialize(new Parser(input), type);
		}

		public T Deserialize<T>(IParser parser)
		{
			return (T)Deserialize(parser, typeof(T));
		}

		public object? Deserialize(IParser parser)
		{
			return Deserialize(parser, typeof(object));
		}

		public object? Deserialize(IParser parser, Type type)
		{
			if (parser == null)
			{
				throw new ArgumentNullException("parser");
			}
			if (type == null)
			{
				throw new ArgumentNullException("type");
			}
			YamlDotNet.Core.Events.StreamStart @event;
			bool flag = parser.TryConsume<YamlDotNet.Core.Events.StreamStart>(out @event);
			YamlDotNet.Core.Events.DocumentStart event2;
			bool flag2 = parser.TryConsume<YamlDotNet.Core.Events.DocumentStart>(out event2);
			object result = null;
			if (!parser.Accept<YamlDotNet.Core.Events.DocumentEnd>(out var _) && !parser.Accept<YamlDotNet.Core.Events.StreamEnd>(out var _))
			{
				using SerializerState serializerState = new SerializerState();
				result = valueDeserializer.DeserializeValue(parser, type, serializerState, valueDeserializer);
				serializerState.OnDeserialization();
			}
			if (flag2)
			{
				parser.Consume<YamlDotNet.Core.Events.DocumentEnd>();
			}
			if (flag)
			{
				parser.Consume<YamlDotNet.Core.Events.StreamEnd>();
			}
			return result;
		}
	}
	internal sealed class DeserializerBuilder : BuilderSkeleton<DeserializerBuilder>
	{
		private Lazy<IObjectFactory> objectFactory;

		private readonly LazyComponentRegistrationList<Nothing, INodeDeserializer> nodeDeserializerFactories;

		private readonly LazyComponentRegistrationList<Nothing, INodeTypeResolver> nodeTypeResolverFactories;

		private readonly Dictionary<TagName, Type> tagMappings;

		private readonly Dictionary<Type, Type> typeMappings;

		private readonly ITypeConverter typeConverter;

		private bool ignoreUnmatched;

		private bool duplicateKeyChecking;

		private bool attemptUnknownTypeDeserialization;

		protected override DeserializerBuilder Self => this;

		public DeserializerBuilder()
			: base((ITypeResolver)new StaticTypeResolver())
		{
			typeMappings = new Dictionary<Type, Type>();
			objectFactory = new Lazy<IObjectFactory>(() => new DefaultObjectFactory(typeMappings, settings), isThreadSafe: true);
			tagMappings = new Dictionary<TagName, Type>
			{
				{
					FailsafeSchema.Tags.Map,
					typeof(Dictionary<object, object>)
				},
				{
					FailsafeSchema.Tags.Str,
					typeof(string)
				},
				{
					JsonSchema.Tags.Bool,
					typeof(bool)
				},
				{
					JsonSchema.Tags.Float,
					typeof(double)
				},
				{
					JsonSchema.Tags.Int,
					typeof(int)
				},
				{
					DefaultSchema.Tags.Timestamp,
					typeof(DateTime)
				}
			};
			typeInspectorFactories.Add(typeof(CachedTypeInspector), (ITypeInspector inner) => new CachedTypeInspector(inner));
			typeInspectorFactories.Add(typeof(NamingConventionTypeInspector), (ITypeInspector inner) => (!(namingConvention is NullNamingConvention)) ? new NamingConventionTypeInspector(inner, namingConvention) : inner);
			typeInspectorFactories.Add(typeof(YamlAttributesTypeInspector), (ITypeInspector inner) => new YamlAttributesTypeInspector(inner));
			typeInspectorFactories.Add(typeof(YamlAttributeOverridesInspector), (ITypeInspector inner) => (overrides == null) ? inner : new YamlAttributeOverridesInspector(inner, overrides.Clone()));
			typeInspectorFactories.Add(typeof(ReadableAndWritablePropertiesTypeInspector), (ITypeInspector inner) => new ReadableAndWritablePropertiesTypeInspector(inner));
			nodeDeserializerFactories = new LazyComponentRegistrationList<Nothing, INodeDeserializer>
			{
				{
					typeof(YamlConvertibleNodeDeserializer),
					(Nothing _) => new YamlConvertibleNodeDeserializer(objectFactory.Value)
				},
				{
					typeof(YamlSerializableNodeDeserializer),
					(Nothing _) => new YamlSerializableNodeDeserializer(objectFactory.Value)
				},
				{
					typeof(TypeConverterNodeDeserializer),
					(Nothing _) => new TypeConverterNodeDeserializer(BuildTypeConverters())
				},
				{
					typeof(NullNodeDeserializer),
					(Nothing _) => new NullNodeDeserializer()
				},
				{
					typeof(ScalarNodeDeserializer),
					(Nothing _) => new ScalarNodeDeserializer(attemptUnknownTypeDeserialization, typeConverter)
				},
				{
					typeof(ArrayNodeDeserializer),
					(Nothing _) => new ArrayNodeDeserializer()
				},
				{
					typeof(DictionaryNodeDeserializer),
					(Nothing _) => new DictionaryNodeDeserializer(objectFactory.Value, duplicateKeyChecking)
				},
				{
					typeof(CollectionNodeDeserializer),
					(Nothing _) => new CollectionNodeDeserializer(objectFactory.Value)
				},
				{
					typeof(EnumerableNodeDeserializer),
					(Nothing _) => new EnumerableNodeDeserializer()
				},
				{
					typeof(ObjectNodeDeserializer),
					(Nothing _) => new ObjectNodeDeserializer(objectFactory.Value, BuildTypeInspector(), ignoreUnmatched, duplicateKeyChecking, typeConverter)
				}
			};
			nodeTypeResolverFactories = new LazyComponentRegistrationList<Nothing, INodeTypeResolver>
			{
				{
					typeof(MappingNodeTypeResolver),
					(Nothing _) => new MappingNodeTypeResolver(typeMappings)
				},
				{
					typeof(YamlConvertibleTypeResolver),
					(Nothing _) => new YamlConvertibleTypeResolver()
				},
				{
					typeof(YamlSerializableTypeResolver),
					(Nothing _) => new YamlSerializableTypeResolver()
				},
				{
					typeof(TagNodeTypeResolver),
					(Nothing _) => new TagNodeTypeResolver(tagMappings)
				},
				{
					typeof(PreventUnknownTagsNodeTypeResolver),
					(Nothing _) => new PreventUnknownTagsNodeTypeResolver()
				},
				{
					typeof(DefaultContainersNodeTypeResolver),
					(Nothing _) => new DefaultContainersNodeTypeResolver()
				}
			};
			typeConverter = new ReflectionTypeConverter();
		}

		internal ITypeInspector BuildTypeInspector()
		{
			ITypeInspector typeInspector = new WritablePropertiesTypeInspector(typeResolver, includeNonPublicProperties);
			if (!ignoreFields)
			{
				typeInspector = new CompositeTypeInspector(new ReadableFieldsTypeInspector(typeResolver), typeInspector);
			}
			return typeInspectorFactories.BuildComponentChain(typeInspector);
		}

		public DeserializerBuilder WithAttemptingUnquotedStringTypeDeserialization()
		{
			attemptUnknownTypeDeserialization = true;
			return this;
		}

		public DeserializerBuilder WithObjectFactory(IObjectFactory objectFactory)
		{
			IObjectFactory objectFactory2 = objectFactory;
			if (objectFactory2 == null)
			{
				throw new ArgumentNullException("objectFactory");
			}
			this.objectFactory = new Lazy<IObjectFactory>(() => objectFactory2, isThreadSafe: true);
			return this;
		}

		public DeserializerBuilder WithObjectFactory(Func<Type, object> objectFactory)
		{
			if (objectFactory == null)
			{
				throw new ArgumentNullException("objectFactory");
			}
			return WithObjectFactory(new LambdaObjectFactory(objectFactory));
		}

		public DeserializerBuilder WithNodeDeserializer(INodeDeserializer nodeDeserializer)
		{
			return WithNodeDeserializer(nodeDeserializer, delegate(IRegistrationLocationSelectionSyntax<INodeDeserializer> w)
			{
				w.OnTop();
			});
		}

		public DeserializerBuilder WithNodeDeserializer(INodeDeserializer nodeDeserializer, Action<IRegistrationLocationSelectionSyntax<INodeDeserializer>> where)
		{
			INodeDeserializer nodeDeserializer2 = nodeDeserializer;
			if (nodeDeserializer2 == null)
			{
				throw new ArgumentNullException("nodeDeserializer");
			}
			if (where == null)
			{
				throw new ArgumentNullException("where");
			}
			where(nodeDeserializerFactories.CreateRegistrationLocationSelector(nodeDeserializer2.GetType(), (Nothing _) => nodeDeserializer2));
			return this;
		}

		public DeserializerBuilder WithNodeDeserializer<TNodeDeserializer>(WrapperFactory<INodeDeserializer, TNodeDeserializer> nodeDeserializerFactory, Action<ITrackingRegistrationLocationSelectionSyntax<INodeDeserializer>> where) where TNodeDeserializer : INodeDeserializer
		{
			WrapperFactory<INodeDeserializer, TNodeDeserializer> nodeDeserializerFactory2 = nodeDeserializerFactory;
			if (nodeDeserializerFactory2 == null)
			{
				throw new ArgumentNullException("nodeDeserializerFactory");
			}
			if (where == null)
			{
				throw new ArgumentNullException("where");
			}
			where(nodeDeserializerFactories.CreateTrackingRegistrationLocationSelector(typeof(TNodeDeserializer), (INodeDeserializer wrapped, Nothing _) => nodeDeserializerFactory2(wrapped)));
			return this;
		}

		public DeserializerBuilder WithoutNodeDeserializer<TNodeDeserializer>() where TNodeDeserializer : INodeDeserializer
		{
			return WithoutNodeDeserializer(typeof(TNodeDeserializer));
		}

		public DeserializerBuilder WithoutNodeDeserializer(Type nodeDeserializerType)
		{
			if (nodeDeserializerType == null)
			{
				throw new ArgumentNullException("nodeDeserializerType");
			}
			nodeDeserializerFactories.Remove(nodeDeserializerType);
			return this;
		}

		public DeserializerBuilder WithTypeDiscriminatingNodeDeserializer(Action<ITypeDiscriminatingNodeDeserializerOptions> configureTypeDiscriminatingNodeDeserializerOptions, int maxDepth = -1, int maxLength = -1)
		{
			TypeDiscriminatingNodeDeserializerOptions typeDiscriminatingNodeDeserializerOptions = new TypeDiscriminatingNodeDeserializerOptions();
			configureTypeDiscriminatingNodeDeserializerOptions(typeDiscriminatingNodeDeserializerOptions);
			TypeDiscriminatingNodeDeserializer nodeDeserializer = new TypeDiscriminatingNodeDeserializer(nodeDeserializerFactories.BuildComponentList(), typeDiscriminatingNodeDeserializerOptions.discriminators, maxDepth, maxLength);
			return WithNodeDeserializer(nodeDeserializer, delegate(IRegistrationLocationSelectionSyntax<INodeDeserializer> s)
			{
				s.Before<DictionaryNodeDeserializer>();
			});
		}

		public DeserializerBuilder WithNodeTypeResolver(INodeTypeResolver nodeTypeResolver)
		{
			return WithNodeTypeResolver(nodeTypeResolver, delegate(IRegistrationLocationSelectionSyntax<INodeTypeResolver> w)
			{
				w.OnTop();
			});
		}

		public DeserializerBuilder WithNodeTypeResolver(INodeTypeResolver nodeTypeResolver, Action<IRegistrationLocationSelectionSyntax<INodeTypeResolver>> where)
		{
			INodeTypeResolver nodeTypeResolver2 = nodeTypeResolver;
			if (nodeTypeResolver2 == null)
			{
				throw new ArgumentNullException("nodeTypeResolver");
			}
			if (where == null)
			{
				throw new ArgumentNullException("where");
			}
			where(nodeTypeResolverFactories.CreateRegistrationLocationSelector(nodeTypeResolver2.GetType(), (Nothing _) => nodeTypeResolver2));
			return this;
		}

		public DeserializerBuilder WithNodeTypeResolver<TNodeTypeResolver>(WrapperFactory<INodeTypeResolver, TNodeTypeResolver> nodeTypeResolverFactory, Action<ITrackingRegistrationLocationSelectionSyntax<INodeTypeResolver>> where) where TNodeTypeResolver : INodeTypeResolver
		{
			WrapperFactory<INodeTypeResolver, TNodeTypeResolver> nodeTypeResolverFactory2 = nodeTypeResolverFactory;
			if (nodeTypeResolverFactory2 == null)
			{
				throw new ArgumentNullException("nodeTypeResolverFactory");
			}
			if (where == null)
			{
				throw new ArgumentNullException("where");
			}
			where(nodeTypeResolverFactories.CreateTrackingRegistrationLocationSelector(typeof(TNodeTypeResolver), (INodeTypeResolver wrapped, Nothing _) => nodeTypeResolverFactory2(wrapped)));
			return this;
		}

		public DeserializerBuilder WithoutNodeTypeResolver<TNodeTypeResolver>() where TNodeTypeResolver : INodeTypeResolver
		{
			return WithoutNodeTypeResolver(typeof(TNodeTypeResolver));
		}

		public DeserializerBuilder WithoutNodeTypeResolver(Type nodeTypeResolverType)
		{
			if (nodeTypeResolverType == null)
			{
				throw new ArgumentNullException("nodeTypeResolverType");
			}
			nodeTypeResolverFactories.Remove(nodeTypeResolverType);
			return this;
		}

		public override DeserializerBuilder WithTagMapping(TagName tag, Type type)
		{
			if (tag.IsEmpty)
			{
				throw new ArgumentException("Non-specific tags cannot be maped");
			}
			if (type == null)
			{
				throw new ArgumentNullException("type");
			}
			if (tagMappings.TryGetValue(tag, out Type value))
			{
				throw new ArgumentException($"Type already has a registered type '{value.FullName}' for tag '{tag}'", "tag");
			}
			tagMappings.Add(tag, type);
			return this;
		}

		public DeserializerBuilder WithTypeMapping<TInterface, TConcrete>() where TConcrete : TInterface
		{
			Type typeFromHandle = typeof(TInterface);
			Type typeFromHandle2 = typeof(TConcrete);
			if (!typeFromHandle.IsAssignableFrom(typeFromHandle2))
			{
				throw new InvalidOperationException("The type '" + typeFromHandle2.Name + "' does not implement interface '" + typeFromHandle.Name + "'.");
			}
			if (typeMappings.ContainsKey(typeFromHandle))
			{
				typeMappings[typeFromHandle] = typeFromHandle2;
			}
			else
			{
				typeMappings.Add(typeFromHandle, typeFromHandle2);
			}
			return this;
		}

		public DeserializerBuilder WithoutTagMapping(TagName tag)
		{
			if (tag.IsEmpty)
			{
				throw new ArgumentException("Non-specific tags cannot be maped");
			}
			if (!tagMappings.Remove(tag))
			{
				throw new KeyNotFoundException($"Tag '{tag}' is not registered");
			}
			return this;
		}

		public DeserializerBuilder IgnoreUnmatchedProperties()
		{
			ignoreUnmatched = true;
			return this;
		}

		public DeserializerBuilder WithDuplicateKeyChecking()
		{
			duplicateKeyChecking = true;
			return this;
		}

		public IDeserializer Build()
		{
			return Deserializer.FromValueDeserializer(BuildValueDeserializer());
		}

		public IValueDeserializer BuildValueDeserializer()
		{
			return new AliasValueDeserializer(new NodeValueDeserializer(nodeDeserializerFactories.BuildComponentList(), nodeTypeResolverFactories.BuildComponentList(), typeConverter));
		}
	}
	internal sealed class EmissionPhaseObjectGraphVisitorArgs
	{
		private readonly IEnumerable<IObjectGraphVisitor<Nothing>> preProcessingPhaseVisitors;

		public IObjectGraphVisitor<IEmitter> InnerVisitor { get; private set; }

		public IEventEmitter EventEmitter { get; private set; }

		public ObjectSerializer NestedObjectSerializer { get; private set; }

		public IEnumerable<IYamlTypeConverter> TypeConverters { get; private set; }

		public EmissionPhaseObjectGraphVisitorArgs(IObjectGraphVisitor<IEmitter> innerVisitor, IEventEmitter eventEmitter, IEnumerable<IObjectGraphVisitor<Nothing>> preProcessingPhaseVisitors, IEnumerable<IYamlTypeConverter> typeConverters, ObjectSerializer nestedObjectSerializer)
		{
			InnerVisitor = innerVisitor ?? throw new ArgumentNullException("innerVisitor");
			EventEmitter = eventEmitter ?? throw new ArgumentNullException("eventEmitter");
			this.preProcessingPhaseVisitors = preProcessingPhaseVisitors ?? throw new ArgumentNullException("preProcessingPhaseVisitors");
			TypeConverters = typeConverters ?? throw new ArgumentNullException("typeConverters");
			NestedObjectSerializer = nestedObjectSerializer ?? throw new ArgumentNullException("nestedObjectSerializer");
		}

		public T GetPreProcessingPhaseObjectGraphVisitor<T>() where T : IObjectGraphVisitor<Nothing>
		{
			return preProcessingPhaseVisitors.OfType<T>().Single();
		}
	}
	internal abstract class EventInfo
	{
		public IObjectDescriptor Source { get; }

		protected EventInfo(IObjectDescriptor source)
		{
			Source = source ?? throw new ArgumentNullException("source");
		}
	}
	internal class AliasEventInfo : EventInfo
	{
		public AnchorName Alias { get; }

		public bool NeedsExpansion { get; set; }

		public AliasEventInfo(IObjectDescriptor source, AnchorName alias)
			: base(source)
		{
			if (alias.IsEmpty)
			{
				throw new ArgumentNullException("alias");
			}
			Alias = alias;
		}
	}
	internal class ObjectEventInfo : EventInfo
	{
		public AnchorName Anchor { get; set; }

		public TagName Tag { get; set; }

		protected ObjectEventInfo(IObjectDescriptor source)
			: base(source)
		{
		}
	}
	internal sealed class ScalarEventInfo : ObjectEventInfo
	{
		public string RenderedValue { get; set; }

		public ScalarStyle Style { get; set; }

		public bool IsPlainImplicit { get; set; }

		public bool IsQuotedImplicit { get; set; }

		public ScalarEventInfo(IObjectDescriptor source)
			: base(source)
		{
			Style = source.ScalarStyle;
			RenderedValue = string.Empty;
		}
	}
	internal sealed class MappingStartEventInfo : ObjectEventInfo
	{
		public bool IsImplicit { get; set; }

		public MappingStyle Style { get; set; }

		public MappingStartEventInfo(IObjectDescriptor source)
			: base(source)
		{
		}
	}
	internal sealed class MappingEndEventInfo : EventInfo
	{
		public MappingEndEventInfo(IObjectDescriptor source)
			: base(source)
		{
		}
	}
	internal sealed class SequenceStartEventInfo : ObjectEventInfo
	{
		public bool IsImplicit { get; set; }

		public SequenceStyle Style { get; set; }

		public SequenceStartEventInfo(IObjectDescriptor source)
			: base(source)
		{
		}
	}
	internal sealed class SequenceEndEventInfo : EventInfo
	{
		public SequenceEndEventInfo(IObjectDescriptor source)
			: base(source)
		{
		}
	}
	internal interface IAliasProvider
	{
		AnchorName GetAlias(object target);
	}
	internal interface IDeserializer
	{
		T Deserialize<T>(string input);

		T Deserialize<T>(TextReader input);

		object? Deserialize(TextReader input);

		object? Deserialize(string input, Type type);

		object? Deserialize(TextReader input, Type type);

		T Deserialize<T>(IParser parser);

		object? Deserialize(IParser parser);

		object? Deserialize(IParser parser, Type type);
	}
	internal interface IEventEmitter
	{
		void Emit(AliasEventInfo eventInfo, IEmitter emitter);

		void Emit(ScalarEventInfo eventInfo, IEmitter emitter);

		void Emit(MappingStartEventInfo eventInfo, IEmitter emitter);

		void Emit(MappingEndEventInfo eventInfo, IEmitter emitter);

		void Emit(SequenceStartEventInfo eventInfo, IEmitter emitter);

		void Emit(SequenceEndEventInfo eventInfo, IEmitter emitter);
	}
	internal interface INamingConvention
	{
		string Apply(string value);
	}
	internal interface INodeDeserializer
	{
		bool Deserialize(IParser reader, Type expectedType, Func<IParser, Type, object?> nestedObjectDeserializer, out object? value);
	}
	internal interface INodeTypeResolver
	{
		bool Resolve(NodeEvent? nodeEvent, ref Type currentType);
	}
	internal interface IObjectAccessor
	{
		void Set(string name, object target, object value);

		object? Read(string name, object target);
	}
	internal interface IObjectDescriptor
	{
		object? Value { get; }

		Type Type { get; }

		Type StaticType { get; }

		ScalarStyle ScalarStyle { get; }
	}
	internal static class ObjectDescriptorExtensions
	{
		public static object NonNullValue(this IObjectDescriptor objectDescriptor)
		{
			return objectDescriptor.Value ?? throw new InvalidOperationException("Attempted to use a IObjectDescriptor of type '" + objectDescriptor.Type.FullName + "' whose Value is null at a point whete it is invalid to do so. This may indicate a bug in YamlDotNet.");
		}
	}
	internal interface IObjectFactory
	{
		object Create(Type type);

		object? CreatePrimitive(Type type);

		bool GetDictionary(IObjectDescriptor descriptor, out IDictionary? dictionary, out Type[]? genericArguments);

		Type GetValueType(Type type);
	}
	internal interface IObjectGraphTraversalStrategy
	{
		void Traverse<TContext>(IObjectDescriptor graph, IObjectGraphVisitor<TContext> visitor, TContext context);
	}
	internal interface IObjectGraphVisitor<TContext>
	{
		bool Enter(IObjectDescriptor value, TContext context);

		bool EnterMapping(IObjectDescriptor key, IObjectDescriptor value, TContext context);

		bool EnterMapping(IPropertyDescriptor key, IObjectDescriptor value, TContext context);

		void VisitScalar(IObjectDescriptor scalar, TContext context);

		void VisitMappingStart(IObjectDescriptor mapping, Type keyType, Type valueType, TContext context);

		void VisitMappingEnd(IObjectDescriptor mapping, TContext context);

		void VisitSequenceStart(IObjectDescriptor sequence, Type elementType, TContext context);

		void VisitSequenceEnd(IObjectDescriptor sequence, TContext context);
	}
	internal interface IPropertyDescriptor
	{
		string Name { get; }

		bool CanWrite { get; }

		Type Type { get; }

		Type? TypeOverride { get; set; }

		int Order { get; set; }

		ScalarStyle ScalarStyle { get; set; }

		T? GetCustomAttribute<T>() where T : Attribute;

		IObjectDescriptor Read(object target);

		void Write(object target, object? value);
	}
	internal interface IRegistrationLocationSelectionSyntax<TBaseRegistrationType>
	{
		void InsteadOf<TRegistrationType>() where TRegistrationType : TBaseRegistrationType;

		void Before<TRegistrationType>() where TRegistrationType : TBaseRegistrationType;

		void After<TRegistrationType>() where TRegistrationType : TBaseRegistrationType;

		void OnTop();

		void OnBottom();
	}
	internal interface ITrackingRegistrationLocationSelectionSyntax<TBaseRegistrationType>
	{
		void InsteadOf<TRegistrationType>() where TRegistrationType : TBaseRegistrationType;
	}
	internal interface ISerializer
	{
		void Serialize(TextWriter writer, object? graph);

		string Serialize(object? graph);

		void Serialize(TextWriter writer, object? graph, Type type);

		void Serialize(IEmitter emitter, object? graph);

		void Serialize(IEmitter emitter, object? graph, Type type);
	}
	internal interface ITypeInspector
	{
		IEnumerable<IPropertyDescriptor> GetProperties(Type type, object? container);

		IPropertyDescriptor GetProperty(Type type, object? container, string name, [MaybeNullWhen(true)] bool ignoreUnmatched);
	}
	internal interface ITypeResolver
	{
		Type Resolve(Type staticType, object? actualValue);
	}
	internal interface IValueDeserializer
	{
		object? DeserializeValue(IParser parser, Type expectedType, SerializerState state, IValueDeserializer nestedObjectDeserializer);
	}
	internal interface IValuePromise
	{
		event Action<object?> ValueAvailable;
	}
	internal interface IValueSerializer
	{
		void SerializeValue(IEmitter emitter, object? value, Type? type);
	}
	internal interface IYamlConvertible
	{
		void Read(IParser parser, Type expectedType, ObjectDeserializer nestedObjectDeserializer);

		void Write(IEmitter emitter, ObjectSerializer nestedObjectSerializer);
	}
	internal delegate object? ObjectDeserializer(Type type);
	internal delegate void ObjectSerializer(object? value, Type? type = null);
	[Obsolete("Please use IYamlConvertible instead")]
	internal interface IYamlSerializable
	{
		void ReadYaml(IParser parser);

		void WriteYaml(IEmitter emitter);
	}
	internal interface IYamlTypeConverter
	{
		bool Accepts(Type type);

		object? ReadYaml(IParser parser, Type type);

		void WriteYaml(IEmitter emitter, object? value, Type type);
	}
	internal sealed class LazyComponentRegistrationList<TArgument, TComponent> : IEnumerable<Func<TArgument, TComponent>>, IEnumerable
	{
		public sealed class LazyComponentRegistration
		{
			public readonly Type ComponentType;

			public readonly Func<TArgument, TComponent> Factory;

			public LazyComponentRegistration(Type componentType, Func<TArgument, TComponent> factory)
			{
				ComponentType = componentType;
				Factory = factory;
			}
		}

		public sealed class TrackingLazyComponentRegistration
		{
			public readonly Type ComponentType;

			public readonly Func<TComponent, TArgument, TComponent> Factory;

			public TrackingLazyComponentRegistration(Type componentType, Func<TComponent, TArgument, TComponent> factory)
			{
				ComponentType = componentType;
				Factory = factory;
			}
		}

		private class RegistrationLocationSelector : IRegistrationLocationSelectionSyntax<TComponent>
		{
			private readonly LazyComponentRegistrationList<TArgument, TComponent> registrations;

			private readonly LazyComponentRegistration newRegistration;

			public RegistrationLocationSelector(LazyComponentRegistrationList<TArgument, TComponent> registrations, LazyComponentRegistration newRegistration)
			{
				this.registrations = registrations;
				this.newRegistration = newRegistration;
			}

			void IRegistrationLocationSelectionSyntax<TComponent>.InsteadOf<TRegistrationType>()
			{
				if (newRegistration.ComponentType != typeof(TRegistrationType))
				{
					registrations.EnsureNoDuplicateRegistrationType(newRegistration.ComponentType);
				}
				int index = registrations.EnsureRegistrationExists<TRegistrationType>();
				registrations.entries[index] = newRegistration;
			}

			void IRegistrationLocationSelectionSyntax<TComponent>.After<TRegistrationType>()
			{
				registrations.EnsureNoDuplicateRegistrationType(newRegistration.ComponentType);
				int num = registrations.EnsureRegistrationExists<TRegistrationType>();
				registrations.entries.Insert(num + 1, newRegistration);
			}

			void IRegistrationLocationSelectionSyntax<TComponent>.Before<TRegistrationType>()
			{
				registrations.EnsureNoDuplicateRegistrationType(newRegistration.ComponentType);
				int index = registrations.EnsureRegistrationExists<TRegistrationType>();
				registrations.entries.Insert(index, newRegistration);
			}

			void IRegistrationLocationSelectionSyntax<TComponent>.OnBottom()
			{
				registrations.EnsureNoDuplicateRegistrationType(newRegistration.ComponentType);
				registrations.entries.Add(newRegistration);
			}

			void IRegistrationLocationSelectionSyntax<TComponent>.OnTop()
			{
				registrations.EnsureNoDuplicateRegistrationType(newRegistration.ComponentType);
				registrations.entries.Insert(0, newRegistration);
			}
		}

		private class TrackingRegistrationLocationSelector : ITrackingRegistrationLocationSelectionSyntax<TComponent>
		{
			private readonly LazyComponentRegistrationList<TArgument, TComponent> registrations;

			private readonly TrackingLazyComponentRegistration newRegistration;

			public TrackingRegistrationLocationSelector(LazyComponentRegistrationList<TArgument, TComponent> registrations, TrackingLazyComponentRegistration newRegistration)
			{
				this.registrations = registrations;
				this.newRegistration = newRegistration;
			}

			void ITrackingRegistrationLocationSelectionSyntax<TComponent>.InsteadOf<TRegistrationType>()
			{
				if (newRegistration.ComponentType != typeof(TRegistrationType))
				{
					registrations.EnsureNoDuplicateRegistrationType(newRegistration.ComponentType);
				}
				int index = registrations.EnsureRegistrationExists<TRegistrationType>();
				Func<TArgument, TComponent> innerComponentFactory = registrations.entries[index].Factory;
				registrations.entries[index] = new LazyComponentRegistration(newRegistration.ComponentType, (TArgument arg) => newRegistration.Factory(innerComponentFactory(arg), arg));
			}
		}

		private readonly List<LazyComponentRegistration> entries = new List<LazyComponentRegistration>();

		public int Count => entries.Count;

		public IEnumerable<Func<TArgument, TComponent>> InReverseOrder
		{
			get
			{
				int i = entries.Count - 1;
				while (i >= 0)
				{
					yield return entries[i].Factory;
					int num = i - 1;
					i = num;
				}
			}
		}

		public LazyComponentRegistrationList<TArgument, TComponent> Clone()
		{
			LazyComponentRegistrationList<TArgument, TComponent> lazyComponentRegistrationList = new LazyComponentRegistrationList<TArgument, TComponent>();
			foreach (LazyComponentRegistration entry in entries)
			{
				lazyComponentRegistrationList.entries.Add(entry);
			}
			return lazyComponentRegistrationList;
		}

		public void Clear()
		{
			entries.Clear();
		}

		public void Add(Type componentType, Func<TArgument, TComponent> factory)
		{
			entries.Add(new LazyComponentRegistration(componentType, factory));
		}

		public void Remove(Type componentType)
		{
			for (int i = 0; i < entries.Count; i++)
			{
				if (entries[i].ComponentType == componentType)
				{
					entries.RemoveAt(i);
					return;
				}
			}
			throw new KeyNotFoundException("A component registration of type '" + componentType.FullName + "' was not found.");
		}

		public IRegistrationLocationSelectionSyntax<TComponent> CreateRegistrationLocationSelector(Type componentType, Func<TArgument, TComponent> factory)
		{
			return new RegistrationLocationSelector(this, new LazyComponentRegistration(componentType, factory));
		}

		public ITrackingRegistrationLocationSelectionSyntax<TComponent> CreateTrackingRegistrationLocationSelector(Type componentType, Func<TComponent, TArgument, TComponent> factory)
		{
			return new TrackingRegistrationLocationSelector(this, new TrackingLazyComponentRegistration(componentType, factory));
		}

		public IEnumerator<Func<TArgument, TComponent>> GetEnumerator()
		{
			return entries.Select((LazyComponentRegistration e) => e.Factory).GetEnumerator();
		}

		IEnumerator IEnumerable.GetEnumerator()
		{
			return GetEnumerator();
		}

		private int IndexOfRegistration(Type registrationType)
		{
			for (int i = 0; i < entries.Count; i++)
			{
				if (registrationType == entries[i].ComponentType)
				{
					return i;
				}
			}
			return -1;
		}

		private void EnsureNoDuplicateRegistrationType(Type componentType)
		{
			if (IndexOfRegistration(componentType) != -1)
			{
				throw new InvalidOperationException("A component of type '" + componentType.FullName + "' has already been registered.");
			}
		}

		private int EnsureRegistrationExists<TRegistrationType>()
		{
			int num = IndexOfRegistration(typeof(TRegistrationType));
			if (num == -1)
			{
				throw new InvalidOperationException("A component of type '" + typeof(TRegistrationType).FullName + "' has not been registered.");
			}
			return num;
		}
	}
	internal static class LazyComponentRegistrationListExtensions
	{
		public static TComponent BuildComponentChain<TComponent>(this LazyComponentRegistrationList<TComponent, TComponent> registrations, TComponent innerComponent)
		{
			return registrations.InReverseOrder.Aggregate(innerComponent, (TComponent inner, Func<TComponent, TComponent> factory) => factory(inner));
		}

		public static TComponent BuildComponentChain<TArgument, TComponent>(this LazyComponentRegistrationList<TArgument, TComponent> registrations, TComponent innerComponent, Func<TComponent, TArgument> argumentBuilder)
		{
			Func<TComponent, TArgument> argumentBuilder2 = argumentBuilder;
			return registrations.InReverseOrder.Aggregate(innerComponent, (TComponent inner, Func<TArgument, TComponent> factory) => factory(argumentBuilder2(inner)));
		}

		public static List<TComponent> BuildComponentList<TComponent>(this LazyComponentRegistrationList<Nothing, TComponent> registrations)
		{
			return registrations.Select((Func<Nothing, TComponent> factory) => factory(default(Nothing))).ToList();
		}

		public static List<TComponent> BuildComponentList<TArgument, TComponent>(this LazyComponentRegistrationList<TArgument, TComponent> registrations, TArgument argument)
		{
			TArgument argument2 = argument;
			return registrations.Select((Func<TArgument, TComponent> factory) => factory(argument2)).ToList();
		}
	}
	[StructLayout(LayoutKind.Sequential, Size = 1)]
	internal struct Nothing
	{
	}
	internal sealed class ObjectDescriptor : IObjectDescriptor
	{
		public object? Value { get; private set; }

		public Type Type { get; private set; }

		public Type StaticType { get; private set; }

		public ScalarStyle ScalarStyle { get; private set; }

		public ObjectDescriptor(object? value, Type type, Type staticType)
			: this(value, type, staticType, ScalarStyle.Any)
		{
		}

		public ObjectDescriptor(object? value, Type type, Type staticType, ScalarStyle scalarStyle)
		{
			Value = value;
			Type = type ?? throw new ArgumentNullException("type");
			StaticType = staticType ?? throw new ArgumentNullException("staticType");
			ScalarStyle = scalarStyle;
		}
	}
	internal delegate IObjectGraphTraversalStrategy ObjectGraphTraversalStrategyFactory(ITypeInspector typeInspector, ITypeResolver typeResolver, IEnumerable<IYamlTypeConverter> typeConverters, int maximumRecursion);
	internal sealed class PropertyDescriptor : IPropertyDescriptor
	{
		private readonly IPropertyDescriptor baseDescriptor;

		public string Name { get; set; }

		public Type Type => baseDescriptor.Type;

		public Type? TypeOverride
		{
			get
			{
				return baseDescriptor.TypeOverride;
			}
			set
			{
				baseDescriptor.TypeOverride = value;
			}
		}

		public int Order { get; set; }

		public ScalarStyle ScalarStyle
		{
			get
			{
				return baseDescriptor.ScalarStyle;
			}
			set
			{
				baseDescriptor.ScalarStyle = value;
			}
		}

		public bool CanWrite => baseDescriptor.CanWrite;

		public PropertyDescriptor(IPropertyDescriptor baseDescriptor)
		{
			this.baseDescriptor = baseDescriptor;
			Name = baseDescriptor.Name;
		}

		public void Write(object target, object? value)
		{
			baseDescriptor.Write(target, value);
		}

		public T? GetCustomAttribute<T>() where T : Attribute
		{
			return baseDescriptor.GetCustomAttribute<T>();
		}

		public IObjectDescriptor Read(object target)
		{
			return baseDescriptor.Read(target);
		}
	}
	internal sealed class Serializer : ISerializer
	{
		private readonly IValueSerializer valueSerializer;

		private readonly EmitterSettings emitterSettings;

		public Serializer()
			: this(new SerializerBuilder().BuildValueSerializer(), EmitterSettings.Default)
		{
		}

		private Serializer(IValueSerializer valueSerializer, EmitterSettings emitterSettings)
		{
			this.valueSerializer = valueSerializer ?? throw new ArgumentNullException("valueSerializer");
			this.emitterSettings = emitterSettings ?? throw new ArgumentNullException("emitterSettings");
		}

		public static Serializer FromValueSerializer(IValueSerializer valueSerializer, EmitterSettings emitterSettings)
		{
			return new Serializer(valueSerializer, emitterSettings);
		}

		public void Serialize(TextWriter writer, object? graph)
		{
			Serialize(new Emitter(writer, emitterSettings), graph);
		}

		public string Serialize(object? graph)
		{
			using StringWriter stringWriter = new StringWriter();
			Serialize(stringWriter, graph);
			return stringWriter.ToString();
		}

		public void Serialize(TextWriter writer, object? graph, Type type)
		{
			Serialize(new Emitter(writer, emitterSettings), graph, type);
		}

		public void Serialize(IEmitter emitter, object? graph)
		{
			if (emitter == null)
			{
				throw new ArgumentNullException("emitter");
			}
			EmitDocument(emitter, graph, null);
		}

		public void Serialize(IEmitter emitter, object? graph, Type type)
		{
			if (emitter == null)
			{
				throw new ArgumentNullException("emitter");
			}
			if (type == null)
			{
				throw new ArgumentNullException("type");
			}
			EmitDocument(emitter, graph, type);
		}

		private void EmitDocument(IEmitter emitter, object? graph, Type? type)
		{
			emitter.Emit(new YamlDotNet.Core.Events.StreamStart());
			emitter.Emit(new YamlDotNet.Core.Events.DocumentStart());
			valueSerializer.SerializeValue(emitter, graph, type);
			emitter.Emit(new YamlDotNet.Core.Events.DocumentEnd(isImplicit: true));
			emitter.Emit(new YamlDotNet.Core.Events.StreamEnd());
		}
	}
	internal sealed class SerializerBuilder : BuilderSkeleton<SerializerBuilder>
	{
		private class ValueSerializer : IValueSerializer
		{
			private readonly IObjectGraphTraversalStrategy traversalStrategy;

			private readonly IEventEmitter eventEmitter;

			private readonly IEnumerable<IYamlTypeConverter> typeConverters;

			private readonly LazyComponentRegistrationList<IEnumerable<IYamlTypeConverter>, IObjectGraphVisitor<Nothing>> preProcessingPhaseObjectGraphVisitorFactories;

			private readonly LazyComponentRegistrationList<EmissionPhaseObjectGraphVisitorArgs, IObjectGraphVisitor<IEmitter>> emissionPhaseObjectGraphVisitorFactories;

			public ValueSerializer(IObjectGraphTraversalStrategy traversalStrategy, IEventEmitter eventEmitter, IEnumerable<IYamlTypeConverter> typeConverters, LazyComponentRegistrationList<IEnumerable<IYamlTypeConverter>, IObjectGraphVisitor<Nothing>> preProcessingPhaseObjectGraphVisitorFactories, LazyComponentRegistrationList<EmissionPhaseObjectGraphVisitorArgs, IObjectGraphVisitor<IEmitter>> emissionPhaseObjectGraphVisitorFactories)
			{
				this.traversalStrategy = traversalStrategy;
				this.eventEmitter = eventEmitter;
				this.typeConverters = typeConverters;
				this.preProcessingPhaseObjectGraphVisitorFactories = preProcessingPhaseObjectGraphVisitorFactories;
				this.emissionPhaseObjectGraphVisitorFactories = emissionPhaseObjectGraphVisitorFactories;
			}

			public void SerializeValue(IEmitter emitter, object? value, Type? type)
			{
				IEmitter emitter2 = emitter;
				Type type2 = type ?? ((value != null) ? value.GetType() : typeof(object));
				Type staticType = type ?? typeof(object);
				ObjectDescriptor graph = new ObjectDescriptor(value, type2, staticType);
				List<IObjectGraphVisitor<Nothing>> preProcessingPhaseObjectGraphVisitors = preProcessingPhaseObjectGraphVisitorFactories.BuildComponentList(typeConverters);
				foreach (IObjectGraphVisitor<Nothing> item in preProcessingPhaseObjectGraphVisitors)
				{
					traversalStrategy.Traverse(graph, item, default(Nothing));
				}
				IObjectGraphVisitor<IEmitter> visitor = emissionPhaseObjectGraphVisitorFactories.BuildComponentChain<EmissionPhaseObjectGraphVisitorArgs, IObjectGraphVisitor<IEmitter>>(new EmittingObjectGraphVisitor(eventEmitter), (IObjectGraphVisitor<IEmitter> inner) => new EmissionPhaseObjectGraphVisitorArgs(inner, eventEmitter, preProcessingPhaseObjectGraphVisitors, typeConverters, NestedObjectSerializer));
				traversalStrategy.Traverse(graph, visitor, emitter2);
				void NestedObjectSerializer(object? v, Type? t)
				{
					SerializeValue(emitter2, v, t);
				}
			}
		}

		private ObjectGraphTraversalStrategyFactory objectGraphTraversalStrategyFactory;

		private readonly LazyComponentRegistra