/// <summary> /// Crate the item set file name based on our naming convention /// </summary> /// <param name="championKey">Key value for the champion you want the item set directory for or empty if global</param> /// <param name="map">Map type this item is set for</param> /// <param name="name">Custom name added to file name</param> /// <returns>Name for file including file extention</returns> public static string getItemSetFileName(string championKey, ItemSet.Map map, string name) { //Convert the enum value to the EnumMember string var atr = map.GetAttribute <EnumMemberAttribute>(); string mapAbreviation = atr.Value.ToString(); return(ItemSetNaming.ToolName + championKey + mapAbreviation + name + FileExtention); }
public static void testReader() { string championKey = "Ashe"; ItemSet.Map map = ItemSet.Map.SummonersRift; ItemSet set = ItemSetWriter.readInItemSet(championKey, map, "Boots"); if (set != null) { string JSON = JsonConvert.SerializeObject(set, Formatting.Indented); Console.Write(JSON); } else { Console.WriteLine("No item set found"); } }
/// <summary> /// Read in an item set from disk /// </summary> /// <param name="championKey">Key value for the champion you want the item set directory for or empty if global</param> /// <param name="map">Map this item set is for (used in naming convention)</param> /// <param name="name">Name for this item set file (used in naming convention)</param> /// <param name="subDir">Sub directory to read from, if empty use League of Legends directory</param> /// <returns>Item set if file was found or null if not</returns> public static ItemSet readInItemSet(string championKey = "", ItemSet.Map map = ItemSet.Map.SummonersRift, string name = "", string subDir = "") { //Get the directory we are going to write out to string itemSetDir = (String.IsNullOrEmpty(subDir)) ? getItemSetDirectory(championKey) : Path.Combine(subDir, championKey == "" ? "Global" : championKey) + Path.DirectorySeparatorChar; //Create our unique file name for the system string fileName = Path.Combine(itemSetDir, getItemSetFileName(championKey, map, name)); //Make sure we have this file if (!File.Exists(fileName)) { return(null); } //Read in the file string JSON = File.ReadAllText(fileName); //Convert the JSON string to an object ItemSet itemSet = JsonConvert.DeserializeObject <ItemSet>(JSON); return(itemSet); }