Decompiled source of DarkWoodFurnitures v1.0.0

DarkWoodFurnitures.dll

Decompiled a month 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.IO.Compression;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Reflection.Emit;
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 BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using DarkWoodFurnitures.Functions;
using HarmonyLib;
using JetBrains.Annotations;
using LocalizationManager;
using Microsoft.CodeAnalysis;
using PieceManager;
using ServerSync;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using YamlDotNet.Core;
using YamlDotNet.Core.Events;
using YamlDotNet.Core.Tokens;
using YamlDotNet.Helpers;
using YamlDotNet.Serialization;
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: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("DarkWoodFurnitures")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DarkWoodFurnitures")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("34E75B11-4BCF-4677-8B29-84C64EA45193")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace DarkWoodFurnitures
{
	[BepInPlugin("blacks7ar.DarkWoodFurnitures", "DarkWoodFurnitures", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private enum Toggle
		{
			On = 1,
			Off = 0
		}

		private const string modGUID = "blacks7ar.DarkWoodFurnitures";

		public const string modName = "DarkWoodFurnitures";

		public const string modAuthor = "blacks7ar";

		public const string modVersion = "1.0.0";

		public const string modLink = "";

		public static readonly Harmony _harmony = new Harmony("blacks7ar.DarkWoodFurnitures");

		private static readonly ConfigSync _configSync = new ConfigSync("blacks7ar.DarkWoodFurnitures")
		{
			DisplayName = "DarkWoodFurnitures",
			CurrentVersion = "1.0.0",
			MinimumRequiredVersion = "1.0.0"
		};

		private static ConfigEntry<Toggle> _serverConfigLocked;

		private ConfigEntry<T> config<T>(string group, string name, T value, ConfigDescription description, bool synchronizedConfig = true)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			ConfigDescription val = new ConfigDescription(description.Description + (synchronizedConfig ? " [Synced with Server]" : " [Not Synced with Server]"), description.AcceptableValues, description.Tags);
			ConfigEntry<T> val2 = ((BaseUnityPlugin)this).Config.Bind<T>(group, name, value, val);
			_configSync.AddConfigEntry<T>(val2).SynchronizedConfig = synchronizedConfig;
			return val2;
		}

		public void Awake()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			Localizer.Load();
			((BaseUnityPlugin)this).Config.SaveOnConfigSet = false;
			_serverConfigLocked = config("1- ServerSync", "Lock Configuration", Toggle.On, new ConfigDescription("If On, the configuration is locked and can be changed by server admins only.", (AcceptableValueBase)null, Array.Empty<object>()));
			_configSync.AddLockingConfigEntry<Toggle>(_serverConfigLocked);
			PrefabsSetup.Init();
			((BaseUnityPlugin)this).Config.SaveOnConfigSet = true;
			((BaseUnityPlugin)this).Config.Save();
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			_harmony.PatchAll(executingAssembly);
		}

		private void OnDestroy()
		{
			((BaseUnityPlugin)this).Config.Save();
		}
	}
}
namespace DarkWoodFurnitures.Functions
{
	public static class PrefabsSetup
	{
		private static AssetBundle _darkwoodBundle;

		private const string _category = "DarkWood Furnitues";

		private const string _fineWood = "FineWood";

		private const string _tar = "Tar";

		private const string _wolfPelt = "WolfPelt";

		private const string _glass = "Crystal";

