Decompiled source of Jam v1.0.9
Jam/Jam.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.CodeDom; using System.CodeDom.Compiler; using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Collections.Specialized; using System.ComponentModel; using System.Configuration; using System.Data; using System.Data.SqlTypes; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Dynamic; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Linq.Expressions; using System.Numerics; using System.Reflection; using System.Reflection.Emit; using System.Resources; using System.Runtime; using System.Runtime.CompilerServices; using System.Runtime.Diagnostics; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Runtime.Serialization.Configuration; using System.Runtime.Serialization.Diagnostics; using System.Runtime.Serialization.Diagnostics.Application; using System.Runtime.Serialization.Formatters; using System.Runtime.Serialization.Json; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; using System.Xml; using System.Xml.Linq; using System.Xml.Schema; using System.Xml.Serialization; using System.Xml.XPath; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using Common; using HarmonyLib; using JetBrains.Annotations; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using Newtonsoft.Json.Bson; using Newtonsoft.Json.Converters; using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq.JsonPath; using Newtonsoft.Json.Schema; using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Utilities; using ServerSync; using TMPro; using UnityEngine; [assembly: AssemblyFileVersion("1.0.9")] [assembly: Guid("6c679b7e-9f39-4df2-9f8a-717e68fbf0e3")] [assembly: ComVisible(false)] [assembly: AssemblyTrademark("")] [assembly: AssemblyCopyright("Copyright © RandyKnapp 2023")] [assembly: AssemblyProduct("Jam")] [assembly: AssemblyCompany("Randy Knapp Mods")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyDescription("")] [assembly: AssemblyTitle("Jam")] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: CompilationRelaxations(8)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.9.0")] [module: UnverifiableCode] public static class PlayerExtensions { public static ZDO GetZDO(this Player player) { return ((Character)player).m_nview.GetZDO(); } } namespace Common { public class ConfigPositionedElement : MonoBehaviour { public ConfigEntry<TextAnchor> AnchorConfig; public ConfigEntry<Vector2> PositionConfig; protected RectTransform _rt; protected TextAnchor _currentAnchor; public virtual void Awake() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown _rt = (RectTransform)((Component)this).transform; EnsureCorrectPosition(); } public virtual void Update() { EnsureCorrectPosition(); } public virtual void EnsureCorrectPosition() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected I4, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) if (AnchorConfig != null && PositionConfig != null && (_currentAnchor != AnchorConfig.Value || !(_rt.anchoredPosition == PositionConfig.Value))) { _currentAnchor = AnchorConfig.Value; TextAnchor currentAnchor = _currentAnchor; Vector2 val = default(Vector2); switch ((int)currentAnchor) { case 0: { RectTransform rt25 = _rt; RectTransform rt26 = _rt; RectTransform rt27 = _rt; ((Vector2)(ref val))..ctor(0f, 1f); rt27.anchorMax = val; Vector2 pivot = (rt26.anchorMin = val); rt25.pivot = pivot; break; } case 1: { RectTransform rt22 = _rt; RectTransform rt23 = _rt; RectTransform rt24 = _rt; ((Vector2)(ref val))..ctor(0.5f, 1f); rt24.anchorMax = val; Vector2 pivot = (rt23.anchorMin = val); rt22.pivot = pivot; break; } case 2: { RectTransform rt19 = _rt; RectTransform rt20 = _rt; RectTransform rt21 = _rt; ((Vector2)(ref val))..ctor(1f, 1f); rt21.anchorMax = val; Vector2 pivot = (rt20.anchorMin = val); rt19.pivot = pivot; break; } case 3: { RectTransform rt16 = _rt; RectTransform rt17 = _rt; RectTransform rt18 = _rt; ((Vector2)(ref val))..ctor(0f, 0.5f); rt18.anchorMax = val; Vector2 pivot = (rt17.anchorMin = val); rt16.pivot = pivot; break; } case 4: { RectTransform rt13 = _rt; RectTransform rt14 = _rt; RectTransform rt15 = _rt; ((Vector2)(ref val))..ctor(0.5f, 0.5f); rt15.anchorMax = val; Vector2 pivot = (rt14.anchorMin = val); rt13.pivot = pivot; break; } case 5: { RectTransform rt10 = _rt; RectTransform rt11 = _rt; RectTransform rt12 = _rt; ((Vector2)(ref val))..ctor(1f, 0.5f); rt12.anchorMax = val; Vector2 pivot = (rt11.anchorMin = val); rt10.pivot = pivot; break; } case 6: { RectTransform rt7 = _rt; RectTransform rt8 = _rt; RectTransform rt9 = _rt; ((Vector2)(ref val))..ctor(0f, 0f); rt9.anchorMax = val; Vector2 pivot = (rt8.anchorMin = val); rt7.pivot = pivot; break; } case 7: { RectTransform rt4 = _rt; RectTransform rt5 = _rt; RectTransform rt6 = _rt; ((Vector2)(ref val))..ctor(0.5f, 0f); rt6.anchorMax = val; Vector2 pivot = (rt5.anchorMin = val); rt4.pivot = pivot; break; } case 8: { RectTransform rt = _rt; RectTransform rt2 = _rt; RectTransform rt3 = _rt; ((Vector2)(ref val))..ctor(1f, 0f); rt3.anchorMax = val; Vector2 pivot = (rt2.anchorMin = val); rt.pivot = pivot; break; } } _rt.anchoredPosition = PositionConfig.Value; } } } [Serializable] public class RecipeRequirementConfig { public string item = ""; public int amount = 1; } [Serializable] public class RecipeConfig { public string name = ""; public string item = ""; public int amount = 1; public string craftingStation = ""; public int minStationLevel = 1; public bool enabled = true; public string repairStation = ""; public List<RecipeRequirementConfig> resources = new List<RecipeRequirementConfig>(); } [Serializable] public class RecipesConfig { public List<RecipeConfig> recipes = new List<RecipeConfig>(); } public static class GameObjectExtensions { public static RectTransform RectTransform(this GameObject go) { Transform transform = go.transform; return (RectTransform)(object)((transform is RectTransform) ? transform : null); } public static T RequireComponent<T>(this GameObject go) where T : Component { T component = go.GetComponent<T>(); if (!((Object)(object)component == (Object)null)) { return component; } return go.AddComponent<T>(); } } public class GotDestroyed : MonoBehaviour { public void OnDisable() { Debug.LogError((object)("I got destroyed! (" + ((Object)((Component)this).gameObject).name + ")")); Debug.Log((object)Environment.StackTrace); } } public class MultiValueDictionary<TKey, TValue> : Dictionary<TKey, List<TValue>> { public void Add(TKey key, TValue value) { if (!TryGetValue(key, out var value2)) { value2 = new List<TValue>(); Add(key, value2); } value2.Add(value); } public bool ContainsValue(TKey key, TValue value) { if (TryGetValue(key, out var value2)) { return value2.Contains(value); } return false; } public void Remove(TKey key, TValue value) { if (TryGetValue(key, out var value2)) { value2.Remove(value); if (value2.Count <= 0) { Remove(key); } } } public void Merge(MultiValueDictionary<TKey, TValue> toMergeWith) { if (toMergeWith == null) { return; } foreach (KeyValuePair<TKey, List<TValue>> item in toMergeWith) { foreach (TValue item2 in item.Value) { Add(item.Key, item2); } } } public List<TValue> GetValues(TKey key, bool returnEmptySet = false) { if (!TryGetValue(key, out var value) && returnEmptySet) { return new List<TValue>(); } return value; } } public static class PrefabCreator { public static ManualLogSource Logger; public static Dictionary<string, CraftingStation> CraftingStations; public static T RequireComponent<T>(GameObject go) where T : Component { T val = go.GetComponent<T>(); if ((Object)(object)val == (Object)null) { val = go.AddComponent<T>(); } return val; } public static void Reset() { CraftingStations = null; } private static void InitCraftingStations() { if (CraftingStations != null) { return; } CraftingStations = new Dictionary<string, CraftingStation>(); foreach (Recipe recipe in ObjectDB.instance.m_recipes) { if ((Object)(object)recipe.m_craftingStation != (Object)null && !CraftingStations.ContainsKey(((Object)recipe.m_craftingStation).name)) { CraftingStations.Add(((Object)recipe.m_craftingStation).name, recipe.m_craftingStation); } } } public static Recipe CreateRecipe(string name, string itemId, RecipeConfig recipeConfig) { //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Expected O, but got Unknown InitCraftingStations(); GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(itemId); if ((Object)(object)itemPrefab == (Object)null) { ManualLogSource logger = Logger; if (logger != null) { logger.LogWarning((object)("[PrefabCreator] Could not find item prefab (" + itemId + ")")); } return null; } Recipe val = ScriptableObject.CreateInstance<Recipe>(); ((Object)val).name = name; val.m_amount = recipeConfig.amount; val.m_minStationLevel = recipeConfig.minStationLevel; val.m_item = itemPrefab.GetComponent<ItemDrop>(); val.m_enabled = recipeConfig.enabled; if (!string.IsNullOrEmpty(recipeConfig.craftingStation)) { if (!CraftingStations.ContainsKey(recipeConfig.craftingStation)) { ManualLogSource logger2 = Logger; if (logger2 != null) { logger2.LogWarning((object)("[PrefabCreator] Could not find crafting station (" + itemId + "): " + recipeConfig.craftingStation)); } string text = string.Join(", ", CraftingStations.Keys); ManualLogSource logger3 = Logger; if (logger3 != null) { logger3.LogInfo((object)("[PrefabCreator] Available Stations: " + text)); } } else { val.m_craftingStation = CraftingStations[recipeConfig.craftingStation]; } } if (!string.IsNullOrEmpty(recipeConfig.repairStation)) { if (!CraftingStations.ContainsKey(recipeConfig.repairStation)) { ManualLogSource logger4 = Logger; if (logger4 != null) { logger4.LogWarning((object)("[PrefabCreator] Could not find repair station (" + itemId + "): " + recipeConfig.repairStation)); } string text2 = string.Join(", ", CraftingStations.Keys); ManualLogSource logger5 = Logger; if (logger5 != null) { logger5.LogInfo((object)("[PrefabCreator] Available Stations: " + text2)); } } else { val.m_repairStation = CraftingStations[recipeConfig.repairStation]; } } List<Requirement> list = new List<Requirement>(); foreach (RecipeRequirementConfig resource in recipeConfig.resources) { GameObject itemPrefab2 = ObjectDB.instance.GetItemPrefab(resource.item); if ((Object)(object)itemPrefab2 == (Object)null) { ManualLogSource logger6 = Logger; if (logger6 != null) { logger6.LogError((object)("[PrefabCreator] Could not find requirement item (" + itemId + "): " + resource.item)); } } else { list.Add(new Requirement { m_amount = resource.amount, m_resItem = itemPrefab2.GetComponent<ItemDrop>() }); } } val.m_resources = list.ToArray(); return val; } public static Recipe AddNewRecipe(string name, string itemId, RecipeConfig recipeConfig) { Recipe val = CreateRecipe(name, itemId, recipeConfig); if ((Object)(object)val == (Object)null) { ManualLogSource logger = Logger; if (logger != null) { logger.LogError((object)("[PrefabCreator] Failed to create recipe (" + name + ")")); } return null; } return AddNewRecipe(val); } public static Recipe AddNewRecipe(Recipe recipe) { int num = ObjectDB.instance.m_recipes.RemoveAll((Recipe x) => ((Object)x).name == ((Object)recipe).name); if (num > 0) { ManualLogSource logger = Logger; if (logger != null) { logger.LogInfo((object)$"[PrefabCreator] Removed recipe ({((Object)recipe).name}): {num}"); } } ObjectDB.instance.m_recipes.Add(recipe); ManualLogSource logger2 = Logger; if (logger2 != null) { logger2.LogInfo((object)("[PrefabCreator] Added recipe: " + ((Object)recipe).name)); } return recipe; } } [Serializable] public struct SerializableVector3 { public float x; public float y; public float z; public SerializableVector3(float x, float y, float z) { this.x = x; this.y = y; this.z = z; } public void ToPackage(ZPackage pkg) { pkg.Write(x); pkg.Write(y); pkg.Write(z); } public static SerializableVector3 FromPackage(ZPackage pkg) { SerializableVector3 result = default(SerializableVector3); result.x = pkg.ReadSingle(); result.y = pkg.ReadSingle(); result.z = pkg.ReadSingle(); return result; } public override string ToString() { return $"[{x}, {y}, {z}]"; } public static implicit operator Vector3(SerializableVector3 s) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) return new Vector3(s.x, s.y, s.z); } public static implicit operator SerializableVector3(Vector3 v) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) return new SerializableVector3(v.x, v.y, v.z); } public static SerializableVector3 operator +(SerializableVector3 a, SerializableVector3 b) { return new SerializableVector3(a.x + b.x, a.y + b.y, a.z + b.z); } public static SerializableVector3 operator -(SerializableVector3 a, SerializableVector3 b) { return new SerializableVector3(a.x - b.x, a.y - b.y, a.z - b.z); } public static SerializableVector3 operator -(SerializableVector3 a) { return new SerializableVector3(0f - a.x, 0f - a.y, 0f - a.z); } public static SerializableVector3 operator *(SerializableVector3 a, float m) { return new SerializableVector3(a.x * m, a.y * m, a.z * m); } public static SerializableVector3 operator *(float m, SerializableVector3 a) { return new SerializableVector3(a.x * m, a.y * m, a.z * m); } public static SerializableVector3 operator /(SerializableVector3 a, float d) { return new SerializableVector3(a.x / d, a.y / d, a.z / d); } } public static class Utils { public static void PrintObject(object o) { if (o == null) { Debug.Log((object)"null"); } else { Debug.Log((object)(o?.ToString() + ":\n" + GetObjectString(o, " "))); } } public static string GetObjectString(object obj, string indent) { string text = ""; foreach (FieldInfo item in from f in obj.GetType().GetFields() where f.IsPublic select f) { object value = item.GetValue(obj); string text2 = ((value == null) ? "null" : value.ToString()); text = text + "\n" + indent + item.Name + ": " + text2; } return text; } public static Sprite LoadSpriteFromFile(string spritePath) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) spritePath = Path.Combine(Paths.PluginPath, spritePath); if (File.Exists(spritePath)) { byte[] array = File.ReadAllBytes(spritePath); Texture2D val = new Texture2D(20, 20); if (ImageConversion.LoadImage(val, array)) { return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), default(Vector2), 100f); } } return null; } public static Sprite LoadSpriteFromFile(string modFolder, string iconName) { return LoadSpriteFromFile(Path.Combine(modFolder, iconName)); } public static string RemoveBetween(string s, string from, string to) { int num = 0; while (num >= 0) { num = s.IndexOf(from, StringComparison.InvariantCulture); if (num < 0) { break; } int num2 = s.IndexOf(to, num, StringComparison.InvariantCulture); if (num2 < 0) { break; } s = s.Remove(num, num2 - num + to.Length); } return s; } public static void CopyFields(object originalObject, object cloneObject, Type typeToReflect, BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.Public) { FieldInfo[] fields = typeToReflect.GetFields(bindingFlags); foreach (FieldInfo obj in fields) { object value = obj.GetValue(originalObject); obj.SetValue(cloneObject, value); } } public static bool IsServer() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Invalid comparison between Unknown and I4 if (!ZNet.instance.IsServer() && !ZNet.instance.IsDedicated()) { return (int)SystemInfo.graphicsDeviceType == 4; } return true; } } public static class ArrayUtils { public static bool IsNullOrEmpty<T>(T[] a) { if (a != null) { return a.Length == 0; } return true; } public static T[] Copy<T>(T[] other) { return other?.ToArray(); } } public static class ListExtensions { public static bool TryFind<T>(this List<T> list, Predicate<T> predicate, out T result) { int num = list.FindIndex(predicate); if (num != -1) { result = list[num]; return true; } result = default(T); return false; } } public class WeightedRandomCollection<T> { private readonly Random _random; private List<T> _list; private Func<T, float> _weightSelector; private bool _removeOnSelect; public float TotalWeight { get; private set; } public WeightedRandomCollection(Random random) { _random = random; } public WeightedRandomCollection(Random random, IEnumerable<T> collection, Func<T, float> weightSelector, bool removeOnSelect = false) { _random = random ?? new Random(); Setup(collection, weightSelector, removeOnSelect); } public void Setup(IEnumerable<T> collection, Func<T, float> weightSelector, bool removeOnSelect = false) { _list = collection.ToList(); _weightSelector = weightSelector; _removeOnSelect = removeOnSelect; TotalWeight = _list.Sum(_weightSelector); } public T Roll() { if (_list == null) { return default(T); } float num = (float)_random.NextDouble() * TotalWeight; float num2 = 0f; T val = default(T); foreach (var item in _list.Select((T weightedItem) => new { Value = weightedItem, Weight = _weightSelector(weightedItem) })) { num2 += item.Weight; if (num2 >= num) { val = item.Value; break; } } if (_removeOnSelect) { _list.Remove(val); TotalWeight = _list.Sum(_weightSelector); } return val; } public List<T> Roll(int numberOfRolls) { if (_list == null) { return null; } List<T> list = new List<T>(); for (int i = 0; i < numberOfRolls; i++) { T x = Roll(); if (!EqualityComparer<T>.Default.Equals(x, default(T))) { list.Add(Roll()); } } return list; } public void Reset() { _list = null; _weightSelector = null; _removeOnSelect = false; TotalWeight = 0f; } } } namespace Jam { [HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")] public static class ObjectDB_CopyOtherDB_Patch { public static void Postfix() { Jam.TryRegisterItems(); Jam.TryRegisterRecipes(); } } [HarmonyPatch(typeof(ObjectDB), "Awake")] public static class ObjectDB_Awake_Patch { public static void Postfix() { Jam.TryRegisterItems(); Jam.TryRegisterRecipes(); } } public static class RecipesHelper { public static RecipesConfig Config; public static void Initialize(RecipesConfig config) { Config = config; if (Jam.IsObjectDBReady()) { SetupRecipes(); } } public static void SetupRecipes() { PrefabCreator.Reset(); foreach (RecipeConfig recipe in Config.recipes) { PrefabCreator.AddNewRecipe(recipe.name, recipe.item, recipe); } } } [HarmonyPatch(typeof(ZNetScene), "Awake")] public static class ZNetScene_Awake_Patch { public static bool Prefix(ZNetScene __instance) { Jam.TryRegisterPrefabs(__instance); return true; } } [BepInPlugin("randyknapp.mods.jam", "Jam", "1.0.9")] public class Jam : BaseUnityPlugin { public const string PluginId = "randyknapp.mods.jam"; public const string DisplayName = "Jam"; public const string Version = "1.0.9"; private readonly ConfigSync _configSync = new ConfigSync("randyknapp.mods.jam") { DisplayName = "Jam", CurrentVersion = "1.0.9", MinimumRequiredVersion = "1.0.9" }; private static ConfigEntry<bool> _serverConfigLocked; private static Jam _instance; private Harmony _harmony; public static readonly Dictionary<string, GameObject> Prefabs = new Dictionary<string, GameObject>(); public static Dictionary<string, CustomSyncedValue<string>> SyncedJsonFiles = new Dictionary<string, CustomSyncedValue<string>>(); [UsedImplicitly] public void Awake() { _instance = this; PrefabCreator.Logger = ((BaseUnityPlugin)this).Logger; _serverConfigLocked = SyncedConfig("Config Sync", "Lock Config", value: false, "[Server Only] The configuration is locked and may not be changed by clients once it has been synced from the server. Only valid for server config, will have no effect on clients."); _configSync.AddLockingConfigEntry<bool>(_serverConfigLocked); AssetBundle val = LoadAssetBundle("jamassets"); if ((Object)(object)val != (Object)null) { GameObject[] array = val.LoadAllAssets<GameObject>(); foreach (GameObject val2 in array) { Prefabs.Add(((Object)val2).name, val2); } } LoadJsonFile<RecipesConfig>("recipes.json", RecipesHelper.Initialize); if (val != null) { val.Unload(false); } _harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "randyknapp.mods.jam"); } public static string LoadJsonText(string filename) { string assetPath = GetAssetPath(filename); if (string.IsNullOrEmpty(assetPath)) { return null; } return File.ReadAllText(assetPath); } public static void LoadJsonFile<T>(string filename, Action<T> onFileLoad, bool update = false) where T : class { string text = LoadJsonText(filename); if (!update) { SyncedJsonFiles.Add(filename, new CustomSyncedValue<string>(_instance._configSync, filename, text)); } SyncedJsonFiles[filename].ValueChanged += Process; Process(); if (text != null) { string assetPath = GetAssetPath(filename); string directoryName = Path.GetDirectoryName(assetPath); if (directoryName != null) { FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(directoryName, Path.GetFileName(assetPath)); fileSystemWatcher.Changed += ConsumeConfigFileEvent; fileSystemWatcher.Created += ConsumeConfigFileEvent; fileSystemWatcher.Renamed += ConsumeConfigFileEvent; fileSystemWatcher.IncludeSubdirectories = true; fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject; fileSystemWatcher.EnableRaisingEvents = true; } } void ConsumeConfigFileEvent(object s, FileSystemEventArgs e) { SyncedJsonFiles[filename].AssignLocalValue(LoadJsonText(filename)); } void Process() { T obj; try { obj = (string.IsNullOrEmpty(SyncedJsonFiles[filename].Value) ? null : JsonConvert.DeserializeObject<T>(SyncedJsonFiles[filename].Value)); } catch (Exception) { LogError("Could not parse file '" + filename + "'! Errors in JSON!"); throw; } onFileLoad(obj); } } public static void LogError(string message) { ((BaseUnityPlugin)_instance).Logger.LogError((object)message); } public static AssetBundle LoadAssetBundle(string filename) { Assembly callingAssembly = Assembly.GetCallingAssembly(); return AssetBundle.LoadFromStream(callingAssembly.GetManifestResourceStream(callingAssembly.GetName().Name + "." + filename)); } public static string GenerateAssetPathAtAssembly(string assetName) { return Path.Combine(Path.GetDirectoryName(typeof(Jam).Assembly.Location) ?? string.Empty, assetName); } public static string GetAssetPath(string assetName) { string text = Path.Combine(Paths.PluginPath, "Jam", assetName); if (!File.Exists(text)) { text = GenerateAssetPathAtAssembly(assetName); if (!File.Exists(text)) { ((BaseUnityPlugin)_instance).Logger.LogError((object)("Could not find asset (" + assetName + ")")); return null; } } return text; } public ConfigEntry<T> SyncedConfig<T>(string group, string configName, T value, string description, bool synchronizedSetting = true) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown ConfigEntry<T> val = ((BaseUnityPlugin)this).Config.Bind<T>(group, configName, value, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>())); _configSync.AddConfigEntry<T>(val).SynchronizedConfig = synchronizedSetting; return val; } [UsedImplicitly] public void OnDestroy() { _instance = null; } public static void TryRegisterPrefabs(ZNetScene zNetScene) { if ((Object)(object)zNetScene == (Object)null) { return; } foreach (GameObject value in Prefabs.Values) { zNetScene.m_prefabs.Add(value); } } public static bool IsObjectDBReady() { if ((Object)(object)ObjectDB.instance != (Object)null && ObjectDB.instance.m_items.Count != 0) { return (Object)(object)ObjectDB.instance.GetItemPrefab("Amber") != (Object)null; } return false; } public static void TryRegisterItems() { if (!IsObjectDBReady()) { return; } foreach (GameObject value in Prefabs.Values) { ItemDrop component = value.GetComponent<ItemDrop>(); if ((Object)(object)component != (Object)null && (Object)(object)ObjectDB.instance.GetItemPrefab(StringExtensionMethods.GetStableHashCode(((Object)value).name)) == (Object)null) { component.m_itemData.m_dropPrefab = value; ObjectDB.instance.m_items.Add(value); } } ObjectDB.instance.UpdateRegisters(); } public static void TryRegisterRecipes() { if (IsObjectDBReady()) { RecipesHelper.SetupRecipes(); } } } } namespace Microsoft.CodeAnalysis { [CompilerGenerated] [<68880fcb-db6f-49ae-af5f-0fac0ec8be1b>Embedded] internal sealed class <68880fcb-db6f-49ae-af5f-0fac0ec8be1b>EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [<68880fcb-db6f-49ae-af5f-0fac0ec8be1b>Embedded] internal sealed class IsReadOnlyAttribute : Attribute { } [CompilerGenerated] [<68880fcb-db6f-49ae-af5f-0fac0ec8be1b>Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class <7590d925-4c58-49ee-8f26-84b08f2a30f8>NullableAttribute : Attribute { public readonly byte[] NullableFlags; public <7590d925-4c58-49ee-8f26-84b08f2a30f8>NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public <7590d925-4c58-49ee-8f26-84b08f2a30f8>NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [<68880fcb-db6f-49ae-af5f-0fac0ec8be1b>Embedded] [CompilerGenerated] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class <71712b87-457a-4b7a-bfec-5496a9d76840>NullableContextAttribute : Attribute { public readonly byte Flag; public <71712b87-457a-4b7a-bfec-5496a9d76840>NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace System.Diagnostics.CodeAnalysis { [AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = true)] internal sealed class NotNullAttribute : Attribute { } [AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false)] internal sealed class NotNullWhenAttribute : Attribute { public bool ReturnValue { get; } public NotNullWhenAttribute(bool returnValue) { ReturnValue = returnValue; } } [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, Inherited = false)] internal sealed class MaybeNullAttribute : Attribute { } [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)] internal sealed class AllowNullAttribute : Attribute { } [AttributeUsage(AttributeTargets.Parameter, Inherited = false)] internal class DoesNotReturnIfAttribute : Attribute { public bool ParameterValue { get; } public DoesNotReturnIfAttribute(bool parameterValue) { ParameterValue = parameterValue; } } } namespace Newtonsoft.Json { internal enum ConstructorHandling { Default, AllowNonPublicDefaultConstructor } internal enum DateFormatHandling { IsoDateFormat, MicrosoftDateFormat } internal enum DateParseHandling { None, DateTime, DateTimeOffset } internal enum DateTimeZoneHandling { Local, Utc, Unspecified, RoundtripKind } [<71712b87-457a-4b7a-bfec-5496a9d76840>NullableContext(1)] [<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(0)] internal class DefaultJsonNameTable : JsonNameTable { [<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(0)] private class Entry { internal readonly string Value; internal readonly int HashCode; internal Entry Next; internal Entry(string value, int hashCode, Entry next) { Value = value; HashCode = hashCode; Next = next; } } private static readonly int HashCodeRandomizer; private int _count; private Entry[] _entries; private int _mask = 31; static DefaultJsonNameTable() { HashCodeRandomizer = Environment.TickCount; } public DefaultJsonNameTable() { _entries = new Entry[_mask + 1]; } [return: <7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(2)] public override string Get(char[] key, int start, int length) { if (length == 0) { return string.Empty; } int num = length + HashCodeRandomizer; num += (num << 7) ^ key[start]; int num2 = start + length; for (int i = start + 1; i < num2; i++) { num += (num << 7) ^ key[i]; } num -= num >> 17; num -= num >> 11; num -= num >> 5; int num3 = Volatile.Read(ref _mask); int num4 = num & num3; for (Entry entry = _entries[num4]; entry != null; entry = entry.Next) { if (entry.HashCode == num && TextEquals(entry.Value, key, start, length)) { return entry.Value; } } return null; } public string Add(string key) { if (key == null) { throw new ArgumentNullException("key"); } int length = key.Length; if (length == 0) { return string.Empty; } int num = length + HashCodeRandomizer; for (int i = 0; i < key.Length; i++) { num += (num << 7) ^ key[i]; } num -= num >> 17; num -= num >> 11; num -= num >> 5; for (Entry entry = _entries[num & _mask]; entry != null; entry = entry.Next) { if (entry.HashCode == num && entry.Value.Equals(key, StringComparison.Ordinal)) { return entry.Value; } } return AddEntry(key, num); } private string AddEntry(string str, int hashCode) { int num = hashCode & _mask; Entry entry = new Entry(str, hashCode, _entries[num]); _entries[num] = entry; if (_count++ == _mask) { Grow(); } return entry.Value; } private void Grow() { Entry[] entries = _entries; int num = _mask * 2 + 1; Entry[] array = new Entry[num + 1]; for (int i = 0; i < entries.Length; i++) { Entry entry = entries[i]; while (entry != null) { int num2 = entry.HashCode & num; Entry next = entry.Next; entry.Next = array[num2]; array[num2] = entry; entry = next; } } _entries = array; Volatile.Write(ref _mask, num); } private static bool TextEquals(string str1, char[] str2, int str2Start, int str2Length) { if (str1.Length != str2Length) { return false; } for (int i = 0; i < str1.Length; i++) { if (str1[i] != str2[str2Start + i]) { return false; } } return true; } } [Flags] internal enum DefaultValueHandling { Include = 0, Ignore = 1, Populate = 2, IgnoreAndPopulate = 3 } internal enum FloatFormatHandling { String, Symbol, DefaultValue } internal enum FloatParseHandling { Double, Decimal } internal enum Formatting { None, Indented } [<71712b87-457a-4b7a-bfec-5496a9d76840>NullableContext(1)] internal interface IArrayPool<[<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(2)] T> { T[] Rent(int minimumLength); void Return([<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(new byte[] { 2, 1 })] T[] array); } internal interface IJsonLineInfo { int LineNumber { get; } int LinePosition { get; } bool HasLineInfo(); } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = false)] internal sealed class JsonArrayAttribute : JsonContainerAttribute { private bool _allowNullItems; public bool AllowNullItems { get { return _allowNullItems; } set { _allowNullItems = value; } } public JsonArrayAttribute() { } public JsonArrayAttribute(bool allowNullItems) { _allowNullItems = allowNullItems; } [<71712b87-457a-4b7a-bfec-5496a9d76840>NullableContext(1)] public JsonArrayAttribute(string id) : base(id) { } } [AttributeUsage(AttributeTargets.Constructor, AllowMultiple = false)] internal sealed class JsonConstructorAttribute : Attribute { } [<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(0)] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = false)] [<71712b87-457a-4b7a-bfec-5496a9d76840>NullableContext(2)] internal abstract class JsonContainerAttribute : Attribute { internal bool? _isReference; internal bool? _itemIsReference; internal ReferenceLoopHandling? _itemReferenceLoopHandling; internal TypeNameHandling? _itemTypeNameHandling; private Type _namingStrategyType; [<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(new byte[] { 2, 1 })] private object[] _namingStrategyParameters; public string Id { get; set; } public string Title { get; set; } public string Description { get; set; } public Type ItemConverterType { get; set; } [<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(new byte[] { 2, 1 })] [field: <7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(new byte[] { 2, 1 })] public object[] ItemConverterParameters { [return: <7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(new byte[] { 2, 1 })] get; [param: <7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(new byte[] { 2, 1 })] set; } public Type NamingStrategyType { get { return _namingStrategyType; } set { _namingStrategyType = value; NamingStrategyInstance = null; } } [<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(new byte[] { 2, 1 })] public object[] NamingStrategyParameters { [return: <7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(new byte[] { 2, 1 })] get { return _namingStrategyParameters; } [param: <7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(new byte[] { 2, 1 })] set { _namingStrategyParameters = value; NamingStrategyInstance = null; } } internal NamingStrategy NamingStrategyInstance { get; set; } public bool IsReference { get { return _isReference.GetValueOrDefault(); } set { _isReference = value; } } public bool ItemIsReference { get { return _itemIsReference.GetValueOrDefault(); } set { _itemIsReference = value; } } public ReferenceLoopHandling ItemReferenceLoopHandling { get { return _itemReferenceLoopHandling.GetValueOrDefault(); } set { _itemReferenceLoopHandling = value; } } public TypeNameHandling ItemTypeNameHandling { get { return _itemTypeNameHandling.GetValueOrDefault(); } set { _itemTypeNameHandling = value; } } protected JsonContainerAttribute() { } [<71712b87-457a-4b7a-bfec-5496a9d76840>NullableContext(1)] protected JsonContainerAttribute(string id) { Id = id; } } [<71712b87-457a-4b7a-bfec-5496a9d76840>NullableContext(1)] [<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(0)] internal static class JsonConvert { public static readonly string True = "true"; public static readonly string False = "false"; public static readonly string Null = "null"; public static readonly string Undefined = "undefined"; public static readonly string PositiveInfinity = "Infinity"; public static readonly string NegativeInfinity = "-Infinity"; public static readonly string NaN = "NaN"; [<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(new byte[] { 2, 1 })] [field: <7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(new byte[] { 2, 1 })] public static Func<JsonSerializerSettings> DefaultSettings { [return: <7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(new byte[] { 2, 1 })] get; [param: <7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(new byte[] { 2, 1 })] set; } public static string ToString(DateTime value) { return ToString(value, DateFormatHandling.IsoDateFormat, DateTimeZoneHandling.RoundtripKind); } public static string ToString(DateTime value, DateFormatHandling format, DateTimeZoneHandling timeZoneHandling) { DateTime value2 = DateTimeUtils.EnsureDateTime(value, timeZoneHandling); using StringWriter stringWriter = StringUtils.CreateStringWriter(64); stringWriter.Write('"'); DateTimeUtils.WriteDateTimeString(stringWriter, value2, format, null, CultureInfo.InvariantCulture); stringWriter.Write('"'); return stringWriter.ToString(); } public static string ToString(DateTimeOffset value) { return ToString(value, DateFormatHandling.IsoDateFormat); } public static string ToString(DateTimeOffset value, DateFormatHandling format) { using StringWriter stringWriter = StringUtils.CreateStringWriter(64); stringWriter.Write('"'); DateTimeUtils.WriteDateTimeOffsetString(stringWriter, value, format, null, CultureInfo.InvariantCulture); stringWriter.Write('"'); return stringWriter.ToString(); } public static string ToString(bool value) { if (!value) { return False; } return True; } public static string ToString(char value) { return ToString(char.ToString(value)); } public static string ToString(Enum value) { return value.ToString("D"); } public static string ToString(int value) { return value.ToString(null, CultureInfo.InvariantCulture); } public static string ToString(short value) { return value.ToString(null, CultureInfo.InvariantCulture); } [CLSCompliant(false)] public static string ToString(ushort value) { return value.ToString(null, CultureInfo.InvariantCulture); } [CLSCompliant(false)] public static string ToString(uint value) { return value.ToString(null, CultureInfo.InvariantCulture); } public static string ToString(long value) { return value.ToString(null, CultureInfo.InvariantCulture); } private static string ToStringInternal(BigInteger value) { return value.ToString(null, CultureInfo.InvariantCulture); } [CLSCompliant(false)] public static string ToString(ulong value) { return value.ToString(null, CultureInfo.InvariantCulture); } public static string ToString(float value) { return EnsureDecimalPlace(value, value.ToString("R", CultureInfo.InvariantCulture)); } internal static string ToString(float value, FloatFormatHandling floatFormatHandling, char quoteChar, bool nullable) { return EnsureFloatFormat(value, EnsureDecimalPlace(value, value.ToString("R", CultureInfo.InvariantCulture)), floatFormatHandling, quoteChar, nullable); } private static string EnsureFloatFormat(double value, string text, FloatFormatHandling floatFormatHandling, char quoteChar, bool nullable) { if (floatFormatHandling == FloatFormatHandling.Symbol || (!double.IsInfinity(value) && !double.IsNaN(value))) { return text; } if (floatFormatHandling == FloatFormatHandling.DefaultValue) { if (nullable) { return Null; } return "0.0"; } return quoteChar + text + quoteChar; } public static string ToString(double value) { return EnsureDecimalPlace(value, value.ToString("R", CultureInfo.InvariantCulture)); } internal static string ToString(double value, FloatFormatHandling floatFormatHandling, char quoteChar, bool nullable) { return EnsureFloatFormat(value, EnsureDecimalPlace(value, value.ToString("R", CultureInfo.InvariantCulture)), floatFormatHandling, quoteChar, nullable); } private static string EnsureDecimalPlace(double value, string text) { if (double.IsNaN(value) || double.IsInfinity(value) || StringUtils.IndexOf(text, '.') != -1 || StringUtils.IndexOf(text, 'E') != -1 || StringUtils.IndexOf(text, 'e') != -1) { return text; } return text + ".0"; } private static string EnsureDecimalPlace(string text) { if (StringUtils.IndexOf(text, '.') != -1) { return text; } return text + ".0"; } public static string ToString(byte value) { return value.ToString(null, CultureInfo.InvariantCulture); } [CLSCompliant(false)] public static string ToString(sbyte value) { return value.ToString(null, CultureInfo.InvariantCulture); } public static string ToString(decimal value) { return EnsureDecimalPlace(value.ToString(null, CultureInfo.InvariantCulture)); } public static string ToString(Guid value) { return ToString(value, '"'); } internal static string ToString(Guid value, char quoteChar) { string text = value.ToString("D", CultureInfo.InvariantCulture); string text2 = quoteChar.ToString(CultureInfo.InvariantCulture); return text2 + text + text2; } public static string ToString(TimeSpan value) { return ToString(value, '"'); } internal static string ToString(TimeSpan value, char quoteChar) { return ToString(value.ToString(), quoteChar); } public static string ToString([<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(2)] Uri value) { if (value == null) { return Null; } return ToString(value, '"'); } internal static string ToString(Uri value, char quoteChar) { return ToString(value.OriginalString, quoteChar); } public static string ToString([<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(2)] string value) { return ToString(value, '"'); } public static string ToString([<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(2)] string value, char delimiter) { return ToString(value, delimiter, StringEscapeHandling.Default); } public static string ToString([<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(2)] string value, char delimiter, StringEscapeHandling stringEscapeHandling) { if (delimiter != '"' && delimiter != '\'') { throw new ArgumentException("Delimiter must be a single or double quote.", "delimiter"); } return JavaScriptUtils.ToEscapedJavaScriptString(value, delimiter, appendDelimiters: true, stringEscapeHandling); } public static string ToString([<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(2)] object value) { if (value == null) { return Null; } return ConvertUtils.GetTypeCode(value.GetType()) switch { PrimitiveTypeCode.String => ToString((string)value), PrimitiveTypeCode.Char => ToString((char)value), PrimitiveTypeCode.Boolean => ToString((bool)value), PrimitiveTypeCode.SByte => ToString((sbyte)value), PrimitiveTypeCode.Int16 => ToString((short)value), PrimitiveTypeCode.UInt16 => ToString((ushort)value), PrimitiveTypeCode.Int32 => ToString((int)value), PrimitiveTypeCode.Byte => ToString((byte)value), PrimitiveTypeCode.UInt32 => ToString((uint)value), PrimitiveTypeCode.Int64 => ToString((long)value), PrimitiveTypeCode.UInt64 => ToString((ulong)value), PrimitiveTypeCode.Single => ToString((float)value), PrimitiveTypeCode.Double => ToString((double)value), PrimitiveTypeCode.DateTime => ToString((DateTime)value), PrimitiveTypeCode.Decimal => ToString((decimal)value), PrimitiveTypeCode.DBNull => Null, PrimitiveTypeCode.DateTimeOffset => ToString((DateTimeOffset)value), PrimitiveTypeCode.Guid => ToString((Guid)value), PrimitiveTypeCode.Uri => ToString((Uri)value), PrimitiveTypeCode.TimeSpan => ToString((TimeSpan)value), PrimitiveTypeCode.BigInteger => ToStringInternal((BigInteger)value), _ => throw new ArgumentException("Unsupported type: {0}. Use the JsonSerializer class to get the object's JSON representation.".FormatWith(CultureInfo.InvariantCulture, value.GetType())), }; } [DebuggerStepThrough] public static string SerializeObject([<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(2)] object value) { return SerializeObject(value, (Type)null, (JsonSerializerSettings)null); } [DebuggerStepThrough] public static string SerializeObject([<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(2)] object value, Formatting formatting) { return SerializeObject(value, formatting, (JsonSerializerSettings)null); } [DebuggerStepThrough] public static string SerializeObject([<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(2)] object value, params JsonConverter[] converters) { JsonSerializerSettings settings = ((converters != null && converters.Length != 0) ? new JsonSerializerSettings { Converters = converters } : null); return SerializeObject(value, null, settings); } [DebuggerStepThrough] public static string SerializeObject([<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(2)] object value, Formatting formatting, params JsonConverter[] converters) { JsonSerializerSettings settings = ((converters != null && converters.Length != 0) ? new JsonSerializerSettings { Converters = converters } : null); return SerializeObject(value, null, formatting, settings); } [DebuggerStepThrough] [<71712b87-457a-4b7a-bfec-5496a9d76840>NullableContext(2)] [return: <7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(1)] public static string SerializeObject(object value, JsonSerializerSettings settings) { return SerializeObject(value, null, settings); } [DebuggerStepThrough] [<71712b87-457a-4b7a-bfec-5496a9d76840>NullableContext(2)] [return: <7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(1)] public static string SerializeObject(object value, Type type, JsonSerializerSettings settings) { JsonSerializer jsonSerializer = JsonSerializer.CreateDefault(settings); return SerializeObjectInternal(value, type, jsonSerializer); } [DebuggerStepThrough] [<71712b87-457a-4b7a-bfec-5496a9d76840>NullableContext(2)] [return: <7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(1)] public static string SerializeObject(object value, Formatting formatting, JsonSerializerSettings settings) { return SerializeObject(value, null, formatting, settings); } [DebuggerStepThrough] [<71712b87-457a-4b7a-bfec-5496a9d76840>NullableContext(2)] [return: <7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(1)] public static string SerializeObject(object value, Type type, Formatting formatting, JsonSerializerSettings settings) { JsonSerializer jsonSerializer = JsonSerializer.CreateDefault(settings); jsonSerializer.Formatting = formatting; return SerializeObjectInternal(value, type, jsonSerializer); } private static string SerializeObjectInternal([<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(2)] object value, [<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(2)] Type type, JsonSerializer jsonSerializer) { StringWriter stringWriter = new StringWriter(new StringBuilder(256), CultureInfo.InvariantCulture); using (JsonTextWriter jsonTextWriter = new JsonTextWriter(stringWriter)) { jsonTextWriter.Formatting = jsonSerializer.Formatting; jsonSerializer.Serialize(jsonTextWriter, value, type); } return stringWriter.ToString(); } [DebuggerStepThrough] [return: <7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(2)] public static object DeserializeObject(string value) { return DeserializeObject(value, (Type)null, (JsonSerializerSettings)null); } [DebuggerStepThrough] [return: <7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(2)] public static object DeserializeObject(string value, JsonSerializerSettings settings) { return DeserializeObject(value, null, settings); } [DebuggerStepThrough] [return: <7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(2)] public static object DeserializeObject(string value, Type type) { return DeserializeObject(value, type, (JsonSerializerSettings)null); } [DebuggerStepThrough] [<71712b87-457a-4b7a-bfec-5496a9d76840>NullableContext(2)] public static T DeserializeObject<T>([<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(1)] string value) { return JsonConvert.DeserializeObject<T>(value, (JsonSerializerSettings)null); } [DebuggerStepThrough] [return: <7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(2)] public static T DeserializeAnonymousType<[<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(2)] T>(string value, T anonymousTypeObject) { return DeserializeObject<T>(value); } [DebuggerStepThrough] [return: <7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(2)] public static T DeserializeAnonymousType<[<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(2)] T>(string value, T anonymousTypeObject, JsonSerializerSettings settings) { return DeserializeObject<T>(value, settings); } [DebuggerStepThrough] [return: <7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(2)] public static T DeserializeObject<[<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(2)] T>(string value, params JsonConverter[] converters) { return (T)DeserializeObject(value, typeof(T), converters); } [DebuggerStepThrough] [<71712b87-457a-4b7a-bfec-5496a9d76840>NullableContext(2)] public static T DeserializeObject<T>([<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(1)] string value, JsonSerializerSettings settings) { return (T)DeserializeObject(value, typeof(T), settings); } [DebuggerStepThrough] [return: <7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(2)] public static object DeserializeObject(string value, Type type, params JsonConverter[] converters) { JsonSerializerSettings settings = ((converters != null && converters.Length != 0) ? new JsonSerializerSettings { Converters = converters } : null); return DeserializeObject(value, type, settings); } [<71712b87-457a-4b7a-bfec-5496a9d76840>NullableContext(2)] public static object DeserializeObject([<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(1)] string value, Type type, JsonSerializerSettings settings) { ValidationUtils.ArgumentNotNull(value, "value"); JsonSerializer jsonSerializer = JsonSerializer.CreateDefault(settings); if (!jsonSerializer.IsCheckAdditionalContentSet()) { jsonSerializer.CheckAdditionalContent = true; } using JsonTextReader reader = new JsonTextReader(new StringReader(value)); return jsonSerializer.Deserialize(reader, type); } [DebuggerStepThrough] public static void PopulateObject(string value, object target) { PopulateObject(value, target, null); } public static void PopulateObject(string value, object target, [<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(2)] JsonSerializerSettings settings) { JsonSerializer jsonSerializer = JsonSerializer.CreateDefault(settings); using JsonReader jsonReader = new JsonTextReader(new StringReader(value)); jsonSerializer.Populate(jsonReader, target); if (settings == null || !settings.CheckAdditionalContent) { return; } while (jsonReader.Read()) { if (jsonReader.TokenType != JsonToken.Comment) { throw JsonSerializationException.Create(jsonReader, "Additional text found in JSON string after finishing deserializing object."); } } } public static string SerializeXmlNode([<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(2)] XmlNode node) { return SerializeXmlNode(node, Formatting.None); } public static string SerializeXmlNode([<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(2)] XmlNode node, Formatting formatting) { XmlNodeConverter xmlNodeConverter = new XmlNodeConverter(); return SerializeObject(node, formatting, xmlNodeConverter); } public static string SerializeXmlNode([<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(2)] XmlNode node, Formatting formatting, bool omitRootObject) { XmlNodeConverter xmlNodeConverter = new XmlNodeConverter { OmitRootObject = omitRootObject }; return SerializeObject(node, formatting, xmlNodeConverter); } [return: <7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(2)] public static XmlDocument DeserializeXmlNode(string value) { return DeserializeXmlNode(value, null); } [<71712b87-457a-4b7a-bfec-5496a9d76840>NullableContext(2)] public static XmlDocument DeserializeXmlNode([<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(1)] string value, string deserializeRootElementName) { return DeserializeXmlNode(value, deserializeRootElementName, writeArrayAttribute: false); } [<71712b87-457a-4b7a-bfec-5496a9d76840>NullableContext(2)] public static XmlDocument DeserializeXmlNode([<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(1)] string value, string deserializeRootElementName, bool writeArrayAttribute) { return DeserializeXmlNode(value, deserializeRootElementName, writeArrayAttribute, encodeSpecialCharacters: false); } [<71712b87-457a-4b7a-bfec-5496a9d76840>NullableContext(2)] public static XmlDocument DeserializeXmlNode([<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(1)] string value, string deserializeRootElementName, bool writeArrayAttribute, bool encodeSpecialCharacters) { XmlNodeConverter xmlNodeConverter = new XmlNodeConverter(); xmlNodeConverter.DeserializeRootElementName = deserializeRootElementName; xmlNodeConverter.WriteArrayAttribute = writeArrayAttribute; xmlNodeConverter.EncodeSpecialCharacters = encodeSpecialCharacters; return (XmlDocument)DeserializeObject(value, typeof(XmlDocument), xmlNodeConverter); } public static string SerializeXNode([<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(2)] XObject node) { return SerializeXNode(node, Formatting.None); } public static string SerializeXNode([<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(2)] XObject node, Formatting formatting) { return SerializeXNode(node, formatting, omitRootObject: false); } public static string SerializeXNode([<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(2)] XObject node, Formatting formatting, bool omitRootObject) { XmlNodeConverter xmlNodeConverter = new XmlNodeConverter { OmitRootObject = omitRootObject }; return SerializeObject(node, formatting, xmlNodeConverter); } [return: <7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(2)] public static XDocument DeserializeXNode(string value) { return DeserializeXNode(value, null); } [<71712b87-457a-4b7a-bfec-5496a9d76840>NullableContext(2)] public static XDocument DeserializeXNode([<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(1)] string value, string deserializeRootElementName) { return DeserializeXNode(value, deserializeRootElementName, writeArrayAttribute: false); } [<71712b87-457a-4b7a-bfec-5496a9d76840>NullableContext(2)] public static XDocument DeserializeXNode([<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(1)] string value, string deserializeRootElementName, bool writeArrayAttribute) { return DeserializeXNode(value, deserializeRootElementName, writeArrayAttribute, encodeSpecialCharacters: false); } [<71712b87-457a-4b7a-bfec-5496a9d76840>NullableContext(2)] public static XDocument DeserializeXNode([<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(1)] string value, string deserializeRootElementName, bool writeArrayAttribute, bool encodeSpecialCharacters) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown XmlNodeConverter xmlNodeConverter = new XmlNodeConverter(); xmlNodeConverter.DeserializeRootElementName = deserializeRootElementName; xmlNodeConverter.WriteArrayAttribute = writeArrayAttribute; xmlNodeConverter.EncodeSpecialCharacters = encodeSpecialCharacters; return (XDocument)DeserializeObject(value, typeof(XDocument), xmlNodeConverter); } } [<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(0)] [<71712b87-457a-4b7a-bfec-5496a9d76840>NullableContext(1)] internal abstract class JsonConverter { public virtual bool CanRead => true; public virtual bool CanWrite => true; public abstract void WriteJson(JsonWriter writer, [<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(2)] object value, JsonSerializer serializer); [return: <7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(2)] public abstract object ReadJson(JsonReader reader, Type objectType, [<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(2)] object existingValue, JsonSerializer serializer); public abstract bool CanConvert(Type objectType); } [<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(0)] [<71712b87-457a-4b7a-bfec-5496a9d76840>NullableContext(1)] internal abstract class JsonConverter<[<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(2)] T> : JsonConverter { public sealed override void WriteJson(JsonWriter writer, [<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(2)] object value, JsonSerializer serializer) { if (!((value != null) ? (value is T) : ReflectionUtils.IsNullable(typeof(T)))) { throw new JsonSerializationException("Converter cannot write specified value to JSON. {0} is required.".FormatWith(CultureInfo.InvariantCulture, typeof(T))); } WriteJson(writer, (T)value, serializer); } public abstract void WriteJson(JsonWriter writer, [<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(2)] T value, JsonSerializer serializer); [return: <7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(2)] public sealed override object ReadJson(JsonReader reader, Type objectType, [<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(2)] object existingValue, JsonSerializer serializer) { bool flag = existingValue == null; if (!flag && !(existingValue is T)) { throw new JsonSerializationException("Converter cannot read JSON with the specified existing value. {0} is required.".FormatWith(CultureInfo.InvariantCulture, typeof(T))); } return ReadJson(reader, objectType, flag ? default(T) : ((T)existingValue), !flag, serializer); } [return: <7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(2)] public abstract T ReadJson(JsonReader reader, Type objectType, [<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(2)] T existingValue, bool hasExistingValue, JsonSerializer serializer); public sealed override bool CanConvert(Type objectType) { return typeof(T).IsAssignableFrom(objectType); } } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Interface | AttributeTargets.Parameter, AllowMultiple = false)] [<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(0)] [<71712b87-457a-4b7a-bfec-5496a9d76840>NullableContext(1)] internal sealed class JsonConverterAttribute : Attribute { private readonly Type _converterType; public Type ConverterType => _converterType; [<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(new byte[] { 2, 1 })] [field: <7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(new byte[] { 2, 1 })] public object[] ConverterParameters { [return: <7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(new byte[] { 2, 1 })] get; } public JsonConverterAttribute(Type converterType) { if (converterType == null) { throw new ArgumentNullException("converterType"); } _converterType = converterType; } public JsonConverterAttribute(Type converterType, params object[] converterParameters) : this(converterType) { ConverterParameters = converterParameters; } } [<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(new byte[] { 0, 1 })] internal class JsonConverterCollection : Collection<JsonConverter> { } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = false)] internal sealed class JsonDictionaryAttribute : JsonContainerAttribute { public JsonDictionaryAttribute() { } [<71712b87-457a-4b7a-bfec-5496a9d76840>NullableContext(1)] public JsonDictionaryAttribute(string id) : base(id) { } } [Serializable] [<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(0)] [<71712b87-457a-4b7a-bfec-5496a9d76840>NullableContext(1)] internal class JsonException : Exception { public JsonException() { } public JsonException(string message) : base(message) { } public JsonException(string message, [<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(2)] Exception innerException) : base(message, innerException) { } public JsonException(SerializationInfo info, StreamingContext context) : base(info, context) { } internal static JsonException Create(IJsonLineInfo lineInfo, string path, string message) { message = JsonPosition.FormatMessage(lineInfo, path, message); return new JsonException(message); } } [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)] internal class JsonExtensionDataAttribute : Attribute { public bool WriteData { get; set; } public bool ReadData { get; set; } public JsonExtensionDataAttribute() { WriteData = true; ReadData = true; } } [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)] internal sealed class JsonIgnoreAttribute : Attribute { } internal abstract class JsonNameTable { [<71712b87-457a-4b7a-bfec-5496a9d76840>NullableContext(1)] [return: <7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(2)] public abstract string Get(char[] key, int start, int length); } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface, AllowMultiple = false)] internal sealed class JsonObjectAttribute : JsonContainerAttribute { private MemberSerialization _memberSerialization; internal MissingMemberHandling? _missingMemberHandling; internal Required? _itemRequired; internal NullValueHandling? _itemNullValueHandling; public MemberSerialization MemberSerialization { get { return _memberSerialization; } set { _memberSerialization = value; } } public MissingMemberHandling MissingMemberHandling { get { return _missingMemberHandling.GetValueOrDefault(); } set { _missingMemberHandling = value; } } public NullValueHandling ItemNullValueHandling { get { return _itemNullValueHandling.GetValueOrDefault(); } set { _itemNullValueHandling = value; } } public Required ItemRequired { get { return _itemRequired.GetValueOrDefault(); } set { _itemRequired = value; } } public JsonObjectAttribute() { } public JsonObjectAttribute(MemberSerialization memberSerialization) { MemberSerialization = memberSerialization; } [<71712b87-457a-4b7a-bfec-5496a9d76840>NullableContext(1)] public JsonObjectAttribute(string id) : base(id) { } } internal enum JsonContainerType { None, Object, Array, Constructor } [<71712b87-457a-4b7a-bfec-5496a9d76840>NullableContext(1)] [<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(0)] internal struct JsonPosition { private static readonly char[] SpecialCharacters = new char[18] { '.', ' ', '\'', '/', '"', '[', ']', '(', ')', '\t', '\n', '\r', '\f', '\b', '\\', '\u0085', '\u2028', '\u2029' }; internal JsonContainerType Type; internal int Position; [<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(2)] internal string PropertyName; internal bool HasIndex; public JsonPosition(JsonContainerType type) { Type = type; HasIndex = TypeHasIndex(type); Position = -1; PropertyName = null; } internal int CalculateLength() { switch (Type) { case JsonContainerType.Object: return PropertyName.Length + 5; case JsonContainerType.Array: case JsonContainerType.Constructor: return MathUtils.IntLength((ulong)Position) + 2; default: throw new ArgumentOutOfRangeException("Type"); } } [<71712b87-457a-4b7a-bfec-5496a9d76840>NullableContext(2)] internal void WriteTo([<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(1)] StringBuilder sb, ref StringWriter writer, ref char[] buffer) { switch (Type) { case JsonContainerType.Object: { string propertyName = PropertyName; if (propertyName.IndexOfAny(SpecialCharacters) != -1) { sb.Append("['"); if (writer == null) { writer = new StringWriter(sb); } JavaScriptUtils.WriteEscapedJavaScriptString(writer, propertyName, '\'', appendDelimiters: false, JavaScriptUtils.SingleQuoteCharEscapeFlags, StringEscapeHandling.Default, null, ref buffer); sb.Append("']"); } else { if (sb.Length > 0) { sb.Append('.'); } sb.Append(propertyName); } break; } case JsonContainerType.Array: case JsonContainerType.Constructor: sb.Append('['); sb.Append(Position); sb.Append(']'); break; } } internal static bool TypeHasIndex(JsonContainerType type) { if (type != JsonContainerType.Array) { return type == JsonContainerType.Constructor; } return true; } internal static string BuildPath(List<JsonPosition> positions, JsonPosition? currentPosition) { int num = 0; if (positions != null) { for (int i = 0; i < positions.Count; i++) { num += positions[i].CalculateLength(); } } if (currentPosition.HasValue) { num += currentPosition.GetValueOrDefault().CalculateLength(); } StringBuilder stringBuilder = new StringBuilder(num); StringWriter writer = null; char[] buffer = null; if (positions != null) { foreach (JsonPosition position in positions) { position.WriteTo(stringBuilder, ref writer, ref buffer); } } currentPosition?.WriteTo(stringBuilder, ref writer, ref buffer); return stringBuilder.ToString(); } internal static string FormatMessage([<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(2)] IJsonLineInfo lineInfo, string path, string message) { if (!message.EndsWith(Environment.NewLine, StringComparison.Ordinal)) { message = message.Trim(); if (!StringUtils.EndsWith(message, '.')) { message += "."; } message += " "; } message += "Path '{0}'".FormatWith(CultureInfo.InvariantCulture, path); if (lineInfo != null && lineInfo.HasLineInfo()) { message += ", line {0}, position {1}".FormatWith(CultureInfo.InvariantCulture, lineInfo.LineNumber, lineInfo.LinePosition); } message += "."; return message; } } [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false)] [<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(0)] [<71712b87-457a-4b7a-bfec-5496a9d76840>NullableContext(2)] internal sealed class JsonPropertyAttribute : Attribute { internal NullValueHandling? _nullValueHandling; internal DefaultValueHandling? _defaultValueHandling; internal ReferenceLoopHandling? _referenceLoopHandling; internal ObjectCreationHandling? _objectCreationHandling; internal TypeNameHandling? _typeNameHandling; internal bool? _isReference; internal int? _order; internal Required? _required; internal bool? _itemIsReference; internal ReferenceLoopHandling? _itemReferenceLoopHandling; internal TypeNameHandling? _itemTypeNameHandling; public Type ItemConverterType { get; set; } [<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(new byte[] { 2, 1 })] [field: <7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(new byte[] { 2, 1 })] public object[] ItemConverterParameters { [return: <7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(new byte[] { 2, 1 })] get; [param: <7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(new byte[] { 2, 1 })] set; } public Type NamingStrategyType { get; set; } [<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(new byte[] { 2, 1 })] [field: <7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(new byte[] { 2, 1 })] public object[] NamingStrategyParameters { [return: <7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(new byte[] { 2, 1 })] get; [param: <7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(new byte[] { 2, 1 })] set; } public NullValueHandling NullValueHandling { get { return _nullValueHandling.GetValueOrDefault(); } set { _nullValueHandling = value; } } public DefaultValueHandling DefaultValueHandling { get { return _defaultValueHandling.GetValueOrDefault(); } set { _defaultValueHandling = value; } } public ReferenceLoopHandling ReferenceLoopHandling { get { return _referenceLoopHandling.GetValueOrDefault(); } set { _referenceLoopHandling = value; } } public ObjectCreationHandling ObjectCreationHandling { get { return _objectCreationHandling.GetValueOrDefault(); } set { _objectCreationHandling = value; } } public TypeNameHandling TypeNameHandling { get { return _typeNameHandling.GetValueOrDefault(); } set { _typeNameHandling = value; } } public bool IsReference { get { return _isReference.GetValueOrDefault(); } set { _isReference = value; } } public int Order { get { return _order.GetValueOrDefault(); } set { _order = value; } } public Required Required { get { return _required.GetValueOrDefault(); } set { _required = value; } } public string PropertyName { get; set; } public ReferenceLoopHandling ItemReferenceLoopHandling { get { return _itemReferenceLoopHandling.GetValueOrDefault(); } set { _itemReferenceLoopHandling = value; } } public TypeNameHandling ItemTypeNameHandling { get { return _itemTypeNameHandling.GetValueOrDefault(); } set { _itemTypeNameHandling = value; } } public bool ItemIsReference { get { return _itemIsReference.GetValueOrDefault(); } set { _itemIsReference = value; } } public JsonPropertyAttribute() { } [<71712b87-457a-4b7a-bfec-5496a9d76840>NullableContext(1)] public JsonPropertyAttribute(string propertyName) { PropertyName = propertyName; } } [<71712b87-457a-4b7a-bfec-5496a9d76840>NullableContext(2)] [<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(0)] internal abstract class JsonReader : IDisposable { [<71712b87-457a-4b7a-bfec-5496a9d76840>NullableContext(0)] protected internal enum State { Start, Complete, Property, ObjectStart, Object, ArrayStart, Array, Closed, PostValue, ConstructorStart, Constructor, Error, Finished } private JsonToken _tokenType; private object _value; internal char _quoteChar; internal State _currentState; private JsonPosition _currentPosition; private CultureInfo _culture; private DateTimeZoneHandling _dateTimeZoneHandling; private int? _maxDepth; private bool _hasExceededMaxDepth; internal DateParseHandling _dateParseHandling; internal FloatParseHandling _floatParseHandling; private string _dateFormatString; private List<JsonPosition> _stack; protected State CurrentState => _currentState; public bool CloseInput { get; set; } public bool SupportMultipleContent { get; set; } public virtual char QuoteChar { get { return _quoteChar; } protected internal set { _quoteChar = value; } } public DateTimeZoneHandling DateTimeZoneHandling { get { return _dateTimeZoneHandling; } set { if (value < DateTimeZoneHandling.Local || value > DateTimeZoneHandling.RoundtripKind) { throw new ArgumentOutOfRangeException("value"); } _dateTimeZoneHandling = value; } } public DateParseHandling DateParseHandling { get { return _dateParseHandling; } set { if (value < DateParseHandling.None || value > DateParseHandling.DateTimeOffset) { throw new ArgumentOutOfRangeException("value"); } _dateParseHandling = value; } } public FloatParseHandling FloatParseHandling { get { return _floatParseHandling; } set { if (value < FloatParseHandling.Double || value > FloatParseHandling.Decimal) { throw new ArgumentOutOfRangeException("value"); } _floatParseHandling = value; } } public string DateFormatString { get { return _dateFormatString; } set { _dateFormatString = value; } } public int? MaxDepth { get { return _maxDepth; } set { if (value <= 0) { throw new ArgumentException("Value must be positive.", "value"); } _maxDepth = value; } } public virtual JsonToken TokenType => _tokenType; public virtual object Value => _value; public virtual Type ValueType => _value?.GetType(); public virtual int Depth { get { int num = _stack?.Count ?? 0; if (JsonTokenUtils.IsStartToken(TokenType) || _currentPosition.Type == JsonContainerType.None) { return num; } return num + 1; } } [<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(1)] public virtual string Path { [<71712b87-457a-4b7a-bfec-5496a9d76840>NullableContext(1)] get { if (_currentPosition.Type == JsonContainerType.None) { return string.Empty; } JsonPosition? currentPosition = ((_currentState != State.ArrayStart && _currentState != State.ConstructorStart && _currentState != State.ObjectStart) ? new JsonPosition?(_currentPosition) : null); return JsonPosition.BuildPath(_stack, currentPosition); } } [<7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(1)] public CultureInfo Culture { [<71712b87-457a-4b7a-bfec-5496a9d76840>NullableContext(1)] get { return _culture ?? CultureInfo.InvariantCulture; } [<71712b87-457a-4b7a-bfec-5496a9d76840>NullableContext(1)] set { _culture = value; } } [<71712b87-457a-4b7a-bfec-5496a9d76840>NullableContext(1)] public virtual Task<bool> ReadAsync(CancellationToken cancellationToken = default(CancellationToken)) { return cancellationToken.CancelIfRequestedAsync<bool>() ?? Read().ToAsync(); } [<71712b87-457a-4b7a-bfec-5496a9d76840>NullableContext(1)] public async Task SkipAsync(CancellationToken cancellationToken = default(CancellationToken)) { if (TokenType == JsonToken.PropertyName) { await ReadAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false); } if (JsonTokenUtils.IsStartToken(TokenType)) { int depth = Depth; while (await ReadAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false) && depth < Depth) { } } } [<71712b87-457a-4b7a-bfec-5496a9d76840>NullableContext(1)] internal async Task ReaderReadAndAssertAsync(CancellationToken cancellationToken) { if (!(await ReadAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false))) { throw CreateUnexpectedEndException(); } } [<71712b87-457a-4b7a-bfec-5496a9d76840>NullableContext(1)] public virtual Task<bool?> ReadAsBooleanAsync(CancellationToken cancellationToken = default(CancellationToken)) { return cancellationToken.CancelIfRequestedAsync<bool?>() ?? Task.FromResult(ReadAsBoolean()); } [return: <7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(new byte[] { 1, 2 })] public virtual Task<byte[]> ReadAsBytesAsync(CancellationToken cancellationToken = default(CancellationToken)) { return cancellationToken.CancelIfRequestedAsync<byte[]>() ?? Task.FromResult(ReadAsBytes()); } [return: <7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(new byte[] { 1, 2 })] internal async Task<byte[]> ReadArrayIntoByteArrayAsync(CancellationToken cancellationToken) { List<byte> buffer = new List<byte>(); do { if (!(await ReadAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false))) { SetToken(JsonToken.None); } } while (!ReadArrayElementIntoByteArrayReportDone(buffer)); byte[] array = buffer.ToArray(); SetToken(JsonToken.Bytes, array, updateIndex: false); return array; } [<71712b87-457a-4b7a-bfec-5496a9d76840>NullableContext(1)] public virtual Task<DateTime?> ReadAsDateTimeAsync(CancellationToken cancellationToken = default(CancellationToken)) { return cancellationToken.CancelIfRequestedAsync<DateTime?>() ?? Task.FromResult(ReadAsDateTime()); } [<71712b87-457a-4b7a-bfec-5496a9d76840>NullableContext(1)] public virtual Task<DateTimeOffset?> ReadAsDateTimeOffsetAsync(CancellationToken cancellationToken = default(CancellationToken)) { return cancellationToken.CancelIfRequestedAsync<DateTimeOffset?>() ?? Task.FromResult(ReadAsDateTimeOffset()); } [<71712b87-457a-4b7a-bfec-5496a9d76840>NullableContext(1)] public virtual Task<decimal?> ReadAsDecimalAsync(CancellationToken cancellationToken = default(CancellationToken)) { return cancellationToken.CancelIfRequestedAsync<decimal?>() ?? Task.FromResult(ReadAsDecimal()); } [<71712b87-457a-4b7a-bfec-5496a9d76840>NullableContext(1)] public virtual Task<double?> ReadAsDoubleAsync(CancellationToken cancellationToken = default(CancellationToken)) { return Task.FromResult(ReadAsDouble()); } [<71712b87-457a-4b7a-bfec-5496a9d76840>NullableContext(1)] public virtual Task<int?> ReadAsInt32Async(CancellationToken cancellationToken = default(CancellationToken)) { return cancellationToken.CancelIfRequestedAsync<int?>() ?? Task.FromResult(ReadAsInt32()); } [return: <7590d925-4c58-49ee-8f26-84b08f2a30f8>Nullable(new byte[] { 1, 2 })] public virtual Task<string> ReadAsStringAsync(CancellationToken cancellationToken = default(CancellationToken)) { return cancellationToken.CancelIfRequestedAsync<string>() ?? Task.FromResult(ReadAsString()); } [<71712b87-457a-4b7a-bfec-5496a9d76840>NullableContext(1)] internal async Task<bool> ReadAndMoveToContentAsync(CancellationToken cancellationToken) { bool flag = await ReadAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false); if (flag) { flag = await MoveToContentAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false); } return flag; } [<71712b87-457a-4b7a-bfec-5496a9d76840>NullableContext(1)] internal Task<bool> MoveToContentAsync(CancellationToken cancellationToken) { JsonToken tokenType = TokenType; if (tokenType == JsonToken.None || tokenType == JsonToken.Comment) { return MoveToContentFromNonContentAsync(cancellationToken); } return AsyncUtils.True; } [<71712b87-457a-4b7a-bfec-5496a9d76840>NullableContext(1)] private async Task<bool> MoveToContentFromNonContentAsync(CancellationToken cancellationToken) { JsonToken tokenType; do { if (!(await ReadAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false))) { return false; } tokenType = TokenType; } while (tokenType == JsonToken.None || tokenType == JsonToken.Comment); return true; } internal JsonPosition GetPosition(int depth) { if (_stack != null && depth < _stack.Count) { return _stack[depth]; } return _currentPosition; } protected JsonReader() { _currentState = State.Start; _dateTimeZoneHandling = DateTimeZoneHandling.RoundtripKind; _dateParseHandling = DateParseHandling.DateTime; _floatParseHandling = FloatParseHandling.Double; _maxDepth = 64; CloseInput = true; } private void Push(JsonContainerType value) { UpdateScopeWithFinishedValue(); if (_currentPosition.Type == JsonContainerType.None) { _currentPosition = new JsonPosition(value); return; } if (_stack == null) { _stack = new List<JsonPosition>(); } _stack.Add(_currentPosition); _currentPosition = new JsonPosition(value); if (!_maxDepth.HasValue || !(Depth + 1 > _maxDepth) || _hasExceededMaxDepth) { return; } _hasExceededMaxDepth = true; throw JsonReaderException.Create(this, "The reader's MaxDepth of {0} has been exceeded.".FormatWith(CultureInfo.InvariantCulture, _maxDepth)); } private JsonContainerType Pop() { JsonPosition currentPosition; if (_stack != null && _stack.Count > 0) { currentPosition = _currentPosition; _currentPosition = _stack[_stack.Count - 1]; _stack.RemoveAt(_stack.Count - 1); } else { currentPosition = _currentPosition; _currentPosition = default(JsonPosition); } if (_maxDepth.HasValue && Depth <= _maxDepth) { _hasExceededMaxDepth = false; } return currentPosition.Type; } private JsonContainerType Peek() { return _currentPosition.Type; } public abstract bool Read(); public virtual int? ReadAsInt32() { JsonToken contentToken = GetContentToken(); switch (contentToken) { case JsonToken.None: case JsonToken.Null: case JsonToken.EndArray: return null; case JsonToken.Integer: case JsonToken.Float: { object value = Value; if (value is int) { return (int)value; } int num; if (value is BigInteger bigInteger) { num = (int)bigInteger; } else { try { num = Convert.ToInt32(value, CultureInfo.InvariantCulture); } catch (Exception ex) { throw JsonReaderException.Create(this, "Could not convert to integer: {0}.".FormatWith(CultureInfo.InvariantCulture, value), ex); } } SetToken(JsonToken.Integer, num, updateIndex: false); return num; } case JsonToken.String: { string s = (string)Value; return ReadInt32String(s); } default: throw JsonReaderException.Create(this, "Error reading integer. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, contentToken)); } } internal int? ReadInt32String(string s) { if (StringUtils.IsNullOrEmpty(s)) { SetToken(JsonToken.Null, null, updateIndex: false); return null; } if (int.TryParse(s, NumberStyles.Integer, Culture, out var result)) { SetToken(JsonToken.Integer, result, updateIndex: false); return result; } SetToken(JsonToken.String, s, updateIndex: false); throw JsonReaderException.Create(this, "Could not convert string to integer: {0}.".FormatWith(CultureInfo.InvariantCulture, s)); } public virtual string ReadAsString() { JsonToken contentToken = GetContentToken(); switch (contentToken) { case JsonToken.None: case JsonToken.Null: case JsonToken.EndArray: return null; case JsonToken.String: return (string)Value; default: if (JsonTokenUtils.IsPrimitiveToken(contentToken)) { object value = Value; if (value != null) { string text = ((!(value is IFormattable formattable)) ? ((value is Uri uri) ? uri.OriginalString : value.ToString()) : formattable.ToString(null, Culture)); SetToken(JsonToken.String, text, updateIndex: false); return text; } } throw JsonReaderException.Create(this, "Error reading string. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, contentToken)); } } public virtual byte[] ReadAsBytes() { JsonToken contentToken = GetContentToken(); switch (contentToken) { case JsonToken.StartObject: { ReadIntoWrappedTypeObject(); byte[] array2 = ReadAsBytes(); ReaderReadAndAssert(); if (TokenType != JsonToken.EndObject) { throw JsonReaderException.Create(this, "Error reading bytes. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, TokenType)); } SetToken(JsonToken.Bytes, array2, updateIndex: false); return array2; } case JsonToken.String: { string text = (string)Value; Guid g; byte[] array3 = ((text.Length == 0) ? CollectionUtils.ArrayEmpty<byte>() : ((!ConvertUtils.TryConvertGuid(text, out g)) ? Convert.FromBase64String(text) : g.ToByteArray())); SetToken(JsonToken.Bytes, array3, updateIndex: false); return array3; } case JsonToken.None: case JsonToken.Null: case JsonToken.EndArray: return null; case JsonToken.Bytes: if (Value is Guid guid) { byte[] array = guid.ToByteArray(); SetToken(JsonToken.Bytes, array, updateIndex: false); return array; } return (byte[])Value; case JsonToken.StartArray: return ReadArrayIntoByteArray(); default: throw JsonReaderException.Create(this, "Error reading bytes. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, contentToken)); } } [<71712b87-457a-4b7a-bfec-5496a9d76840>NullableContext(1)] internal byte[] ReadArrayIntoByteArray() { List<byte> list = new List<byte>(); do { if (!Read()) { SetToken(JsonToken.None); } } while (!ReadArrayElementIntoByteArrayReportDone(list)); byte[] array = list.ToArray(); SetToken(JsonToken.Bytes, array, updateIndex: false); return array; } [<71712b87-457a-4b7a-bfec-5496a9d76840>NullableContext(1)] private bool ReadArrayElementIntoByteArrayReportDone(List<byte> buffer) { switch (TokenType) { case JsonToken.None: throw JsonReaderException.Create(this, "Unexpected end when reading bytes."); case JsonToken.Integer: buffer.Add(Convert.ToByte(Value, CultureInfo.InvariantCulture)); return false; case JsonToken.EndArray: return true; case JsonToken.Comment: return false; default: throw JsonReaderException.Create(this, "Unexpected token when reading bytes: {0}.".FormatWith(CultureInfo.InvariantCulture, TokenType)); } } public virtual double? ReadAsDouble() { JsonToken contentToken = GetContentToken(); switch (contentToken) { case JsonToken.None: case JsonToken.Null: case JsonToken.EndArray: return null; case JsonToken.Integer: case JsonToken.Float: { object value = Value; if (value is double) { return (double)value; } double num = ((!(value is BigInteger bigInteger)) ? Convert.ToDouble(value, CultureInfo.InvariantCulture) : ((double)bigInteger)); SetToken(JsonToken.Float, num, updateIndex: false); return num; } case JsonToken.String: return ReadDoubleString((string)Value); default: throw JsonReaderException.Create(this, "Error reading double. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, contentToken)); } } internal double? ReadDoubleString(string s) { if (StringUtils.IsNullOrEmpty(s)) { SetToken(JsonToken.Null, null, updateIndex: false); return null; } if (double.TryParse(s, NumberStyles.Float | NumberStyles.AllowThousands, Culture, out var result)) { SetToken(JsonToken.Float, result, updateIndex: false); return result; } SetToken(JsonToken.String, s, updateIndex: false); throw JsonReaderException.Create(this, "Could not convert string to double: {0}.".FormatWith(CultureInfo.InvariantCulture, s)); } public virtual bool? ReadAsBoolean() { JsonToken contentToken = GetContentToken(); switch (contentToken) { case JsonToken.None: case JsonToken.Null: case JsonToken.EndArray: return null; case JsonToken.Integer: case JsonToken.Float: { bool flag = ((!(Value is BigInteger bigInteger)) ? Convert.ToBoolean(Value, CultureInfo.InvariantCulture) : (bigInteger != 0L)); SetToken(JsonToken.Boolean, flag, updateIndex: false); return flag; } case JsonToken.String: return ReadBooleanString((string)Value); case JsonToken.Boolean: return (bool)Value; default: throw JsonReaderException.Create(this, "Error reading boolean. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, contentToken)); } } internal bool? ReadBooleanString(string s) { if (StringUtils.IsNullOrEmpty(s)) { SetToken(JsonToken.Null, null, updateIndex: false); return null; } if (bool.TryParse(s, out var result)) { SetToken(JsonToken.Boolean, result, updateIndex: false); return result; } SetToken(JsonToken.String, s, updateIndex: false); throw JsonReaderException.Create(this, "Could not convert string to boolean: {0}.".FormatWith(CultureInfo.InvariantCulture, s)); } public virtual decimal? ReadAsDecimal() { JsonToken contentToken = GetContentToken(); switch (contentToken) { case JsonToken.None: case JsonToken.Null: case JsonToken.EndArray: return null; case JsonToken.Integer: case JsonToken.Float: { object value = Value; if (value is decimal) { return (decimal)value; } decimal num; if (value is BigInteger bigInteger) { num = (decimal)bigInteger; } else { try { num = Convert.ToDecimal(value, CultureInfo.InvariantCulture); } catch (Exception ex) { throw JsonReaderException.Create(this, "Could not convert to decimal: {0}.".FormatWith(CultureInfo.InvariantCulture, value), ex); } } SetToken(JsonToken.Float, num, updateIndex: false); return num; } case JsonToken.String: return ReadDecimalString((string)Value); default: throw JsonReaderException.Create(this, "Error reading decimal. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, contentToken)); } } internal decimal? ReadDecimalString(string s) { if (StringUtils.IsNullOrEmpty(s)) { SetToken(JsonToken.Null, null, updateIndex: false); return null; } if (decimal.TryParse(s, NumberStyles.Number, Culture, out var result)) { SetToken(JsonToken.Float, result, updateIndex: false); return result; } if (ConvertUtils.DecimalTryParse(s.ToCharArray(), 0, s.Length, out result) == ParseResult.Success) { SetToken(JsonToken.Float, result, updateIndex: false); return result; } SetToken(JsonToken.String, s, updateIndex: false); throw JsonReaderException.Create(this, "Could not convert string to decimal: {0}.".FormatWith(CultureInfo.InvariantCulture, s)); } public virtual DateTime? ReadAsDateTime() { switch (GetContentToken()) { case JsonToken.None: case JsonToken.Null: case JsonToken.EndArray: return null; case JsonToken.Date: if (Value is DateTimeOffset dateTimeOffset) { SetToken(JsonToken.Date, dateTimeOffset.DateTime, updateIndex: false); } return (DateTime)Value; case JsonToken.String: return ReadDateTimeString((string)Value); default: throw JsonReaderException.Create(this, "Error reading date. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, TokenType)); } } internal DateTime? ReadDateTimeString(string s) { if (StringUtils.IsNullOrEmpty(s)) { SetToken(JsonToken.Null, null, updateIndex: false); return null; } if (DateTimeUtils.TryParseDateTime(s, DateTimeZoneHandling, _dateFormatString, Culture, out var dt)) { dt = DateTimeUtils.EnsureDateTime(dt, DateTimeZoneHandling); SetToken(JsonToken.Date, dt, updateIndex: false); return dt; } if (DateTime.TryParse(s, Culture, DateTimeStyles.RoundtripKind, out dt)) { dt = DateTimeUtils.EnsureDateTime(dt, DateTimeZoneHandling); SetToken(JsonToken.Date, dt, updateIndex: false); return dt; } throw JsonReaderException.Create(this, "Could not convert string to DateTime: {0}.".FormatWith(CultureInfo.InvariantCulture, s)); } public virtual DateTimeOffset? ReadAsDateTimeOffset() { JsonToken contentToken = GetContentToken(); switch (contentToken) { case JsonToken.None: case JsonToken.Null: case JsonToken.EndArray: return null; case JsonToken.Date: if (Value is DateTime dateTime) { SetToken(JsonToken.Date, new DateTimeOffset(dateTime), updateIndex: false); } return (DateTimeOffset)Value; case JsonToken.String: { string s = (string)Value; return ReadDateTimeOffsetString(s); } default: throw JsonReaderException.Create(this, "Error reading date. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, contentToken)); } } internal DateTimeOffset? ReadDateTimeOffsetString(string s) { if (StringUtils.IsNullOrEmpty(s)) { SetToken(JsonToken.Null, null, updateIndex: false); return null; } if (DateTimeUtils.TryParseDateTimeOffset(s, _dateFormatString, Culture, out var dt)) { SetToken(JsonToken.Date, dt, updateIndex: false); return dt; } if (DateTimeOffset.TryParse(s, Culture, DateTimeStyles.RoundtripKind, out dt)) { SetToken(JsonToken.Date, dt, updateIndex: false); return dt; } SetToken(JsonToken.String, s, updateIndex: false); throw JsonReaderException.Create(this, "Could not convert string to DateTimeOffset: {0}.".FormatWith(CultureInfo.InvariantCulture, s)); } internal void ReaderReadAndAssert() { if (!Read()) { throw CreateUnexpectedEndException(); } } [<71712b87-457a-4b7a-bfec-5496a9d76840>NullableContext(1)] internal JsonReaderException CreateUnexpectedEndException() { return JsonReaderException.Create(this, "Unexpected end when reading JSON."); } internal void ReadIntoWrappedTypeObject() { ReaderReadAndAssert(); if (Value != null && Value.ToString() == "$type") { ReaderReadAndAssert(); if (Value != null && Value.ToString().StartsWith("System.Byte[]", StringComparison.Ordinal)) { ReaderReadAndAssert(); if (Value.ToString() == "$value") { return; } } } throw JsonReaderException.Create(this, "Error reading bytes. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, JsonToken.StartObject)); } public void Skip() { if (TokenType == JsonToken.PropertyName) { Read(); } if (JsonTokenUtils.IsStartToken(TokenType)) { int depth = Depth; while (Read() && depth < Depth) { } } } protected void SetToken(JsonToken newToken) { SetToken(newToken, null, updateIndex: true); } protected void SetToken(JsonToken newToken, object value) { SetToken(newToken, value, updateIndex: true); } protected void SetToken(JsonToken newToken, object value, bool updateIndex) { _tokenType = newToken; _value = value; switch (newToken) { case JsonToken.StartObject: _currentState = State.ObjectStart; Push(JsonContainerType.Object); break; case JsonToken.StartArray: _currentState = State.ArrayStart; Push(JsonContainerType.Array); break; case JsonToken.StartConstructor: _currentState = State.ConstructorStart; Push(JsonContainerType.Constructor); break; case JsonToken.EndObject: ValidateEnd(JsonToken.EndObject); break; case JsonToken.EndArray: ValidateEnd(JsonToken.EndArray); break; case JsonToken.EndConstructor: ValidateEnd(JsonToken