Example #1
0
        private TopicSection ReadSection(XmlReader reader, DirectoryPath root)
        {
            var id     = reader.GetAttribute("id");
            var title  = reader.GetAttribute("title");
            var hidden = string.Equals("true", reader.GetAttribute("hidden"), StringComparison.OrdinalIgnoreCase);

            if (string.IsNullOrWhiteSpace(id))
            {
                id = title.ToSlug();
            }

            var topics = new List <Topic>();

            while (reader.Read())
            {
                if (!reader.IsStartElement() && reader.Name == "section")
                {
                    break;
                }
                if (reader.IsStartElement() && reader.Name == "item")
                {
                    var topic = ReadTopic(reader, root);
                    if (topic != null)
                    {
                        topics.Add(topic);
                    }
                }
            }

            var section = new TopicSection(id, title, hidden, topics);

            foreach (var topic in topics)
            {
                topic.Section = section;
            }
            return(section);
        }
Example #2
0
 public static string GetLink(TopicSection section)
 {
     return string.Concat("/docs/", section.Id);
 }
Example #3
0
        private TopicSection ReadSection(XmlReader reader, DirectoryPath root)
        {
            var id = reader.GetAttribute("id");
            var title = reader.GetAttribute("title");
            var hidden = string.Equals("true", reader.GetAttribute("hidden"), StringComparison.OrdinalIgnoreCase);

            if (string.IsNullOrWhiteSpace(id))
            {
                id = title.ToSlug();
            }

            var topics = new List<Topic>();
            while (reader.Read())
            {
                if (!reader.IsStartElement() && reader.Name == "section")
                {
                    break;
                }
                if (reader.IsStartElement() && reader.Name == "item")
                {
                    var topic = ReadTopic(reader, root);
                    if (topic != null)
                    {
                        topics.Add(topic);
                    }
                }
            }

            var section = new TopicSection(id, title, hidden, topics);
            foreach (var topic in topics)
            {
                topic.Section = section;
            }
            return section;
        }