// Iterates through each child element in the document and attempts to extract method(s) from the strings inside the children private static void Parse(XmlDocument doc) { foreach (XmlNode node in doc.DocumentElement.ChildNodes) // entries should be { var meths = new HashSet <MethodInfo>(); foreach (XmlNode child in node.ChildNodes) { switch (child.Name.ToLower()) { case "methods": case "method": foreach (XmlNode method in child.ChildNodes) { meths.Add(ParseMethod(method.InnerText)); } break; case "types": case "type": foreach (XmlNode type in child.ChildNodes) { meths.AddRange(ParseTypeMethods(type.InnerText)); } break; case "nestedtype": case "nestedtypes": foreach (XmlNode type in child.ChildNodes) { meths.AddRange(ParseSubTypeTypeMethods(type.InnerText)); } break; default: ThreadSafeLogger.Error($"[Analyzer] Attempting to read unknown value from an Analyzer.xml, the given input was {child.Name}, it should have been either '(M/m)ethods', '(T/t)ypes' '(N/n)estedTypes"); break; } } Type myType = DynamicTypeBuilder.CreateType(node.Name, meths); GUIController.Tab(Category.Modder).entries.Add(Entry.Create(myType.Name, Category.Modder, myType, false, true), myType); } }
public static void ExecutePatch(CurrentInput mode, string strinput, Category cat) { try { if (cat == Category.Tick) { switch (mode) { case CurrentInput.Method: MethodTransplanting.UpdateMethods(typeof(CustomProfilersTick), Utility.GetMethods(strinput)); break; case CurrentInput.Type: MethodTransplanting.UpdateMethods(typeof(CustomProfilersTick), Utility.GetTypeMethods(AccessTools.TypeByName(strinput))); break; case CurrentInput.MethodHarmony: MethodTransplanting.UpdateMethods(typeof(CustomProfilersTick), Utility.GetMethodsPatching(strinput)); break; case CurrentInput.SubClasses: MethodTransplanting.UpdateMethods(typeof(CustomProfilersTick), Utility.SubClassImplementationsOf(AccessTools.TypeByName(strinput), m => true)); break; case CurrentInput.TypeHarmony: MethodTransplanting.UpdateMethods(typeof(CustomProfilersTick), Utility.GetMethodsPatchingType(AccessTools.TypeByName(strinput))); break; case CurrentInput.InternalMethod: Utility.PatchInternalMethod(strinput, Category.Tick); return; case CurrentInput.Assembly: Utility.PatchAssembly(strinput, Category.Tick); return; } GUIController.Tab(Category.Tick).collapsed = false; GUIController.SwapToEntry("Custom Tick"); } else { switch (mode) { case CurrentInput.Method: MethodTransplanting.UpdateMethods(typeof(CustomProfilersUpdate), Utility.GetMethods(strinput)); break; case CurrentInput.Type: MethodTransplanting.UpdateMethods(typeof(CustomProfilersUpdate), Utility.GetTypeMethods(AccessTools.TypeByName(strinput))); break; case CurrentInput.MethodHarmony: MethodTransplanting.UpdateMethods(typeof(CustomProfilersUpdate), Utility.GetMethodsPatching(strinput)); break; case CurrentInput.SubClasses: MethodTransplanting.UpdateMethods(typeof(CustomProfilersUpdate), Utility.SubClassImplementationsOf(AccessTools.TypeByName(strinput), m => true)); break; case CurrentInput.TypeHarmony: MethodTransplanting.UpdateMethods(typeof(CustomProfilersUpdate), Utility.GetMethodsPatchingType(AccessTools.TypeByName(strinput))); break; case CurrentInput.InternalMethod: Utility.PatchInternalMethod(strinput, Category.Update); return; case CurrentInput.Assembly: Utility.PatchAssembly(strinput, Category.Update); return; } GUIController.Tab(Category.Update).collapsed = false; GUIController.SwapToEntry("Custom Update"); } } catch (Exception e) { ThreadSafeLogger.Error($"Failed to process input, failed with the error {e.Message}"); } }