Example #1
0
        private static void WriteList(DocumentationWriter writer, IEnumerable <XElement> elements, bool isOrdered = false)
        {
            int number = 1;

            using (IEnumerator <XElement> en = Iterator().GetEnumerator())
            {
                if (en.MoveNext())
                {
                    if (isOrdered)
                    {
                        writer.WriteStartOrderedList();
                    }
                    else
                    {
                        writer.WriteStartBulletList();
                    }

                    do
                    {
                        WriteStartItem();
                        WriteContentTo(en.Current, writer, inlineOnly: true);
                        WriteEndItem();
                    } while (en.MoveNext());

                    if (isOrdered)
                    {
                        writer.WriteEndOrderedList();
                    }
                    else
                    {
                        writer.WriteEndBulletList();
                    }
                }
            }

            IEnumerable <XElement> Iterator()
            {
                foreach (XElement element in elements)
                {
                    if (element.Name.LocalName == "item")
                    {
                        using (IEnumerator <XElement> en = element.Elements().GetEnumerator())
                        {
                            if (en.MoveNext())
                            {
                                XElement element2 = en.Current;

                                if (element2.Name.LocalName == "description")
                                {
                                    yield return(element2);
                                }
                            }
                            else
                            {
                                yield return(element);
                            }
                        }
                    }
                }
            }

            void WriteStartItem()
            {
                if (isOrdered)
                {
                    writer.WriteStartOrderedItem(number);
                    number++;
                }
                else
                {
                    writer.WriteStartBulletItem();
                }
            }

            void WriteEndItem()
            {
                if (isOrdered)
                {
                    writer.WriteEndOrderedItem();
                }
                else
                {
                    writer.WriteEndBulletItem();
                }
            }
        }