		public static void Init()
		{
			_darkwoodBundle = PiecePrefabManager.RegisterAssetBundle("darkwoodbundle");
			BuildPiece buildPiece = new BuildPiece(_darkwoodBundle, "BDWF_Bed1");
			buildPiece.Crafting.Set(CraftingTable.Workbench);
			buildPiece.Category.Set("DarkWood Furnitues");
			buildPiece.RequiredItems.Add("FineWood", 6, recover: true);
			buildPiece.RequiredItems.Add("Tar", 2, recover: true);
			buildPiece.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			buildPiece.Snapshot();
			ShaderReplacer.Replace(buildPiece.Prefab);
			BuildPiece buildPiece2 = new BuildPiece(_darkwoodBundle, "BDWF_Bed2");
			buildPiece2.Crafting.Set(CraftingTable.Workbench);
			buildPiece2.Category.Set("DarkWood Furnitues");
			buildPiece2.RequiredItems.Add("FineWood", 10, recover: true);
			buildPiece2.RequiredItems.Add("Tar", 2, recover: true);
			buildPiece2.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			buildPiece2.Snapshot();
			ShaderReplacer.Replace(buildPiece2.Prefab);
			BuildPiece buildPiece3 = new BuildPiece(_darkwoodBundle, "BDWF_Bed3");
			buildPiece3.Crafting.Set(CraftingTable.Workbench);
			buildPiece3.Category.Set("DarkWood Furnitues");
			buildPiece3.RequiredItems.Add("FineWood", 6, recover: true);
			buildPiece3.RequiredItems.Add("Tar", 2, recover: true);
			buildPiece3.RequiredItems.Add("WolfPelt", 4, recover: true);
			buildPiece3.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			buildPiece3.Snapshot();
			ShaderReplacer.Replace(buildPiece3.Prefab);
			BuildPiece buildPiece4 = new BuildPiece(_darkwoodBundle, "BDWF_Bed4");
			buildPiece4.Crafting.Set(CraftingTable.Workbench);
			buildPiece4.Category.Set("DarkWood Furnitues");
			buildPiece4.RequiredItems.Add("FineWood", 6, recover: true);
			buildPiece4.RequiredItems.Add("Tar", 2, recover: true);
			buildPiece4.RequiredItems.Add("WolfPelt", 5, recover: true);
			buildPiece4.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			buildPiece4.Snapshot();
			ShaderReplacer.Replace(buildPiece4.Prefab);
			BuildPiece buildPiece5 = new BuildPiece(_darkwoodBundle, "BDWF_Bench1");
			buildPiece5.Crafting.Set(CraftingTable.Workbench);
			buildPiece5.Category.Set("DarkWood Furnitues");
			buildPiece5.RequiredItems.Add("FineWood", 4, recover: true);
			buildPiece5.RequiredItems.Add("Tar", 2, recover: true);
			buildPiece5.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			buildPiece5.Snapshot();
			ShaderReplacer.Replace(buildPiece5.Prefab);
			BuildPiece buildPiece6 = new BuildPiece(_darkwoodBundle, "BDWF_Bench2");
			buildPiece6.Crafting.Set(CraftingTable.Workbench);
			buildPiece6.Category.Set("DarkWood Furnitues");
			buildPiece6.RequiredItems.Add("FineWood", 4, recover: true);
			buildPiece6.RequiredItems.Add("Tar", 2, recover: true);
			buildPiece6.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			buildPiece6.Snapshot();
			ShaderReplacer.Replace(buildPiece6.Prefab);
			BuildPiece buildPiece7 = new BuildPiece(_darkwoodBundle, "BDWF_Bench3");
			buildPiece7.Crafting.Set(CraftingTable.Workbench);
			buildPiece7.Category.Set("DarkWood Furnitues");
			buildPiece7.RequiredItems.Add("FineWood", 3, recover: true);
			buildPiece7.RequiredItems.Add("Tar", 1, recover: true);
			buildPiece7.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			buildPiece7.Snapshot();
			ShaderReplacer.Replace(buildPiece7.Prefab);
			BuildPiece buildPiece8 = new BuildPiece(_darkwoodBundle, "BDWF_Bench5");
			buildPiece8.Crafting.Set(CraftingTable.Workbench);
			buildPiece8.Category.Set("DarkWood Furnitues");
			buildPiece8.RequiredItems.Add("FineWood", 3, recover: true);
			buildPiece8.RequiredItems.Add("Tar", 1, recover: true);
			buildPiece8.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			buildPiece8.Snapshot();
			ShaderReplacer.Replace(buildPiece8.Prefab);
			BuildPiece buildPiece9 = new BuildPiece(_darkwoodBundle, "BDWF_Bench6");
			buildPiece9.Crafting.Set(CraftingTable.Workbench);
			buildPiece9.Category.Set("DarkWood Furnitues");
			buildPiece9.RequiredItems.Add("FineWood", 3, recover: true);
			buildPiece9.RequiredItems.Add("Tar", 1, recover: true);
			buildPiece9.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			buildPiece9.Snapshot();
			ShaderReplacer.Replace(buildPiece9.Prefab);
			BuildPiece buildPiece10 = new BuildPiece(_darkwoodBundle, "BDWF_Bench7");
			buildPiece10.Crafting.Set(CraftingTable.Workbench);
			buildPiece10.Category.Set("DarkWood Furnitues");
			buildPiece10.RequiredItems.Add("FineWood", 2, recover: true);
			buildPiece10.RequiredItems.Add("Tar", 1, recover: true);
			buildPiece10.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			buildPiece10.Snapshot();
			ShaderReplacer.Replace(buildPiece10.Prefab);
			BuildPiece buildPiece11 = new BuildPiece(_darkwoodBundle, "BDWF_Bench8");
			buildPiece11.Crafting.Set(CraftingTable.Workbench);
			buildPiece11.Category.Set("DarkWood Furnitues");
			buildPiece11.RequiredItems.Add("FineWood", 3, recover: true);
			buildPiece11.RequiredItems.Add("Tar", 2, recover: true);
			buildPiece11.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			buildPiece11.Snapshot();
			ShaderReplacer.Replace(buildPiece11.Prefab);
			BuildPiece buildPiece12 = new BuildPiece(_darkwoodBundle, "BDWF_Bench9");
			buildPiece12.Crafting.Set(CraftingTable.Workbench);
			buildPiece12.Category.Set("DarkWood Furnitues");
			buildPiece12.RequiredItems.Add("FineWood", 6, recover: true);
			buildPiece12.RequiredItems.Add("Tar", 2, recover: true);
			buildPiece12.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			buildPiece12.Snapshot();
			ShaderReplacer.Replace(buildPiece12.Prefab);
			BuildPiece buildPiece13 = new BuildPiece(_darkwoodBundle, "BDWF_Cabinet1");
			buildPiece13.Crafting.Set(CraftingTable.Workbench);
			buildPiece13.Category.Set("DarkWood Furnitues");
			buildPiece13.RequiredItems.Add("FineWood", 10, recover: true);
			buildPiece13.RequiredItems.Add("Tar", 4, recover: true);
			buildPiece13.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			buildPiece13.Snapshot();
			ShaderReplacer.Replace(buildPiece13.Prefab);
			BuildPiece buildPiece14 = new BuildPiece(_darkwoodBundle, "BDWF_Cabinet2");
			buildPiece14.Crafting.Set(CraftingTable.Workbench);
			buildPiece14.Category.Set("DarkWood Furnitues");
			buildPiece14.RequiredItems.Add("FineWood", 10, recover: true);
			buildPiece14.RequiredItems.Add("Tar", 4, recover: true);
			buildPiece14.RequiredItems.Add("Crystal", 4, recover: true);
			buildPiece14.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			buildPiece14.Snapshot();
			ShaderReplacer.Replace(buildPiece14.Prefab);
			BuildPiece buildPiece15 = new BuildPiece(_darkwoodBundle, "BDWF_Cabinet3");
			buildPiece15.Crafting.Set(CraftingTable.Workbench);
			buildPiece15.Category.Set("DarkWood Furnitues");
			buildPiece15.RequiredItems.Add("FineWood", 6, recover: true);
			buildPiece15.RequiredItems.Add("Tar", 2, recover: true);
			buildPiece15.RequiredItems.Add("Crystal", 2, recover: true);
			buildPiece15.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			buildPiece15.Snapshot();
			ShaderReplacer.Replace(buildPiece15.Prefab);
			BuildPiece buildPiece16 = new BuildPiece(_darkwoodBundle, "BDWF_Chair1");
			buildPiece16.Crafting.Set(CraftingTable.Workbench);
			buildPiece16.Category.Set("DarkWood Furnitues");
			buildPiece16.RequiredItems.Add("FineWood", 6, recover: true);
			buildPiece16.RequiredItems.Add("Tar", 3, recover: true);
			buildPiece16.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			buildPiece16.Snapshot();
			ShaderReplacer.Replace(buildPiece16.Prefab);
			BuildPiece buildPiece17 = new BuildPiece(_darkwoodBundle, "BDWF_Chair2");
			buildPiece17.Crafting.Set(CraftingTable.Workbench);
			buildPiece17.Category.Set("DarkWood Furnitues");
			buildPiece17.RequiredItems.Add("FineWood", 6, recover: true);
			buildPiece17.RequiredItems.Add("Tar", 3, recover: true);
			buildPiece17.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			buildPiece17.Snapshot();
			ShaderReplacer.Replace(buildPiece17.Prefab);
			BuildPiece buildPiece18 = new BuildPiece(_darkwoodBundle, "BDWF_Chair3");
			buildPiece18.Crafting.Set(CraftingTable.Workbench);
			buildPiece18.Category.Set("DarkWood Furnitues");
			buildPiece18.RequiredItems.Add("FineWood", 6, recover: true);
			buildPiece18.RequiredItems.Add("Tar", 3, recover: true);
			buildPiece18.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			buildPiece18.Snapshot();
			ShaderReplacer.Replace(buildPiece18.Prefab);
			BuildPiece buildPiece19 = new BuildPiece(_darkwoodBundle, "BDWF_Chair4");
			buildPiece19.Crafting.Set(CraftingTable.Workbench);
			buildPiece19.Category.Set("DarkWood Furnitues");
			buildPiece19.RequiredItems.Add("FineWood", 6, recover: true);
			buildPiece19.RequiredItems.Add("Tar", 3, recover: true);
			buildPiece19.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			buildPiece19.Snapshot();
			ShaderReplacer.Replace(buildPiece19.Prefab);
			BuildPiece buildPiece20 = new BuildPiece(_darkwoodBundle, "BDWF_Chair5");
			buildPiece20.Crafting.Set(CraftingTable.Workbench);
			buildPiece20.Category.Set("DarkWood Furnitues");
			buildPiece20.RequiredItems.Add("FineWood", 6, recover: true);
			buildPiece20.RequiredItems.Add("Tar", 3, recover: true);
			buildPiece20.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			buildPiece20.Snapshot();
			ShaderReplacer.Replace(buildPiece20.Prefab);
			BuildPiece buildPiece21 = new BuildPiece(_darkwoodBundle, "BDWF_Chair6");
			buildPiece21.Crafting.Set(CraftingTable.Workbench);
			buildPiece21.Category.Set("DarkWood Furnitues");
			buildPiece21.RequiredItems.Add("FineWood", 6, recover: true);
			buildPiece21.RequiredItems.Add("Tar", 3, recover: true);
			buildPiece21.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			buildPiece21.Snapshot();
			ShaderReplacer.Replace(buildPiece21.Prefab);
			BuildPiece buildPiece22 = new BuildPiece(_darkwoodBundle, "BDWF_Chair7");
			buildPiece22.Crafting.Set(CraftingTable.Workbench);
			buildPiece22.Category.Set("DarkWood Furnitues");
			buildPiece22.RequiredItems.Add("FineWood", 6, recover: true);
			buildPiece22.RequiredItems.Add("Tar", 3, recover: true);
			buildPiece22.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			buildPiece22.Snapshot();
			ShaderReplacer.Replace(buildPiece22.Prefab);
			BuildPiece buildPiece23 = new BuildPiece(_darkwoodBundle, "BDWF_Cupboard");
			buildPiece23.Crafting.Set(CraftingTable.Workbench);
			buildPiece23.Category.Set("DarkWood Furnitues");
			buildPiece23.RequiredItems.Add("FineWood", 14, recover: true);
			buildPiece23.RequiredItems.Add("Tar", 6, recover: true);
			buildPiece23.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			buildPiece23.Snapshot();
			ShaderReplacer.Replace(buildPiece23.Prefab);
			BuildPiece buildPiece24 = new BuildPiece(_darkwoodBundle, "BDWF_Drawer1");
			buildPiece24.Crafting.Set(CraftingTable.Workbench);
			buildPiece24.Category.Set("DarkWood Furnitues");
			buildPiece24.RequiredItems.Add("FineWood", 10, recover: true);
			buildPiece24.RequiredItems.Add("Tar", 4, recover: true);
			buildPiece24.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			buildPiece24.Snapshot();
			ShaderReplacer.Replace(buildPiece24.Prefab);
			BuildPiece buildPiece25 = new BuildPiece(_darkwoodBundle, "BDWF_Drawer2");
			buildPiece25.Crafting.Set(CraftingTable.Workbench);
			buildPiece25.Category.Set("DarkWood Furnitues");
			buildPiece25.RequiredItems.Add("FineWood", 10, recover: true);
			buildPiece25.RequiredItems.Add("Tar", 4, recover: true);
			buildPiece25.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			buildPiece25.Snapshot();
			ShaderReplacer.Replace(buildPiece25.Prefab);
			BuildPiece buildPiece26 = new BuildPiece(_darkwoodBundle, "BDWF_Drawer3");
			buildPiece26.Crafting.Set(CraftingTable.Workbench);
			buildPiece26.Category.Set("DarkWood Furnitues");
			buildPiece26.RequiredItems.Add("FineWood", 14, recover: true);
			buildPiece26.RequiredItems.Add("Tar", 6, recover: true);
			buildPiece26.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			buildPiece26.Snapshot();
			ShaderReplacer.Replace(buildPiece26.Prefab);
			BuildPiece buildPiece27 = new BuildPiece(_darkwoodBundle, "BDWF_Drawer4");
			buildPiece27.Crafting.Set(CraftingTable.Workbench);
			buildPiece27.Category.Set("DarkWood Furnitues");
			buildPiece27.RequiredItems.Add("FineWood", 10, recover: true);
			buildPiece27.RequiredItems.Add("Tar", 4, recover: true);
			buildPiece27.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			buildPiece27.Snapshot();
			ShaderReplacer.Replace(buildPiece27.Prefab);
			BuildPiece buildPiece28 = new BuildPiece(_darkwoodBundle, "BDWF_Drawer5");
			buildPiece28.Crafting.Set(CraftingTable.Workbench);
			buildPiece28.Category.Set("DarkWood Furnitues");
			buildPiece28.RequiredItems.Add("FineWood", 6, recover: true);
			buildPiece28.RequiredItems.Add("Tar", 2, recover: true);
			buildPiece28.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			buildPiece28.Snapshot();
			ShaderReplacer.Replace(buildPiece28.Prefab);
			BuildPiece buildPiece29 = new BuildPiece(_darkwoodBundle, "BDWF_Drawer6");
			buildPiece29.Crafting.Set(CraftingTable.Workbench);
			buildPiece29.Category.Set("DarkWood Furnitues");
			buildPiece29.RequiredItems.Add("FineWood", 6, recover: true);
			buildPiece29.RequiredItems.Add("Tar", 2, recover: true);
			buildPiece29.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			buildPiece29.Snapshot();
			ShaderReplacer.Replace(buildPiece29.Prefab);
			BuildPiece buildPiece30 = new BuildPiece(_darkwoodBundle, "BDWF_Drawer7");
			buildPiece30.Crafting.Set(CraftingTable.Workbench);
			buildPiece30.Category.Set("DarkWood Furnitues");
			buildPiece30.RequiredItems.Add("FineWood", 6, recover: true);
			buildPiece30.RequiredItems.Add("Tar", 2, recover: true);
			buildPiece30.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			buildPiece30.Snapshot();
			ShaderReplacer.Replace(buildPiece30.Prefab);
			BuildPiece buildPiece31 = new BuildPiece(_darkwoodBundle, "BDWF_Drawer8");
			buildPiece31.Crafting.Set(CraftingTable.Workbench);
			buildPiece31.Category.Set("DarkWood Furnitues");
			buildPiece31.RequiredItems.Add("FineWood", 6, recover: true);
			buildPiece31.RequiredItems.Add("Tar", 2, recover: true);
			buildPiece31.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			buildPiece31.Snapshot();
			ShaderReplacer.Replace(buildPiece31.Prefab);
			BuildPiece buildPiece32 = new BuildPiece(_darkwoodBundle, "BDWF_IronChest");
			buildPiece32.Crafting.Set(CraftingTable.Workbench);
			buildPiece32.Category.Set("DarkWood Furnitues");
			buildPiece32.RequiredItems.Add("FineWood", 4, recover: true);
			buildPiece32.RequiredItems.Add("Tar", 2, recover: true);
			buildPiece32.RequiredItems.Add("Iron", 12, recover: true);
			buildPiece32.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			buildPiece32.Snapshot();
			ShaderReplacer.Replace(buildPiece32.Prefab);
			BuildPiece buildPiece33 = new BuildPiece(_darkwoodBundle, "BDWF_LongCrate");
			buildPiece33.Crafting.Set(CraftingTable.Workbench);
			buildPiece33.Category.Set("DarkWood Furnitues");
			buildPiece33.RequiredItems.Add("FineWood", 12, recover: true);
			buildPiece33.RequiredItems.Add("Tar", 4, recover: true);
			buildPiece33.RequiredItems.Add("Iron", 2, recover: true);
			buildPiece33.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			buildPiece33.Snapshot();
			ShaderReplacer.Replace(buildPiece33.Prefab);
			BuildPiece buildPiece34 = new BuildPiece(_darkwoodBundle, "BDWF_MiniStool1");
			buildPiece34.Crafting.Set(CraftingTable.Workbench);
			buildPiece34.Category.Set("DarkWood Furnitues");
			buildPiece34.RequiredItems.Add("FineWood", 3, recover: true);
			buildPiece34.RequiredItems.Add("Tar", 2, recover: true);
			buildPiece34.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			buildPiece34.Snapshot();
			ShaderReplacer.Replace(buildPiece34.Prefab);
			BuildPiece buildPiece35 = new BuildPiece(_darkwoodBundle, "BDWF_MiniStool2");
			buildPiece35.Crafting.Set(CraftingTable.Workbench);
			buildPiece35.Category.Set("DarkWood Furnitues");
			buildPiece35.RequiredItems.Add("FineWood", 3, recover: true);
			buildPiece35.RequiredItems.Add("Tar", 2, recover: true);
			buildPiece35.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			buildPiece35.Snapshot();
			ShaderReplacer.Replace(buildPiece35.Prefab);
			BuildPiece buildPiece36 = new BuildPiece(_darkwoodBundle, "BDWF_MiniTable1");
			buildPiece36.Crafting.Set(CraftingTable.Workbench);
			buildPiece36.Category.Set("DarkWood Furnitues");
			buildPiece36.RequiredItems.Add("FineWood", 10, recover: true);
			buildPiece36.RequiredItems.Add("Tar", 4, recover: true);
			buildPiece36.RequiredItems.Add("Crystal", 6, recover: true);
			buildPiece36.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			buildPiece36.Snapshot();
			ShaderReplacer.Replace(buildPiece36.Prefab);
			BuildPiece buildPiece37 = new BuildPiece(_darkwoodBundle, "BDWF_MiniTable2");
			buildPiece37.Crafting.Set(CraftingTable.Workbench);
			buildPiece37.Category.Set("DarkWood Furnitues");
			buildPiece37.RequiredItems.Add("FineWood", 10, recover: true);
			buildPiece37.RequiredItems.Add("Tar", 4, recover: true);
			buildPiece37.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			buildPiece37.Snapshot();
			ShaderReplacer.Replace(buildPiece37.Prefab);
			BuildPiece buildPiece38 = new BuildPiece(_darkwoodBundle, "BDWF_MiniTable3");
			buildPiece38.Crafting.Set(CraftingTable.Workbench);
			buildPiece38.Category.Set("DarkWood Furnitues");
			buildPiece38.RequiredItems.Add("FineWood", 4, recover: true);
			buildPiece38.RequiredItems.Add("Tar", 1, recover: true);
			buildPiece38.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			buildPiece38.Snapshot();
			ShaderReplacer.Replace(buildPiece38.Prefab);
			BuildPiece buildPiece39 = new BuildPiece(_darkwoodBundle, "BDWF_Shelf1");
			buildPiece39.Crafting.Set(CraftingTable.Workbench);
			buildPiece39.Category.Set("DarkWood Furnitues");
			buildPiece39.RequiredItems.Add("FineWood", 12, recover: true);
			buildPiece39.RequiredItems.Add("Tar", 6, recover: true);
			buildPiece39.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			buildPiece39.Snapshot();
			ShaderReplacer.Replace(buildPiece39.Prefab);
			BuildPiece buildPiece40 = new BuildPiece(_darkwoodBundle, "BDWF_Shelf2");
			buildPiece40.Crafting.Set(CraftingTable.Workbench);
			buildPiece40.Category.Set("DarkWood Furnitues");
			buildPiece40.RequiredItems.Add("FineWood", 12, recover: true);
			buildPiece40.RequiredItems.Add("Tar", 6, recover: true);
			buildPiece40.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			buildPiece40.Snapshot();
			ShaderReplacer.Replace(buildPiece40.Prefab);
			BuildPiece buildPiece41 = new BuildPiece(_darkwoodBundle, "BDWF_Shelf3");
			buildPiece41.Crafting.Set(CraftingTable.Workbench);
			buildPiece41.Category.Set("DarkWood Furnitues");
			buildPiece41.RequiredItems.Add("FineWood", 12, recover: true);
			buildPiece41.RequiredItems.Add("Tar", 6, recover: true);
			buildPiece41.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			buildPiece41.Snapshot();
			ShaderReplacer.Replace(buildPiece41.Prefab);
			BuildPiece buildPiece42 = new BuildPiece(_darkwoodBundle, "BDWF_Shelf4");
			buildPiece42.Crafting.Set(CraftingTable.Workbench);
			buildPiece42.Category.Set("DarkWood Furnitues");
			buildPiece42.RequiredItems.Add("FineWood", 12, recover: true);
			buildPiece42.RequiredItems.Add("Tar", 6, recover: true);
			buildPiece42.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			buildPiece42.Snapshot();
			ShaderReplacer.Replace(buildPiece42.Prefab);
			BuildPiece buildPiece43 = new BuildPiece(_darkwoodBundle, "BDWF_Shelf5");
			buildPiece43.Crafting.Set(CraftingTable.Workbench);
			buildPiece43.Category.Set("DarkWood Furnitues");
			buildPiece43.RequiredItems.Add("FineWood", 6, recover: true);
			buildPiece43.RequiredItems.Add("Tar", 2, recover: true);
			buildPiece43.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			buildPiece43.Snapshot();
			ShaderReplacer.Replace(buildPiece43.Prefab);
			BuildPiece buildPiece44 = new BuildPiece(_darkwoodBundle, "BDWF_Stool1");
			buildPiece44.Crafting.Set(CraftingTable.Workbench);
			buildPiece44.Category.Set("DarkWood Furnitues");
			buildPiece44.RequiredItems.Add("FineWood", 2, recover: true);
			buildPiece44.RequiredItems.Add("Tar", 1, recover: true);
			buildPiece44.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			buildPiece44.Snapshot();
			ShaderReplacer.Replace(buildPiece44.Prefab);
			BuildPiece buildPiece45 = new BuildPiece(_darkwoodBundle, "BDWF_Stool2");
			buildPiece45.Crafting.Set(CraftingTable.Workbench);
			buildPiece45.Category.Set("DarkWood Furnitues");
			buildPiece45.RequiredItems.Add("FineWood", 4, recover: true);
			buildPiece45.RequiredItems.Add("Tar", 2, recover: true);
			buildPiece45.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			buildPiece45.Snapshot();
			ShaderReplacer.Replace(buildPiece45.Prefab);
			BuildPiece buildPiece46 = new BuildPiece(_darkwoodBundle, "BDWF_Stool3");
			buildPiece46.Crafting.Set(CraftingTable.Workbench);
			buildPiece46.Category.Set("DarkWood Furnitues");
			buildPiece46.RequiredItems.Add("FineWood", 4, recover: true);
			buildPiece46.RequiredItems.Add("Tar", 2, recover: true);
			buildPiece46.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			buildPiece46.Snapshot();
			ShaderReplacer.Replace(buildPiece46.Prefab);
			BuildPiece buildPiece47 = new BuildPiece(_darkwoodBundle, "BDWF_Table1");
			buildPiece47.Crafting.Set(CraftingTable.Workbench);
			buildPiece47.Category.Set("DarkWood Furnitues");
			buildPiece47.RequiredItems.Add("FineWood", 4, recover: true);
			buildPiece47.RequiredItems.Add("Tar", 2, recover: true);
			buildPiece47.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			buildPiece47.Snapshot();
			ShaderReplacer.Replace(buildPiece47.Prefab);
			BuildPiece buildPiece48 = new BuildPiece(_darkwoodBundle, "BDWF_Table2");
			buildPiece48.Crafting.Set(CraftingTable.Workbench);
			buildPiece48.Category.Set("DarkWood Furnitues");
			buildPiece48.RequiredItems.Add("FineWood", 6, recover: true);
			buildPiece48.RequiredItems.Add("Tar", 2, recover: true);
			buildPiece48.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			buildPiece48.Snapshot();
			ShaderReplacer.Replace(buildPiece48.Prefab);
			BuildPiece buildPiece49 = new BuildPiece(_darkwoodBundle, "BDWF_Table3");
			buildPiece49.Crafting.Set(CraftingTable.Workbench);
			buildPiece49.Category.Set("DarkWood Furnitues");
			buildPiece49.RequiredItems.Add("FineWood", 6, recover: true);
			buildPiece49.RequiredItems.Add("Tar", 2, recover: true);
			buildPiece49.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			buildPiece49.Snapshot();
			ShaderReplacer.Replace(buildPiece49.Prefab);
			BuildPiece buildPiece50 = new BuildPiece(_darkwoodBundle, "BDWF_Table4");
			buildPiece50.Crafting.Set(CraftingTable.Workbench);
			buildPiece50.Category.Set("DarkWood Furnitues");
			buildPiece50.RequiredItems.Add("FineWood", 6, recover: true);
			buildPiece50.RequiredItems.Add("Tar", 2, recover: true);
			buildPiece50.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			buildPiece50.Snapshot();
			ShaderReplacer.Replace(buildPiece50.Prefab);
			BuildPiece buildPiece51 = new BuildPiece(_darkwoodBundle, "BDWF_Table5");
			buildPiece51.Crafting.Set(CraftingTable.Workbench);
			buildPiece51.Category.Set("DarkWood Furnitues");
			buildPiece51.RequiredItems.Add("FineWood", 6, recover: true);
			buildPiece51.RequiredItems.Add("Tar", 2, recover: true);
			buildPiece51.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			buildPiece51.Snapshot();
			ShaderReplacer.Replace(buildPiece51.Prefab);
			BuildPiece buildPiece52 = new BuildPiece(_darkwoodBundle, "BDWF_Table6");
			buildPiece52.Crafting.Set(CraftingTable.Workbench);
			buildPiece52.Category.Set("DarkWood Furnitues");
			buildPiece52.RequiredItems.Add("FineWood", 6, recover: true);
			buildPiece52.RequiredItems.Add("Tar", 2, recover: true);
			buildPiece52.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			buildPiece52.Snapshot();
			ShaderReplacer.Replace(buildPiece52.Prefab);
			BuildPiece buildPiece53 = new BuildPiece(_darkwoodBundle, "BDWF_Table7");
			buildPiece53.Crafting.Set(CraftingTable.Workbench);
			buildPiece53.Category.Set("DarkWood Furnitues");
			buildPiece53.RequiredItems.Add("FineWood", 6, recover: true);
			buildPiece53.RequiredItems.Add("Tar", 2, recover: true);
			buildPiece53.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			buildPiece53.Snapshot();
			ShaderReplacer.Replace(buildPiece53.Prefab);
			BuildPiece buildPiece54 = new BuildPiece(_darkwoodBundle, "BDWF_Table8");
			buildPiece54.Crafting.Set(CraftingTable.Workbench);
			buildPiece54.Category.Set("DarkWood Furnitues");
			buildPiece54.RequiredItems.Add("FineWood", 6, recover: true);
			buildPiece54.RequiredItems.Add("Tar", 2, recover: true);
			buildPiece54.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			buildPiece54.Snapshot();
			ShaderReplacer.Replace(buildPiece54.Prefab);
			BuildPiece buildPiece55 = new BuildPiece(_darkwoodBundle, "BDWF_Table9");
			buildPiece55.Crafting.Set(CraftingTable.Workbench);
			buildPiece55.Category.Set("DarkWood Furnitues");
			buildPiece55.RequiredItems.Add("FineWood", 6, recover: true);
			buildPiece55.RequiredItems.Add("Tar", 2, recover: true);
			buildPiece55.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			buildPiece55.Snapshot();
			ShaderReplacer.Replace(buildPiece55.Prefab);
		}
	}
	public static class ShaderReplacer
	{
		private static readonly List<GameObject> GOToSwap;

