Beispiel #1
0
        private void ParseEnumGroups(XDocument doc, XmlSpecData data, Options options)
        {
            var groupsNode = doc.Root.Element("groups");

            if (groupsNode == null)
                return;

            foreach (var enumGroupNode in groupsNode.Elements())
            {
                XmlEnumGroupData enumGroupData = new XmlEnumGroupData()
                {
                    Name = enumGroupNode.GetAttributeValue("name")
                };

                foreach (var enumNode in enumGroupNode.Elements())
                {
                    enumGroupData.Enums.Add(enumNode.GetAttributeValue("name"));
                }

                data.EnumGroups.Add(enumGroupData);
            }
        }
Beispiel #2
0
        private void ParseOverrides(XDocument doc, XmlSpecData data)
        {
            foreach (var groupNode in doc.Root.Element("groups").Elements())
            {
                var enumGroup = data.EnumGroups.SingleOrDefault(x => x.Name == groupNode.GetAttributeValue("name"));

                if (enumGroup == null)
                {
                    enumGroup = new XmlEnumGroupData()
                    {
                        Name = groupNode.GetAttributeValue("name")
                    };

                    data.EnumGroups.Add(enumGroup);
                }

                if (groupNode.Element("enums") != null)
                {
                    foreach (string @enum in groupNode.Element("enums").Value.Split(',').Select(x => x.Trim()))
                    {
                        if (!enumGroup.Enums.Contains(@enum))
                        {
                            enumGroup.Enums.Add(@enum);
                        }
                    }
                }
            }

            foreach (var commandNode in doc.Root.Element("commands").Elements())
            {
                var command = data.Commands.Single(x => x.Name == commandNode.GetAttributeValue("name"));
                
                foreach (var commandParamNode in commandNode.Elements("param"))
                {
                    var param = command.Params.Single(x => x.Name == commandParamNode.GetAttributeValue("name"));

                    string typeGroup = commandParamNode.GetAttributeValue("group");

                    if (typeGroup != null)
                        param.TypeGroup = typeGroup;
                }
            }
        }