using System; using System.Collections.Generic; using System.IO; using Newtonsoft.Json; using Newtonsoft.Json.Linq; public static class ItemLoader { public static List LoadAllItems(string path) { //Check to see if the file exists. If not, just create a blank List. if (!File.Exists(path)) { return new List(); } //Dump the entirely of the file into a string. string json = File.ReadAllText(path); //Create a new variable with our custom JSON serializer settings that allows us to make mixed Lists. var settings = new JsonSerializerSettings { Converters = { new ItemConverter() } }; //Return a list with different Items mixed in, or return a blank list. return JsonConvert.DeserializeObject>(json, settings) ?? new List(); } //Returns all the HealingItems in a list. public static List LoadHealingItemsFromList(List input) { List healingitems = input .OfType() .ToList(); return healingitems; } }