Пример #1
0
        public static void AddEntry(string name, Category category)
        {
            Type myType = null;

            if (types.ContainsKey(name))
            {
                myType = types[name];
            }
            else
            {
                myType = DynamicTypeBuilder.CreateType(name, null);
                types.Add(name, myType);
            }

#if DEBUG
            ThreadSafeLogger.Message($"Adding entry {name} into the category {category}");
#endif
            var entry = Entry.Create(name, category, myType, true, true);

            if (Tab(category).entries.ContainsKey(entry))
            {
                ThreadSafeLogger.Error($"Attempting to re-add entry {name} into the category {category}");
            }
            else
            {
                Tab(category).entries.Add(entry, myType);
            }
        }
Пример #2
0
        // 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);
            }
        }