예제 #1
0
파일: VkDocParser.cs 프로젝트: odugen/vk
        private VkDocType GetVkDocType(XmlReader xml)
        {
            var type = new VkDocType {
                FullName = GetMemberName(xml, "T:")
            };

            while (xml.Read())
            {
                if (xml.NodeType == XmlNodeType.EndElement && xml.Name == "member")
                {
                    break;
                }

                if (xml.NodeType == XmlNodeType.Element && xml.Name == "summary")
                {
                    //type.Summary = xml.ReadElementContentAsString().Trim();
                    type.Summary = xml.ReadInnerXml().Trim();
                }
            }

            return(type);
        }
예제 #2
0
        private VkDocType GetVkDocType(XmlReader xml)
        {
            var type = new VkDocType {FullName = GetMemberName(xml, "T:")};

            while (xml.Read())
            {
                if (xml.NodeType == XmlNodeType.EndElement && xml.Name == "member")
                    break;

                if (xml.NodeType == XmlNodeType.Element && xml.Name == "summary")
                {
                    //type.Summary = xml.ReadElementContentAsString().Trim();
                    type.Summary = xml.ReadInnerXml().Trim();
                }
            }

            return type;
        }
예제 #3
0
파일: VkDocParser.cs 프로젝트: odugen/vk
        public IList <VkDocType> Parse(string content)
        {
            Clear();

            if (string.IsNullOrEmpty(content))
            {
                return(Types);
            }

            using (XmlReader xml = new XmlTextReader(new StringReader(content)))
            {
                while (xml.Read())
                {
                    if (xml.NodeType == XmlNodeType.Element && xml.Name == "member")
                    {
                        string name = xml.GetAttribute("name");
                        if (string.IsNullOrEmpty(name))
                        {
                            continue;
                        }

                        if (name.StartsWith("T:"))
                        {
                            var vkDocType = GetVkDocType(xml);
                            if (!vkDocType.FullName.StartsWith("JetBrains.Annotations"))
                            {
                                Types.Add(vkDocType);
                            }
                        }

                        if (name.StartsWith("M:"))
                        {
                            Methods.Add(GetVkDocMethod(xml));
                        }

                        if (name.StartsWith("P:"))
                        {
                            Properties.Add(GetVkDocProperty(xml));
                        }

                        if (name.StartsWith("F:"))
                        {
                            EnumItems.Add(GetVkDocEnumItem(xml));
                        }
                    }
                }
            }

            foreach (VkDocType type in Types)
            {
                VkDocType          t       = type;
                List <VkDocMethod> methods = Methods.Where(m => m.FullName.StartsWith(t.FullName)).ToList();
                t.Methods = methods;
                methods.ForEach(x => x.Type = t);

                List <VkDocProperty> properties = Properties.Where(m => m.FullName.StartsWith(t.FullName)).ToList();
                t.Properties = properties;
                properties.ForEach(x => x.Type = t);

                List <VkDocEnumItem> enumItems = EnumItems.Where(m => m.FullName.StartsWith(t.FullName)).ToList();
                t.EnumItems = enumItems;
                enumItems.ForEach(x => x.Type = t);
            }

            return(Types);
        }