		static ShaderReplacer()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			GOToSwap = new List<GameObject>();
			new Harmony("blacks7ar.utilities.ShaderReplacer").Patch((MethodBase)AccessTools.DeclaredMethod(typeof(FejdStartup), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(ShaderReplacer), "ReplaceShaderPatch", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}

		public static void Replace(GameObject gameObject)
		{
			GOToSwap.Add(gameObject);
		}

		[HarmonyPriority(700)]
		private static void ReplaceShaderPatch()
		{
			foreach (Material item in from gameObject in GOToSwap
				select gameObject.GetComponentsInChildren<Renderer>(true) into renderers
				from renderer in renderers
				where (Object)(object)renderer != (Object)null
				from material in renderer.sharedMaterials
				where (Object)(object)material != (Object)null
				select material)
			{
				Shader[] array = Resources.FindObjectsOfTypeAll<Shader>();
				foreach (Shader val in array)
				{
					if (((Object)item.shader).name == ((Object)val).name)
					{
						item.shader = val;
					}
				}
			}
		}
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[<b89b921d-8954-4084-bd4d-1feb826a594e>Embedded]
	internal sealed class <b89b921d-8954-4084-bd4d-1feb826a594e>EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[<b89b921d-8954-4084-bd4d-1feb826a594e>Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class <f6f8ff5f-fa45-43ba-9489-b740a9e7c98b>NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public <f6f8ff5f-fa45-43ba-9489-b740a9e7c98b>NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public <f6f8ff5f-fa45-43ba-9489-b740a9e7c98b>NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[<b89b921d-8954-4084-bd4d-1feb826a594e>Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	[CompilerGenerated]
	internal sealed class <bb5e3e5e-5c47-485a-88ef-ea5afd7f01c7>NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public <bb5e3e5e-5c47-485a-88ef-ea5afd7f01c7>NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace LocalizationManager
{
	[<f6f8ff5f-fa45-43ba-9489-b740a9e7c98b>Nullable(0)]
	[PublicAPI]
	[<bb5e3e5e-5c47-485a-88ef-ea5afd7f01c7>NullableContext(1)]
	internal 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;

		[<f6f8ff5f-fa45-43ba-9489-b740a9e7c98b>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([<bb5e3e5e-5c47-485a-88ef-ea5afd7f01c7>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, [<bb5e3e5e-5c47-485a-88ef-ea5afd7f01c7>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, [<f6f8ff5f-fa45-43ba-9489-b740a9e7c98b>Nullable(new byte[] { 2, 1, 1 })] Func<T, string> convertConfigValue = null)
		{
			if (convertConfigValue == null)
			{
				convertConfigValue = [<bb5e3e5e-5c47-485a-88ef-ea5afd7f01c7>NullableContext(0)] [return: <f6f8ff5f-fa45-43ba-9489-b740a9e7c98b>Nullable(1)] (T val) => val.ToString();
			}
			if (!PlaceholderProcessors.ContainsKey(key))
			{
				PlaceholderProcessors[key] = new Dictionary<string, Func<string>>();
			}
			config.SettingChanged += [<bb5e3e5e-5c47-485a-88ef-ea5afd7f01c7>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: <f6f8ff5f-fa45-43ba-9489-b740a9e7c98b>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;
		}

		[<bb5e3e5e-5c47-485a-88ef-ea5afd7f01c7>NullableContext(2)]
		public static byte[] ReadEmbeddedFileBytes([<f6f8ff5f-fa45-43ba-9489-b740a9e7c98b>Nullable(1)] string resourceFileName, Assembly containingAssembly = null)
		{
			using MemoryStream memoryStream = new MemoryStream();
			if ((object)containingAssembly == null)
			{
				containingAssembly = Assembly.GetCallingAssembly();
			}
			string text = containingAssembly.GetManifestResourceNames().FirstOrDefault([<bb5e3e5e-5c47-485a-88ef-ea5afd7f01c7>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 System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace System.Diagnostics.CodeAnalysis
{
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)]
	internal sealed class AllowNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)]
	internal sealed class DisallowNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Method, Inherited = false)]
	internal sealed class DoesNotReturnAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	internal sealed class DoesNotReturnIfAttribute : Attribute
	{
		public bool ParameterValue { get; }

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

		public MaybeNullWhenAttribute(bool returnValue)
		{
			ReturnValue = returnValue;
		}
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, Inherited = false)]
	internal sealed class NotNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = true, Inherited = false)]
	internal sealed class NotNullIfNotNullAttribute : Attribute
	{
		public string ParameterName { get; }

		public NotNullIfNotNullAttribute(string parameterName)
		{
			ParameterName = parameterName;
		}
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	internal sealed class NotNullWhenAttribute : Attribute
	{
		public bool ReturnValue { get; }

		public NotNullWhenAttribute(bool returnValue)
		{
			ReturnValue = returnValue;
		}
	}
}
namespace System.Collections.Generic
{
	internal static class DeconstructionExtensions
	{
		public static void Deconstruct<TKey, TValue>(this KeyValuePair<TKey, TValue> pair, out TKey key, out TValue value)
		{
			key = pair.Key;
			value = pair.Value;
		}
	}
}
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)
		{
			if (!type.IsValueType)
			{
				return type.GetConstructor(BindingFlags.Instance | BindingFlags.Public, 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));
		}
	}
	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;

		private bool ignoreFields;

		private bool includeNonPublicProperties;

		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");
		}

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

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

