private static void ProcessXmlFile(Graph graph, string xmlFilePath) { XmlDocument document = new XmlDocument(); document.Load(xmlFilePath); XmlNode mainNode = document.DocumentElement.SelectSingleNode(Xml.CompoundDef); if (mainNode != null) { string kind = Xml.GetKind(mainNode); switch (kind) { case "class": case "struct": Class newClass = ProcessClass(mainNode); graph.Classes.Add(newClass); break; case "namespace": string namespaceName = Xml.GetCompoundNodeName(mainNode); ProcessMembers(graph, mainNode, namespaceName); break; default: break; } } }
private static void ProcessMembers(ApiContainer apiContainer, XmlNode node, string namespaceName) { bool isClassMember = apiContainer is Class; foreach (XmlNode memberNode in GetMemberNodes(node)) { switch (Xml.GetKind(memberNode)) { case Xml.Function: ProcessFunction(apiContainer, memberNode, namespaceName, isClassMember); break; case Xml.Variable: ProcessVariable(apiContainer, memberNode, namespaceName, isClassMember); break; default: // This can only happen if GetMemberNodes is broken. throw new System.InvalidOperationException("Member nodes must have type 'Epoxy.Api.Xml.Function' or 'Epoxy.Api.Xml.Variable'."); } } }
private static IEnumerable <XmlNode> GetMemberNodes(XmlNode node) { return(node.SelectNodes(Xml.MemberDefinitionSelector).OfType <XmlNode>().Where(childNode => childNode.Attributes[Xml.Protection].Value == Xml.Public && (Xml.GetKind(childNode) == Xml.Function || Xml.GetKind(childNode) == Xml.Variable))); }