Example #1
0
        public string List <T>(IEnumerable <T> items, CodeListStyle style, Func <T, string> exp)
        {
            var enumerator = items.GetEnumerator();

            if (!enumerator.MoveNext())
            {
                return("");
            }

            var argNode = new PascalTree();

            var currentTarget = Target;
            var currentIndex  = Index;

            Target = argNode;
            Index  = 0;

            List(style, () =>
            {
                foreach (var item in items)
                {
                    ListItem(exp(item));
                }
            });

            Target = currentTarget;
            Index  = currentIndex;

            return(InlineNode(argNode));
        }
Example #2
0
        public void BeginList(CodeListStyle style = CodeListStyle.SingleLine)
        {
            _commaListGroups.Push(_currentListSize);
            _listStyleStack.Push(ListStyle);

            ListStyle        = style;
            _currentListSize = 0;
        }
Example #3
0
        public void List(CodeListStyle style, Action content)
        {
            var list = new ListNode(style);

            InsertAndPushTarget(list);
            InsertAndPushTarget(new ListItemNode());
            content();
            PopTarget();
            PopTarget();

            if (list.Children.Count != 0 && ((PascalTree)list.Children.Last()).Children.Count == 0)
            {
                list.Children.RemoveAt(list.Children.Count - 1);
            }
        }
Example #4
0
 public ListNode(CodeListStyle style)
 {
     ListStyle = style;
 }