Decompiled source of CrystalLights v1.1.2
CrystalLights.dll
Decompiled 2 weeks ago
The result has been truncated due to the large size, download it to view full contents!
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 HarmonyLib; using ItemManager; 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: AssemblyFileVersion("1.0.0.0")] [assembly: Guid("D181CDA7-EF07-4BBC-B975-2B80FC6BBFAE")] [assembly: ComVisible(false)] [assembly: AssemblyTrademark("")] [assembly: AssemblyCopyright("Copyright © 2024")] [assembly: AssemblyProduct("CrystalArrows")] [assembly: AssemblyCompany("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyDescription("")] [assembly: AssemblyTitle("CrystalLights")] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: CompilationRelaxations(8)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace CrystalLights { [BepInPlugin("org.bepinex.plugins.crystallights", "CrystalLights", "1.1.2")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class CrystalLights : BaseUnityPlugin { private enum Toggle { On = 1, Off = 0 } private class ConfigurationManagerAttributes { [UsedImplicitly] public string Category = null; } private const string ModName = "CrystalLights"; private const string ModVersion = "1.1.2"; private const string ModGUID = "org.bepinex.plugins.crystallights"; private static readonly ConfigSync configSync = new ConfigSync("CrystalLights") { DisplayName = "CrystalLights", CurrentVersion = "1.1.2", MinimumRequiredVersion = "1.1.2" }; private static ConfigEntry<Toggle> serverConfigLocked = null; private static readonly Dictionary<string, ConfigEntry<float>> lightIntensities = new Dictionary<string, ConfigEntry<float>>(); private static AssetBundle assets = null; private static Localization english = null; private ConfigEntry<T> config<T>(string group, string name, T value, ConfigDescription description, bool synchronizedSetting = true) { ConfigEntry<T> val = ((BaseUnityPlugin)this).Config.Bind<T>(group, name, value, description); SyncedConfigEntry<T> syncedConfigEntry = configSync.AddConfigEntry<T>(val); syncedConfigEntry.SynchronizedConfig = synchronizedSetting; return val; } private ConfigEntry<T> config<T>(string group, string name, T value, string description, bool synchronizedSetting = true) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown return config(group, name, value, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>()), synchronizedSetting); } public void Awake() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_1732: Unknown result type (might be due to invalid IL or missing references) //IL_1739: Expected O, but got Unknown Localizer.Load(); english = new Localization(); english.SetupLanguage("English"); serverConfigLocked = config("1 - General", "Lock Configuration", Toggle.On, "If on, the configuration is locked and can be changed by server admins only."); configSync.AddLockingConfigEntry<Toggle>(serverConfigLocked); assets = PiecePrefabManager.RegisterAssetBundle("crystallights"); Item item = new Item(assets, "CL_Crystal_Hammer"); item.Crafting.Add(ItemManager.CraftingTable.Workbench, 1); item.RequiredItems.Add("Uncut_Red_Stone", 1); item.RequiredItems.Add("Wood", 1); item.CraftAmount = 1; BuildPiece buildPiece = AddLightPiece("CL_Large_Wall_Black"); buildPiece.RequiredItems.Add("Uncut_Black_Stone", 10, recover: true); buildPiece.RequiredItems.Add("IronNails", 2, recover: true); buildPiece.Crafting.Set(PieceManager.CraftingTable.None); buildPiece.Category.Set("Misc"); BuildPiece buildPiece2 = AddLightPiece("CL_Large_Wall_White"); buildPiece2.RequiredItems.Add("Uncut_Black_Stone", 10, recover: true); buildPiece2.RequiredItems.Add("IronNails", 2, recover: true); buildPiece2.Crafting.Set(PieceManager.CraftingTable.None); buildPiece2.Category.Set("Misc"); BuildPiece buildPiece3 = AddLightPiece("CL_Large_Wall_Blue"); buildPiece3.RequiredItems.Add("Uncut_Blue_Stone", 10, recover: true); buildPiece3.RequiredItems.Add("IronNails", 2, recover: true); buildPiece3.Crafting.Set(PieceManager.CraftingTable.None); buildPiece3.Category.Set("Misc"); BuildPiece buildPiece4 = AddLightPiece("CL_Large_Wall_Green"); buildPiece4.RequiredItems.Add("Uncut_Green_Stone", 10, recover: true); buildPiece4.RequiredItems.Add("IronNails", 2, recover: true); buildPiece4.Crafting.Set(PieceManager.CraftingTable.None); buildPiece4.Category.Set("Misc"); BuildPiece buildPiece5 = AddLightPiece("CL_Large_Wall_Orange"); buildPiece5.RequiredItems.Add("Uncut_Orange_Stone", 10, recover: true); buildPiece5.RequiredItems.Add("IronNails", 2, recover: true); buildPiece5.Crafting.Set(PieceManager.CraftingTable.None); buildPiece5.Category.Set(BuildPieceCategory.Misc); BuildPiece buildPiece6 = AddLightPiece("CL_Large_Wall_Purple"); buildPiece6.RequiredItems.Add("Uncut_Purple_Stone", 10, recover: true); buildPiece6.RequiredItems.Add("IronNails", 2, recover: true); buildPiece6.Crafting.Set(PieceManager.CraftingTable.None); buildPiece6.Category.Set(BuildPieceCategory.Misc); BuildPiece buildPiece7 = AddLightPiece("CL_Large_Wall_Red"); buildPiece7.RequiredItems.Add("Uncut_Red_Stone", 10, recover: true); buildPiece7.RequiredItems.Add("IronNails", 2, recover: true); buildPiece7.Crafting.Set(PieceManager.CraftingTable.None); buildPiece7.Category.Set(BuildPieceCategory.Misc); BuildPiece buildPiece8 = AddLightPiece("CL_Large_Wall_Yellow"); buildPiece8.RequiredItems.Add("Uncut_Yellow_Stone", 10, recover: true); buildPiece8.RequiredItems.Add("IronNails", 2, recover: true); buildPiece8.Crafting.Set(PieceManager.CraftingTable.None); buildPiece8.Category.Set(BuildPieceCategory.Misc); BuildPiece buildPiece9 = AddLightPiece("CL_Small_Wall_Black"); buildPiece9.RequiredItems.Add("Uncut_Black_Stone", 3, recover: true); buildPiece9.RequiredItems.Add("IronNails", 1, recover: true); buildPiece9.Crafting.Set(PieceManager.CraftingTable.None); buildPiece9.Category.Set(BuildPieceCategory.Misc); BuildPiece buildPiece10 = AddLightPiece("CL_Small_Wall_White"); buildPiece10.RequiredItems.Add("Uncut_Black_Stone", 3, recover: true); buildPiece10.RequiredItems.Add("IronNails", 1, recover: true); buildPiece10.Crafting.Set(PieceManager.CraftingTable.None); buildPiece10.Category.Set(BuildPieceCategory.Misc); BuildPiece buildPiece11 = AddLightPiece("CL_Small_Wall_Blue"); buildPiece11.RequiredItems.Add("Uncut_Blue_Stone", 3, recover: true); buildPiece11.RequiredItems.Add("IronNails", 1, recover: true); buildPiece11.Crafting.Set(PieceManager.CraftingTable.None); buildPiece11.Category.Set(BuildPieceCategory.Misc); BuildPiece buildPiece12 = AddLightPiece("CL_Small_Wall_Green"); buildPiece12.RequiredItems.Add("Uncut_Green_Stone", 3, recover: true); buildPiece12.RequiredItems.Add("IronNails", 1, recover: true); buildPiece12.Crafting.Set(PieceManager.CraftingTable.None); buildPiece12.Category.Set(BuildPieceCategory.Misc); BuildPiece buildPiece13 = AddLightPiece("CL_Small_Wall_Orange"); buildPiece13.RequiredItems.Add("Uncut_Orange_Stone", 3, recover: true); buildPiece13.RequiredItems.Add("IronNails", 1, recover: true); buildPiece13.Crafting.Set(PieceManager.CraftingTable.None); buildPiece13.Category.Set(BuildPieceCategory.Misc); BuildPiece buildPiece14 = AddLightPiece("CL_Small_Wall_Purple"); buildPiece14.RequiredItems.Add("Uncut_Purple_Stone", 3, recover: true); buildPiece14.RequiredItems.Add("IronNails", 1, recover: true); buildPiece14.Crafting.Set(PieceManager.CraftingTable.None); buildPiece14.Category.Set(BuildPieceCategory.Misc); BuildPiece buildPiece15 = AddLightPiece("CL_Small_Wall_Red"); buildPiece15.RequiredItems.Add("Uncut_Red_Stone", 3, recover: true); buildPiece15.RequiredItems.Add("IronNails", 1, recover: true); buildPiece15.Crafting.Set(PieceManager.CraftingTable.None); buildPiece15.Category.Set(BuildPieceCategory.Misc); BuildPiece buildPiece16 = AddLightPiece("CL_Small_Wall_Yellow"); buildPiece16.RequiredItems.Add("Uncut_Yellow_Stone", 3, recover: true); buildPiece16.RequiredItems.Add("IronNails", 1, recover: true); buildPiece16.Crafting.Set(PieceManager.CraftingTable.None); buildPiece16.Category.Set(BuildPieceCategory.Misc); BuildPiece buildPiece17 = AddLightPiece("CL_Standing_Lamp_Black"); buildPiece17.RequiredItems.Add("Uncut_Black_Stone", 1, recover: true); buildPiece17.RequiredItems.Add("IronNails", 1, recover: true); buildPiece17.Crafting.Set(PieceManager.CraftingTable.None); buildPiece17.Category.Set(BuildPieceCategory.Misc); BuildPiece buildPiece18 = AddLightPiece("CL_Standing_Lamp_White"); buildPiece18.RequiredItems.Add("Uncut_Black_Stone", 1, recover: true); buildPiece18.RequiredItems.Add("IronNails", 1, recover: true); buildPiece18.Crafting.Set(PieceManager.CraftingTable.None); buildPiece18.Category.Set(BuildPieceCategory.Misc); BuildPiece buildPiece19 = AddLightPiece("CL_Standing_Lamp_Blue"); buildPiece19.RequiredItems.Add("Uncut_Blue_Stone", 1, recover: true); buildPiece19.RequiredItems.Add("IronNails", 1, recover: true); buildPiece19.Crafting.Set(PieceManager.CraftingTable.None); buildPiece19.Category.Set(BuildPieceCategory.Misc); BuildPiece buildPiece20 = AddLightPiece("CL_Standing_Lamp_Green"); buildPiece20.RequiredItems.Add("Uncut_Green_Stone", 1, recover: true); buildPiece20.RequiredItems.Add("IronNails", 1, recover: true); buildPiece20.Crafting.Set(PieceManager.CraftingTable.None); buildPiece20.Category.Set(BuildPieceCategory.Misc); BuildPiece buildPiece21 = AddLightPiece("CL_Standing_Lamp_Orange"); buildPiece21.RequiredItems.Add("Uncut_Orange_Stone", 1, recover: true); buildPiece21.RequiredItems.Add("IronNails", 1, recover: true); buildPiece21.Crafting.Set(PieceManager.CraftingTable.None); buildPiece21.Category.Set(BuildPieceCategory.Misc); BuildPiece buildPiece22 = AddLightPiece("CL_Standing_Lamp_Purple"); buildPiece22.RequiredItems.Add("Uncut_Purple_Stone", 1, recover: true); buildPiece22.RequiredItems.Add("IronNails", 1, recover: true); buildPiece22.Crafting.Set(PieceManager.CraftingTable.None); buildPiece22.Category.Set(BuildPieceCategory.Misc); BuildPiece buildPiece23 = AddLightPiece("CL_Standing_Lamp_Red"); buildPiece23.RequiredItems.Add("Uncut_Red_Stone", 1, recover: true); buildPiece23.RequiredItems.Add("IronNails", 1, recover: true); buildPiece23.Crafting.Set(PieceManager.CraftingTable.None); buildPiece23.Category.Set(BuildPieceCategory.Misc); BuildPiece buildPiece24 = AddLightPiece("CL_Standing_Lamp_Yellow"); buildPiece24.RequiredItems.Add("Uncut_Yellow_Stone", 1, recover: true); buildPiece24.RequiredItems.Add("IronNails", 1, recover: true); buildPiece24.Crafting.Set(PieceManager.CraftingTable.None); buildPiece24.Category.Set(BuildPieceCategory.Misc); BuildPiece buildPiece25 = AddLightPiece("CL_Chandelier_Black"); buildPiece25.RequiredItems.Add("Uncut_Black_Stone", 15, recover: true); buildPiece25.RequiredItems.Add("IronNails", 5, recover: true); buildPiece25.Crafting.Set(PieceManager.CraftingTable.None); buildPiece25.Category.Set(BuildPieceCategory.Misc); BuildPiece buildPiece26 = AddLightPiece("CL_Chandelier_White"); buildPiece26.RequiredItems.Add("Uncut_Black_Stone", 15, recover: true); buildPiece26.RequiredItems.Add("IronNails", 5, recover: true); buildPiece26.Crafting.Set(PieceManager.CraftingTable.None); buildPiece26.Category.Set(BuildPieceCategory.Misc); BuildPiece buildPiece27 = AddLightPiece("CL_Chandelier_Blue"); buildPiece27.RequiredItems.Add("Uncut_Blue_Stone", 15, recover: true); buildPiece27.RequiredItems.Add("IronNails", 5, recover: true); buildPiece27.Crafting.Set(PieceManager.CraftingTable.None); buildPiece27.Category.Set(BuildPieceCategory.Misc); BuildPiece buildPiece28 = AddLightPiece("CL_Chandelier_Green"); buildPiece28.RequiredItems.Add("Uncut_Green_Stone", 15, recover: true); buildPiece28.RequiredItems.Add("IronNails", 5, recover: true); buildPiece28.Crafting.Set(PieceManager.CraftingTable.None); buildPiece28.Category.Set(BuildPieceCategory.Misc); BuildPiece buildPiece29 = AddLightPiece("CL_Chandelier_Orange"); buildPiece29.RequiredItems.Add("Uncut_Orange_Stone", 15, recover: true); buildPiece29.RequiredItems.Add("IronNails", 5, recover: true); buildPiece29.Crafting.Set(PieceManager.CraftingTable.None); buildPiece29.Category.Set(BuildPieceCategory.Misc); BuildPiece buildPiece30 = AddLightPiece("CL_Chandelier_Yellow"); buildPiece30.RequiredItems.Add("Uncut_Yellow_Stone", 15, recover: true); buildPiece30.RequiredItems.Add("IronNails", 5, recover: true); buildPiece30.Crafting.Set(PieceManager.CraftingTable.None); buildPiece30.Category.Set(BuildPieceCategory.Misc); BuildPiece buildPiece31 = AddLightPiece("CL_Chandelier_Purple"); buildPiece31.RequiredItems.Add("Uncut_Purple_Stone", 15, recover: true); buildPiece31.RequiredItems.Add("IronNails", 5, recover: true); buildPiece31.Crafting.Set(PieceManager.CraftingTable.None); buildPiece31.Category.Set(BuildPieceCategory.Misc); BuildPiece buildPiece32 = AddLightPiece("CL_Chandelier_Red"); buildPiece32.RequiredItems.Add("Uncut_Red_Stone", 15, recover: true); buildPiece32.RequiredItems.Add("IronNails", 5, recover: true); buildPiece32.Crafting.Set(PieceManager.CraftingTable.None); buildPiece32.Category.Set(BuildPieceCategory.Misc); BuildPiece buildPiece33 = AddLightPiece("CL_Brazier_Black"); buildPiece33.RequiredItems.Add("Uncut_Black_Stone", 10, recover: true); buildPiece33.RequiredItems.Add("IronNails", 4, recover: true); buildPiece33.Crafting.Set(PieceManager.CraftingTable.None); buildPiece33.Category.Set(BuildPieceCategory.Misc); BuildPiece buildPiece34 = AddLightPiece("CL_Brazier_White"); buildPiece34.RequiredItems.Add("Uncut_Black_Stone", 10, recover: true); buildPiece34.RequiredItems.Add("IronNails", 4, recover: true); buildPiece34.Crafting.Set(PieceManager.CraftingTable.None); buildPiece34.Category.Set(BuildPieceCategory.Misc); BuildPiece buildPiece35 = AddLightPiece("CL_Brazier_Blue"); buildPiece35.RequiredItems.Add("Uncut_Blue_Stone", 10, recover: true); buildPiece35.RequiredItems.Add("IronNails", 4, recover: true); buildPiece35.Crafting.Set(PieceManager.CraftingTable.None); buildPiece35.Category.Set(BuildPieceCategory.Misc); BuildPiece buildPiece36 = AddLightPiece("CL_Brazier_Green"); buildPiece36.RequiredItems.Add("Uncut_Green_Stone", 10, recover: true); buildPiece36.RequiredItems.Add("IronNails", 4, recover: true); buildPiece36.Crafting.Set(PieceManager.CraftingTable.None); buildPiece36.Category.Set(BuildPieceCategory.Misc); BuildPiece buildPiece37 = AddLightPiece("CL_Brazier_Orange"); buildPiece37.RequiredItems.Add("Uncut_Orange_Stone", 10, recover: true); buildPiece37.RequiredItems.Add("IronNails", 4, recover: true); buildPiece37.Crafting.Set(PieceManager.CraftingTable.None); buildPiece37.Category.Set(BuildPieceCategory.Misc); BuildPiece buildPiece38 = AddLightPiece("CL_Brazier_Purple"); buildPiece38.RequiredItems.Add("Uncut_Purple_Stone", 10, recover: true); buildPiece38.RequiredItems.Add("IronNails", 4, recover: true); buildPiece38.Crafting.Set(PieceManager.CraftingTable.None); buildPiece38.Category.Set(BuildPieceCategory.Misc); BuildPiece buildPiece39 = AddLightPiece("CL_Brazier_Red"); buildPiece39.RequiredItems.Add("Uncut_Red_Stone", 10, recover: true); buildPiece39.RequiredItems.Add("IronNails", 4, recover: true); buildPiece39.Crafting.Set(PieceManager.CraftingTable.None); buildPiece39.Category.Set(BuildPieceCategory.Misc); BuildPiece buildPiece40 = AddLightPiece("CL_Brazier_Yellow"); buildPiece40.RequiredItems.Add("Uncut_Yellow_Stone", 10, recover: true); buildPiece40.RequiredItems.Add("IronNails", 4, recover: true); buildPiece40.Crafting.Set(PieceManager.CraftingTable.None); buildPiece40.Category.Set(BuildPieceCategory.Misc); BuildPiece buildPiece41 = AddLightPiece("CL_Hanging_Black"); buildPiece41.RequiredItems.Add("Uncut_Black_Stone", 5, recover: true); buildPiece41.RequiredItems.Add("IronNails", 2, recover: true); buildPiece41.Crafting.Set(PieceManager.CraftingTable.None); buildPiece41.Category.Set(BuildPieceCategory.Misc); BuildPiece buildPiece42 = AddLightPiece("CL_Hanging_White"); buildPiece42.RequiredItems.Add("Uncut_Black_Stone", 5, recover: true); buildPiece42.RequiredItems.Add("IronNails", 2, recover: true); buildPiece42.Crafting.Set(PieceManager.CraftingTable.None); buildPiece42.Category.Set(BuildPieceCategory.Misc); BuildPiece buildPiece43 = AddLightPiece("CL_Hanging_Blue"); buildPiece43.RequiredItems.Add("Uncut_Blue_Stone", 5, recover: true); buildPiece43.RequiredItems.Add("IronNails", 2, recover: true); buildPiece43.Crafting.Set(PieceManager.CraftingTable.None); buildPiece43.Category.Set(BuildPieceCategory.Misc); BuildPiece buildPiece44 = AddLightPiece("CL_Hanging_Green"); buildPiece44.RequiredItems.Add("Uncut_Green_Stone", 5, recover: true); buildPiece44.RequiredItems.Add("IronNails", 2, recover: true); buildPiece44.Crafting.Set(PieceManager.CraftingTable.None); buildPiece44.Category.Set(BuildPieceCategory.Misc); BuildPiece buildPiece45 = AddLightPiece("CL_Hanging_Orange"); buildPiece45.RequiredItems.Add("Uncut_Orange_Stone", 5, recover: true); buildPiece45.RequiredItems.Add("IronNails", 2, recover: true); buildPiece45.Crafting.Set(PieceManager.CraftingTable.None); buildPiece45.Category.Set(BuildPieceCategory.Misc); BuildPiece buildPiece46 = AddLightPiece("CL_Hanging_Purple"); buildPiece46.RequiredItems.Add("Uncut_Purple_Stone", 5, recover: true); buildPiece46.RequiredItems.Add("IronNails", 2, recover: true); buildPiece46.Crafting.Set(PieceManager.CraftingTable.None); buildPiece46.Category.Set(BuildPieceCategory.Misc); BuildPiece buildPiece47 = AddLightPiece("CL_Hanging_Red"); buildPiece47.RequiredItems.Add("Uncut_Red_Stone", 5, recover: true); buildPiece47.RequiredItems.Add("IronNails", 2, recover: true); buildPiece47.Crafting.Set(PieceManager.CraftingTable.None); buildPiece47.Category.Set(BuildPieceCategory.Misc); BuildPiece buildPiece48 = AddLightPiece("CL_Hanging_Yellow"); buildPiece48.RequiredItems.Add("Uncut_Yellow_Stone", 5, recover: true); buildPiece48.RequiredItems.Add("IronNails", 2, recover: true); buildPiece48.Crafting.Set(PieceManager.CraftingTable.None); buildPiece48.Category.Set(BuildPieceCategory.Misc); BuildPiece buildPiece49 = AddLightPiece("CL_Pole_Black"); buildPiece49.RequiredItems.Add("Uncut_Black_Stone", 5, recover: true); buildPiece49.RequiredItems.Add("Iron", 2, recover: true); buildPiece49.Crafting.Set(PieceManager.CraftingTable.None); buildPiece49.Category.Set(BuildPieceCategory.Misc); BuildPiece buildPiece50 = AddLightPiece("CL_Pole_White"); buildPiece50.RequiredItems.Add("Uncut_Black_Stone", 5, recover: true); buildPiece50.RequiredItems.Add("Iron", 2, recover: true); buildPiece50.Crafting.Set(PieceManager.CraftingTable.None); buildPiece50.Category.Set(BuildPieceCategory.Misc); BuildPiece buildPiece51 = AddLightPiece("CL_Pole_Blue"); buildPiece51.RequiredItems.Add("Uncut_Blue_Stone", 5, recover: true); buildPiece51.RequiredItems.Add("Iron", 2, recover: true); buildPiece51.Crafting.Set(PieceManager.CraftingTable.None); buildPiece51.Category.Set(BuildPieceCategory.Misc); BuildPiece buildPiece52 = AddLightPiece("CL_Pole_Green"); buildPiece52.RequiredItems.Add("Uncut_Green_Stone", 5, recover: true); buildPiece52.RequiredItems.Add("Iron", 2, recover: true); buildPiece52.Crafting.Set(PieceManager.CraftingTable.None); buildPiece52.Category.Set(BuildPieceCategory.Misc); BuildPiece buildPiece53 = AddLightPiece("CL_Pole_Orange"); buildPiece53.RequiredItems.Add("Uncut_Orange_Stone", 5, recover: true); buildPiece53.RequiredItems.Add("Iron", 2, recover: true); buildPiece53.Crafting.Set(PieceManager.CraftingTable.None); buildPiece53.Category.Set(BuildPieceCategory.Misc); BuildPiece buildPiece54 = AddLightPiece("CL_Pole_Purple"); buildPiece54.RequiredItems.Add("Uncut_Purple_Stone", 5, recover: true); buildPiece54.RequiredItems.Add("Iron", 2, recover: true); buildPiece54.Crafting.Set(PieceManager.CraftingTable.None); buildPiece54.Category.Set(BuildPieceCategory.Misc); BuildPiece buildPiece55 = AddLightPiece("CL_Pole_Red"); buildPiece55.RequiredItems.Add("Uncut_Red_Stone", 5, recover: true); buildPiece55.RequiredItems.Add("Iron", 2, recover: true); buildPiece55.Crafting.Set(PieceManager.CraftingTable.None); buildPiece55.Category.Set(BuildPieceCategory.Misc); BuildPiece buildPiece56 = AddLightPiece("CL_Pole_Yellow"); buildPiece56.RequiredItems.Add("Uncut_Yellow_Stone", 5, recover: true); buildPiece56.RequiredItems.Add("Iron", 2, recover: true); buildPiece56.Crafting.Set(PieceManager.CraftingTable.None); buildPiece56.Category.Set(BuildPieceCategory.Misc); BuildPiece buildPiece57 = AddLightPiece("CL_Raw_Black"); buildPiece57.RequiredItems.Add("Uncut_Black_Stone", 5, recover: true); buildPiece57.Crafting.Set(PieceManager.CraftingTable.None); buildPiece57.Category.Set(BuildPieceCategory.Misc); BuildPiece buildPiece58 = AddLightPiece("CL_Raw_White"); buildPiece58.RequiredItems.Add("Uncut_Black_Stone", 5, recover: true); buildPiece58.Crafting.Set(PieceManager.CraftingTable.None); buildPiece58.Category.Set(BuildPieceCategory.Misc); BuildPiece buildPiece59 = AddLightPiece("CL_Raw_Blue"); buildPiece59.RequiredItems.Add("Uncut_Blue_Stone", 5, recover: true); buildPiece59.Crafting.Set(PieceManager.CraftingTable.None); buildPiece59.Category.Set("Misc"); BuildPiece buildPiece60 = AddLightPiece("CL_Raw_Green"); buildPiece60.RequiredItems.Add("Uncut_Green_Stone", 5, recover: true); buildPiece60.Crafting.Set(PieceManager.CraftingTable.None); buildPiece60.Category.Set("Misc"); BuildPiece buildPiece61 = AddLightPiece("CL_Raw_Orange"); buildPiece61.RequiredItems.Add("Uncut_Orange_Stone", 5, recover: true); buildPiece61.Crafting.Set(PieceManager.CraftingTable.None); buildPiece61.Category.Set("Misc"); BuildPiece buildPiece62 = AddLightPiece("CL_Raw_Purple"); buildPiece62.RequiredItems.Add("Uncut_Purple_Stone", 5, recover: true); buildPiece62.Crafting.Set(PieceManager.CraftingTable.None); buildPiece62.Category.Set("Misc"); BuildPiece buildPiece63 = AddLightPiece("CL_Raw_Red"); buildPiece63.RequiredItems.Add("Uncut_Red_Stone", 5, recover: true); buildPiece63.Crafting.Set(PieceManager.CraftingTable.None); buildPiece63.Category.Set("Misc"); BuildPiece buildPiece64 = AddLightPiece("CL_Raw_Yellow"); buildPiece64.RequiredItems.Add("Uncut_Yellow_Stone", 5, recover: true); buildPiece64.Crafting.Set(PieceManager.CraftingTable.None); buildPiece64.Category.Set("Misc"); BuildPiece buildPiece65 = AddLightPiece("CL_Standing_Torch_Black"); buildPiece65.RequiredItems.Add("Uncut_Black_Stone", 1, recover: true); buildPiece65.RequiredItems.Add("Wood", 2, recover: true); buildPiece65.Crafting.Set(PieceManager.CraftingTable.None); buildPiece65.Category.Set("Misc"); BuildPiece buildPiece66 = AddLightPiece("CL_Standing_Torch_White"); buildPiece66.RequiredItems.Add("Uncut_Black_Stone", 1, recover: true); buildPiece66.RequiredItems.Add("Wood", 2, recover: true); buildPiece66.Crafting.Set(PieceManager.CraftingTable.None); buildPiece66.Category.Set("Misc"); BuildPiece buildPiece67 = AddLightPiece("CL_Standing_Torch_Blue"); buildPiece67.RequiredItems.Add("Uncut_Blue_Stone", 1, recover: true); buildPiece67.RequiredItems.Add("Wood", 2, recover: true); buildPiece67.Crafting.Set(PieceManager.CraftingTable.None); buildPiece67.Category.Set("Misc"); BuildPiece buildPiece68 = AddLightPiece("CL_Standing_Torch_Green"); buildPiece68.RequiredItems.Add("Uncut_Green_Stone", 1, recover: true); buildPiece68.RequiredItems.Add("Wood", 2, recover: true); buildPiece68.Crafting.Set(PieceManager.CraftingTable.None); buildPiece68.Category.Set("Misc"); BuildPiece buildPiece69 = AddLightPiece("CL_Standing_Torch_Orange"); buildPiece69.RequiredItems.Add("Uncut_Orange_Stone", 1, recover: true); buildPiece69.RequiredItems.Add("Wood", 2, recover: true); buildPiece69.Crafting.Set(PieceManager.CraftingTable.None); buildPiece69.Category.Set("Misc"); BuildPiece buildPiece70 = AddLightPiece("CL_Standing_Torch_Purple"); buildPiece70.RequiredItems.Add("Uncut_Purple_Stone", 1, recover: true); buildPiece70.RequiredItems.Add("Wood", 2, recover: true); buildPiece70.Crafting.Set(PieceManager.CraftingTable.None); buildPiece70.Category.Set("Misc"); BuildPiece buildPiece71 = AddLightPiece("CL_Standing_Torch_Red"); buildPiece71.RequiredItems.Add("Uncut_Red_Stone", 1, recover: true); buildPiece71.RequiredItems.Add("Wood", 2, recover: true); buildPiece71.Crafting.Set(PieceManager.CraftingTable.None); buildPiece71.Category.Set("Misc"); BuildPiece buildPiece72 = AddLightPiece("CL_Standing_Torch_Yellow"); buildPiece72.RequiredItems.Add("Uncut_Yellow_Stone", 1, recover: true); buildPiece72.RequiredItems.Add("Wood", 2, recover: true); buildPiece72.Crafting.Set(PieceManager.CraftingTable.None); buildPiece72.Category.Set("Misc"); Assembly executingAssembly = Assembly.GetExecutingAssembly(); Harmony val = new Harmony("org.bepinex.plugins.crystallights"); val.PatchAll(executingAssembly); } private BuildPiece AddLightPiece(string prefabName) { //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Expected O, but got Unknown BuildPiece light = new BuildPiece(assets, prefabName); light.Tool.Add("CL_Crystal_Hammer"); string name = light.Prefab.GetComponent<Piece>().m_name; name = new Regex("['[\"\\]]").Replace(english.Localize(name), "").Trim(); string category = Localization.instance.Localize(name).Trim(); lightIntensities.Add(prefabName, config(name, "Light Range", light.Prefab.GetComponentInChildren<Light>().range, new ConfigDescription("The range of the light emitted by " + english.Localize(prefabName) + ".", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Category = category } }))); lightIntensities[prefabName].SettingChanged += delegate { SetLightRange(light.Prefab); }; SetLightRange(light.Prefab); return light; } private void SetLightRange(GameObject lightPrefab) { Light[] componentsInChildren = lightPrefab.GetComponentsInChildren<Light>(); foreach (Light val in componentsInChildren) { val.range = lightIntensities[((Object)lightPrefab).name].Value; } } } } namespace Microsoft.CodeAnalysis { [<b89b921d-8954-4084-bd4d-1feb826a594e>Embedded] [CompilerGenerated] internal sealed class <b89b921d-8954-4084-bd4d-1feb826a594e>EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] [<b89b921d-8954-4084-bd4d-1feb826a594e>Embedded] [CompilerGenerated] 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; } } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] [CompilerGenerated] [<b89b921d-8954-4084-bd4d-1feb826a594e>Embedded] 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 { [<bb5e3e5e-5c47-485a-88ef-ea5afd7f01c7>NullableContext(1)] [PublicAPI] [<f6f8ff5f-fa45-43ba-9489-b740a9e7c98b>Nullable(0)] 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 Microsoft.CodeAnalysis { [CompilerGenerated] [<b751454f-1e4c-43e3-b4fa-78c6ba3665a5>Embedded] internal sealed class <b751454f-1e4c-43e3-b4fa-78c6ba3665a5>EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [<b751454f-1e4c-43e3-b4fa-78c6ba3665a5>Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class <55c92cd9-c900-47f5-906d-8d1fb5836d4d>NullableAttribute : Attribute { public readonly byte[] NullableFlags; public <55c92cd9-c900-47f5-906d-8d1fb5836d4d>NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public <55c92cd9-c900-47f5-906d-8d1fb5836d4d>NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [<b751454f-1e4c-43e3-b4fa-78c6ba3665a5>Embedded] [CompilerGenerated] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class <e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContextAttribute : Attribute { public readonly byte Flag; public <e6d51a72-4ccf-4b15-b647-7d6da1ea6470>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)] [<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(0)] [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(1)] 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 { [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(1)] public static void Deconstruct<[<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] TKey, [<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] TValue>([<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(new byte[] { 0, 1, 1 })] this KeyValuePair<TKey, TValue> pair, out TKey key, out TValue value) { key = pair.Key; value = pair.Value; } } } namespace YamlDotNet { [<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(0)] [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(1)] internal sealed class CultureInfoAdapter : CultureInfo { private readonly IFormatProvider provider; public CultureInfoAdapter(CultureInfo baseCulture, IFormatProvider provider) : base(baseCulture.LCID) { this.provider = provider; } [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(2)] public override object GetFormat(Type formatType) { return provider.GetFormat(formatType); } } [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(1)] [<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(0)] internal static class ReflectionExtensions { [<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] private static readonly FieldInfo RemoteStackTraceField = typeof(Exception).GetField("_remoteStackTraceString", BindingFlags.Instance | BindingFlags.NonPublic); [return: <55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] 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); } [return: <55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] public static PropertyInfo GetPublicProperty(this Type type, string name) { return type.GetProperty(name); } [return: <55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] 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([<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(0)] (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 + "'."); } [return: <55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] public static MethodInfo GetPublicStaticMethod(this Type type, string name, params Type[] parameterTypes) { return type.GetMethod(name, BindingFlags.Static | BindingFlags.Public, null, parameterTypes, null); } [return: <55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] 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<[<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] TAttribute>(this PropertyInfo property) { return Attribute.GetCustomAttributes(property, typeof(TAttribute)); } } internal static class PropertyInfoExtensions { [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(1)] [return: <55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] 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 { [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(1)] [<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(0)] internal abstract class BuilderSkeleton<[<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(0)] 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<[<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] 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) { if (typeConverter == null) { throw new ArgumentNullException("typeConverter"); } if (where == null) { throw new ArgumentNullException("where"); } where(typeConverterFactories.CreateRegistrationLocationSelector(typeConverter.GetType(), (Nothing _) => typeConverter)); return Self; } public TBuilder WithTypeConverter<[<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(0)] TYamlTypeConverter>(WrapperFactory<IYamlTypeConverter, IYamlTypeConverter> typeConverterFactory, Action<ITrackingRegistrationLocationSelectionSyntax<IYamlTypeConverter>> where) where TYamlTypeConverter : IYamlTypeConverter { if (typeConverterFactory == null) { throw new ArgumentNullException("typeConverterFactory"); } if (where == null) { throw new ArgumentNullException("where"); } where(typeConverterFactories.CreateTrackingRegistrationLocationSelector(typeof(TYamlTypeConverter), (IYamlTypeConverter wrapped, Nothing _) => typeConverterFactory(wrapped))); return Self; } public TBuilder WithoutTypeConverter<[<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(0)] 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<[<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(0)] TTypeInspector>(Func<ITypeInspector, TTypeInspector> typeInspectorFactory) where TTypeInspector : ITypeInspector { return WithTypeInspector(typeInspectorFactory, delegate(IRegistrationLocationSelectionSyntax<ITypeInspector> w) { w.OnTop(); }); } public TBuilder WithTypeInspector<[<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(0)] TTypeInspector>(Func<ITypeInspector, TTypeInspector> typeInspectorFactory, Action<IRegistrationLocationSelectionSyntax<ITypeInspector>> where) where TTypeInspector : ITypeInspector { if (typeInspectorFactory == null) { throw new ArgumentNullException("typeInspectorFactory"); } if (where == null) { throw new ArgumentNullException("where"); } where(typeInspectorFactories.CreateRegistrationLocationSelector(typeof(TTypeInspector), (ITypeInspector inner) => typeInspectorFactory(inner))); return Self; } public TBuilder WithTypeInspector<[<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(0)] TTypeInspector>(WrapperFactory<ITypeInspector, ITypeInspector, TTypeInspector> typeInspectorFactory, Action<ITrackingRegistrationLocationSelectionSyntax<ITypeInspector>> where) where TTypeInspector : ITypeInspector { if (typeInspectorFactory == null) { throw new ArgumentNullException("typeInspectorFactory"); } if (where == null) { throw new ArgumentNullException("where"); } where(typeInspectorFactories.CreateTrackingRegistrationLocationSelector(typeof(TTypeInspector), (ITypeInspector wrapped, ITypeInspector inner) => typeInspectorFactory(wrapped, inner))); return Self; } public TBuilder WithoutTypeInspector<[<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(0)] 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<[<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] TComponentBase, TComponent>(TComponentBase wrapped) where TComponent : TComponentBase; internal delegate TComponent WrapperFactory<[<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] TArgument, [<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] TComponentBase, TComponent>(TComponentBase wrapped, TArgument argument) where TComponent : TComponentBase; [Flags] internal enum DefaultValuesHandling { Preserve = 0, OmitNull = 1, OmitDefaults = 2, OmitEmptyCollections = 4 } [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(1)] [<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(0)] 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<[<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] T>(string input) { using StringReader input2 = new StringReader(input); return Deserialize<T>(input2); } public T Deserialize<[<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] T>(TextReader input) { return Deserialize<T>(new Parser(input)); } [return: <55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] public object Deserialize(TextReader input) { return Deserialize(input, typeof(object)); } [return: <55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] public object Deserialize(string input, Type type) { using StringReader input2 = new StringReader(input); return Deserialize(input2, type); } [return: <55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] public object Deserialize(TextReader input, Type type) { return Deserialize(new Parser(input), type); } public T Deserialize<[<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] T>(IParser parser) { return (T)Deserialize(parser, typeof(T)); } [return: <55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] public object Deserialize(IParser parser) { return Deserialize(parser, typeof(object)); } [return: <55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] 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; } } [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(1)] [<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(new byte[] { 0, 1 })] 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) { if (objectFactory == null) { throw new ArgumentNullException("objectFactory"); } this.objectFactory = new Lazy<IObjectFactory>(() => objectFactory, 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) { if (nodeDeserializer == null) { throw new ArgumentNullException("nodeDeserializer"); } if (where == null) { throw new ArgumentNullException("where"); } where(nodeDeserializerFactories.CreateRegistrationLocationSelector(nodeDeserializer.GetType(), (Nothing _) => nodeDeserializer)); return this; } public DeserializerBuilder WithNodeDeserializer<[<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(0)] TNodeDeserializer>(WrapperFactory<INodeDeserializer, TNodeDeserializer> nodeDeserializerFactory, Action<ITrackingRegistrationLocationSelectionSyntax<INodeDeserializer>> where) where TNodeDeserializer : INodeDeserializer { if (nodeDeserializerFactory == null) { throw new ArgumentNullException("nodeDeserializerFactory"); } if (where == null) { throw new ArgumentNullException("where"); } where(nodeDeserializerFactories.CreateTrackingRegistrationLocationSelector(typeof(TNodeDeserializer), (INodeDeserializer wrapped, Nothing _) => nodeDeserializerFactory(wrapped))); return this; } public DeserializerBuilder WithoutNodeDeserializer<[<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(0)] 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) { if (nodeTypeResolver == null) { throw new ArgumentNullException("nodeTypeResolver"); } if (where == null) { throw new ArgumentNullException("where"); } where(nodeTypeResolverFactories.CreateRegistrationLocationSelector(nodeTypeResolver.GetType(), (Nothing _) => nodeTypeResolver)); return this; } public DeserializerBuilder WithNodeTypeResolver<[<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(0)] TNodeTypeResolver>(WrapperFactory<INodeTypeResolver, TNodeTypeResolver> nodeTypeResolverFactory, Action<ITrackingRegistrationLocationSelectionSyntax<INodeTypeResolver>> where) where TNodeTypeResolver : INodeTypeResolver { if (nodeTypeResolverFactory == null) { throw new ArgumentNullException("nodeTypeResolverFactory"); } if (where == null) { throw new ArgumentNullException("where"); } where(nodeTypeResolverFactories.CreateTrackingRegistrationLocationSelector(typeof(TNodeTypeResolver), (INodeTypeResolver wrapped, Nothing _) => nodeTypeResolverFactory(wrapped))); return this; } public DeserializerBuilder WithoutNodeTypeResolver<[<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(0)] 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 var 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<[<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] TInterface, [<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(0)] 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())); } } [<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(0)] [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(1)] 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<[<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(0)] T>() where T : IObjectGraphVisitor<Nothing> { return preProcessingPhaseVisitors.OfType<T>().Single(); } } [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(1)] [<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(0)] 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; } [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(1)] 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; } [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(1)] protected ObjectEventInfo(IObjectDescriptor source) : base(source) { } } [<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(0)] [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(1)] 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; } [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(1)] public MappingStartEventInfo(IObjectDescriptor source) : base(source) { } } internal sealed class MappingEndEventInfo : EventInfo { [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(1)] public MappingEndEventInfo(IObjectDescriptor source) : base(source) { } } internal sealed class SequenceStartEventInfo : ObjectEventInfo { public bool IsImplicit { get; set; } public SequenceStyle Style { get; set; } [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(1)] public SequenceStartEventInfo(IObjectDescriptor source) : base(source) { } } internal sealed class SequenceEndEventInfo : EventInfo { [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(1)] public SequenceEndEventInfo(IObjectDescriptor source) : base(source) { } } [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(1)] internal interface IAliasProvider { AnchorName GetAlias(object target); } [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(1)] internal interface IDeserializer { T Deserialize<[<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] T>(string input); T Deserialize<[<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] T>(TextReader input); [return: <55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] object Deserialize(TextReader input); [return: <55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] object Deserialize(string input, Type type); [return: <55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] object Deserialize(TextReader input, Type type); T Deserialize<[<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] T>(IParser parser); [return: <55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] object Deserialize(IParser parser); [return: <55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] object Deserialize(IParser parser, Type type); } [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(1)] 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); } [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(1)] internal interface INamingConvention { string Apply(string value); } [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(1)] internal interface INodeDeserializer { bool Deserialize(IParser reader, Type expectedType, [<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(new byte[] { 1, 1, 1, 2 })] Func<IParser, Type, object> nestedObjectDeserializer, [<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] out object value); } [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(1)] internal interface INodeTypeResolver { bool Resolve([<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] NodeEvent nodeEvent, ref Type currentType); } [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(1)] internal interface IObjectDescriptor { [<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] object Value { [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(2)] get; } Type Type { get; } Type StaticType { get; } ScalarStyle ScalarStyle { get; } } internal static class ObjectDescriptorExtensions { [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(1)] 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."); } } [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(1)] internal interface IObjectFactory { object Create(Type type); } [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(1)] internal interface IObjectGraphTraversalStrategy { void Traverse<[<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] TContext>(IObjectDescriptor graph, IObjectGraphVisitor<TContext> visitor, TContext context); } [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(1)] internal interface IObjectGraphVisitor<[<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] 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); } [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(1)] internal interface IPropertyDescriptor { string Name { get; } bool CanWrite { get; } Type Type { get; } [<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] Type TypeOverride { [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(2)] get; [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(2)] set; } int Order { get; set; } ScalarStyle ScalarStyle { get; set; } T GetCustomAttribute<[<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(0)] T>() where T : Attribute; IObjectDescriptor Read(object target); void Write(object target, [<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] object value); } internal interface IRegistrationLocationSelectionSyntax<[<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] 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<[<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] TBaseRegistrationType> { void InsteadOf<TRegistrationType>() where TRegistrationType : TBaseRegistrationType; } [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(1)] 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); } [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(1)] internal interface ITypeInspector { IEnumerable<IPropertyDescriptor> GetProperties(Type type, [<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] object container); IPropertyDescriptor GetProperty(Type type, [<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] object container, string name, [MaybeNullWhen(true)] bool ignoreUnmatched); } [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(1)] internal interface ITypeResolver { Type Resolve(Type staticType, [<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] object actualValue); } [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(1)] internal interface IValueDeserializer { [return: <55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] object DeserializeValue(IParser parser, Type expectedType, SerializerState state, IValueDeserializer nestedObjectDeserializer); } internal interface IValuePromise { [<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(new byte[] { 1, 2 })] event Action<object> ValueAvailable; } [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(2)] internal interface IValueSerializer { void SerializeValue([<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(1)] IEmitter emitter, object value, Type type); } [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(1)] internal interface IYamlConvertible { void Read(IParser parser, Type expectedType, ObjectDeserializer nestedObjectDeserializer); void Write(IEmitter emitter, ObjectSerializer nestedObjectSerializer); } [return: <55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] internal delegate object ObjectDeserializer(Type type); internal delegate void ObjectSerializer(object value, Type type = null); [Obsolete("Please use IYamlConvertible instead")] [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(1)] internal interface IYamlSerializable { void ReadYaml(IParser parser); void WriteYaml(IEmitter emitter); } [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(1)] internal interface IYamlTypeConverter { bool Accepts(Type type); [return: <55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] object ReadYaml(IParser parser, Type type); void WriteYaml(IEmitter emitter, [<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] object value, Type type); } [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(1)] [<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(0)] internal sealed class LazyComponentRegistrationList<[<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] TArgument, [<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] TComponent> : IEnumerable<Func<TArgument, TComponent>>, IEnumerable { [<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(0)] 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; } } [<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(0)] 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; } } [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(0)] private class RegistrationLocationSelector : IRegistrationLocationSelectionSyntax<TComponent> { [<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(1)] private readonly LazyComponentRegistrationList<TArgument, TComponent> registrations; [<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(new byte[] { 1, 0, 0 })] private readonly LazyComponentRegistration newRegistration; [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(1)] public RegistrationLocationSelector(LazyComponentRegistrationList<TArgument, TComponent> registrations, [<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(new byte[] { 1, 0, 0 })] 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); } } [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(0)] private class TrackingRegistrationLocationSelector : ITrackingRegistrationLocationSelectionSyntax<TComponent> { [<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(1)] private readonly LazyComponentRegistrationList<TArgument, TComponent> registrations; [<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(new byte[] { 1, 0, 0 })] private readonly TrackingLazyComponentRegistration newRegistration; [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(1)] public TrackingRegistrationLocationSelector(LazyComponentRegistrationList<TArgument, TComponent> registrations, [<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(new byte[] { 1, 0, 0 })] 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, [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(1)] (TArgument arg) => newRegistration.Factory(innerComponentFactory(arg), arg)); } } [<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(new byte[] { 1, 1, 0, 0 })] 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([<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(0)] (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."); } } [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(2)] 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; } } [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(1)] [<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(0)] internal static class LazyComponentRegistrationListExtensions { public static TComponent BuildComponentChain<[<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] TComponent>(this LazyComponentRegistrationList<TComponent, TComponent> registrations, TComponent innerComponent) { return registrations.InReverseOrder.Aggregate(innerComponent, [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(0)] (TComponent inner, Func<TComponent, TComponent> factory) => factory(inner)); } public static TComponent BuildComponentChain<[<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] TArgument, [<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] TComponent>(this LazyComponentRegistrationList<TArgument, TComponent> registrations, TComponent innerComponent, Func<TComponent, TArgument> argumentBuilder) { return registrations.InReverseOrder.Aggregate(innerComponent, [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(0)] (TComponent inner, Func<TArgument, TComponent> factory) => factory(argumentBuilder(inner))); } public static List<TComponent> BuildComponentList<[<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] TComponent>(this LazyComponentRegistrationList<Nothing, TComponent> registrations) { return registrations.Select([<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(0)] (Func<Nothing, TComponent> factory) => factory(default(Nothing))).ToList(); } public static List<TComponent> BuildComponentList<[<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] TArgument, [<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] TComponent>(this LazyComponentRegistrationList<TArgument, TComponent> registrations, TArgument argument) { return registrations.Select([<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(0)] (Func<TArgument, TComponent> factory) => factory(argument)).ToList(); } } [StructLayout(LayoutKind.Sequential, Size = 1)] internal struct Nothing { } [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(1)] [<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(0)] internal sealed class ObjectDescriptor : IObjectDescriptor { [<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] [field: <55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] public object Value { [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(2)] get; [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(2)] private set; } public Type Type { get; private set; } public Type StaticType { get; private set; } public ScalarStyle ScalarStyle { get; private set; } public ObjectDescriptor([<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] object value, Type type, Type staticType) : this(value, type, staticType, ScalarStyle.Any) { } public ObjectDescriptor([<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] 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); [<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(0)] [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(1)] internal sealed class PropertyDescriptor : IPropertyDescriptor { private readonly IPropertyDescriptor baseDescriptor; public string Name { get; set; } public Type Type => baseDescriptor.Type; [<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] public Type TypeOverride { [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(2)] get { return baseDescriptor.TypeOverride; } [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(2)] 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, [<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] object value) { baseDescriptor.Write(target, value); } public T GetCustomAttribute<[<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(0)] T>() where T : Attribute { return baseDescriptor.GetCustomAttribute<T>(); } public IObjectDescriptor Read(object target) { return baseDescriptor.Read(target); } } [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(1)] [<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(0)] 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, [<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(2)] 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()); } } [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(1)] [<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(new byte[] { 0, 1 })] internal sealed class SerializerBuilder : BuilderSkeleton<SerializerBuilder> { [<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(0)] 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; } [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(2)] public void SerializeValue([<55c92cd9-c900-47f5-906d-8d1fb5836d4d>Nullable(1)] IEmitter emitter, object value, Type type) { 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(new EmittingObjectGraphVisitor(eventEmitter), [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(0)] (IObjectGraphVisitor<IEmitter> inner) => new EmissionPhaseObjectGraphVisitorArgs(inner, eventEmitter, preProcessingPhaseObjectGraphVisitors, typeConverters, NestedObjectSerializer)); traversalStrategy.Traverse(graph, visitor, emitter); [<e6d51a72-4ccf-4b15-b647-7d6da1ea6470>NullableContext(2)] void NestedObjectSerializer(object v, Type t) { SerializeValue(emitter, 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(DefaultValuesObjectGrap