		public TBuilder IncludeNonPublicProperties()
		{
			includeNonPublicProperties = 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 bool ignoreUnmatched;

		protected override DeserializerBuilder Self => this;

		public DeserializerBuilder()
			: base((ITypeResolver)new StaticTypeResolver())
		{
			typeMappings = new Dictionary<Type, Type>();
			objectFactory = new Lazy<IObjectFactory>(() => new DefaultObjectFactory(typeMappings), 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()
				},
				{
					typeof(ArrayNodeDeserializer),
					(Nothing _) => new ArrayNodeDeserializer()
				},
				{
					typeof(DictionaryNodeDeserializer),
					(Nothing _) => new DictionaryNodeDeserializer(objectFactory.Value)
				},
				{
					typeof(CollectionNodeDeserializer),
					(Nothing _) => new CollectionNodeDeserializer(objectFactory.Value)
				},
				{
					typeof(EnumerableNodeDeserializer),
					(Nothing _) => new EnumerableNodeDeserializer()
				},
				{
					typeof(ObjectNodeDeserializer),
					(Nothing _) => new ObjectNodeDeserializer(objectFactory.Value, BuildTypeInspector(), ignoreUnmatched)
				}
			};
			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()
				}
			};
		}

		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 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 IDeserializer Build()
		{
			return Deserializer.FromValueDeserializer(BuildValueDeserializer());
		}

		public IValueDeserializer BuildValueDeserializer()
		{
			return new AliasValueDeserializer(new NodeValueDeserializer(nodeDeserializerFactories.BuildComponentList(), nodeTypeResolverFactories.BuildComponentList()));
		}
	}
	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 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);
	}
	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 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 LazyComponentRegistrationList<IEnumerable<IYamlTypeConverter>, IObjectGraphVisitor<Nothing>> preProcessingPhaseObjectGraphVisitorFactories;

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

		private readonly LazyComponentRegistrationList<IEventEmitter, IEventEmitter> eventEmitterFactories;

		private readonly IDictionary<Type, TagName> tagMappings = new Dictionary<Type, TagName>();

		private int maximumRecursion = 50;

		private EmitterSettings emitterSettings = EmitterSettings.Default;

		private DefaultValuesHandling defaultValuesHandlingConfiguration;

		protected override SerializerBuilder Self => this;

		public SerializerBuilder()
			: base((ITypeResolver)new DynamicTypeResolver())
		{
			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()));
			preProcessingPhaseObjectGraphVisitorFactories = new LazyComponentRegistrationList<IEnumerable<IYamlTypeConverter>, IObjectGraphVisitor<Nothing>> { 
			{
				typeof(AnchorAssigner),
				(IEnumerable<IYamlTypeConverter> typeConverters) => new AnchorAssigner(typeConverters)
			} };
			emissionPhaseObjectGraphVisitorFactories = new LazyComponentRegistrationList<EmissionPhaseObjectGraphVisitorArgs, IObjectGraphVisitor<IEmitter>>
			{
				{
					typeof(CustomSerializationObjectGraphVisitor),
					(EmissionPhaseObjectGraphVisitorArgs args) => new CustomSerializationObjectGraphVisitor(args.InnerVisitor, args.TypeConverters, args.NestedObjectSerializer)
				},
				{
					typeof(AnchorAssigningObjectGraphVisitor),
					(EmissionPhaseObjectGraphVisitorArgs args) => new AnchorAssigningObjectGraphVisitor(args.InnerVisitor, args.EventEmitter, args.GetPreProcessingPhaseObjectGraphVisitor<AnchorAssigner>())
				},
				{
					typeof(DefaultValuesObjectGraphVisitor),
					(EmissionPhaseObjectGraphVisitorArgs args) => new DefaultValuesObjectGraphVisitor(defaultValuesHandlingConfiguration, args.InnerVisitor)
				},
				{
					typeof(CommentsObjectGraphVisitor),
					(EmissionPhaseObjectGraphVisitorArgs args) => new CommentsObjectGraphVisitor(args.InnerVisitor)
				}
			};
			eventEmitterFactories = new LazyComponentRegistrationList<IEventEmitter, IEventEmitter> { 
			{
				typeof(TypeAssigningEventEmitter),
				(IEventEmitter inner) => new TypeAssigningEventEmitter(inner, requireTagWhenStaticAndActualTypesAreDifferent: false, tagMappings)
			} };
			objectGraphTraversalStrategyFactory = (ITypeInspector typeInspector, ITypeResolver typeResolver, IEnumerable<IYamlTypeConverter> typeConverters, int maximumRecursion) => new FullObjectGraphTraversalStrategy(typeInspector, typeResolver, maximumRecursion, namingConvention);
		}

		public SerializerBuilder WithMaximumRecursion(int maximumRecursion)
		{
			if (maximumRecursion <= 0)
			{
				throw new ArgumentOutOfRangeException("maximumRecursion", $"The maximum recursion specified ({maximumRecursion}) is invalid. It should be a positive integer.");
			}
			this.maximumRecursion = maximumRecursion;
			return this;
		}

		public SerializerBuilder WithEventEmitter<TEventEmitter>(Func<IEventEmitter, TEventEmitter> eventEmitterFactory) where TEventEmitter : IEventEmitter
		{
			return WithEventEmitter(eventEmitterFactory, delegate(IRegistrationLocationSelectionSyntax<IEventEmitter> w)
			{
				w.OnTop();
			});
		}

		public SerializerBuilder WithEventEmitter<TEventEmitter>(Func<IEventEmitter, TEventEmitter> eventEmitterFactory, Action<IRegistrationLocationSelectionSyntax<IEventEmitter>> where) where TEventEmitter : IEventEmitter
		{
			Func<IEventEmitter, TEventEmitter> eventEmitterFactory2 = eventEmitterFactory;
			if (eventEmitterFactory2 == null)
			{
				throw new ArgumentNullException("eventEmitterFactory");
			}
			if (where == null)
			{
				throw new ArgumentNullException("where");
			}
			where(eventEmitterFactories.CreateRegistrationLocationSelector(typeof(TEventEmitter), (IEventEmitter inner) => eventEmitterFactory2(inner)));
			return Self;
		}

		public SerializerBuilder WithEventEmitter<TEventEmitter>(WrapperFactory<IEventEmitter, IEventEmitter, TEventEmitter> eventEmitterFactory, Action<ITrackingRegistrationLocationSelectionSyntax<IEventEmitter>> where) where TEventEmitter : IEventEmitter
		{
			WrapperFactory<IEventEmitter, IEventEmitter, TEventEmitter> eventEmitterFactory2 = eventEmitterFactory;
			if (eventEmitterFactory2 == null)
			{
				throw new ArgumentNullException("eventEmitterFactory");
			}
			if (where == null)
			{
				throw new ArgumentNullException("where");
			}
			where(eventEmitterFactories.CreateTrackingRegistrationLocationSelector(typeof(TEventEmitter), (IEventEmitter wrapped, IEventEmitter inner) => eventEmitterFactory2(wrapped, inner)));
			return Self;
		}

		public SerializerBuilder WithoutEventEmitter<TEventEmitter>() where TEventEmitter : IEventEmitter
		{
			return WithoutEventEmitter(typeof(TEventEmitter));
		}

		public SerializerBuilder WithoutEventEmitter(Type eventEmitterType)
		{
			if (eventEmitterType == null)
			{
				throw new ArgumentNullException("eventEmitterType");
			}
			eventEmitterFactories.Remove(eventEmitterType);
			return this;
		}

		public override SerializerBuilder WithTagMapping(TagName tag, Type type)
		{
			if (tag.IsEmpty)
			{
				throw new ArgumentException("Non-spec