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)); }
public void BeginList(CodeListStyle style = CodeListStyle.SingleLine) { _commaListGroups.Push(_currentListSize); _listStyleStack.Push(ListStyle); ListStyle = style; _currentListSize = 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); } }
public ListNode(CodeListStyle style) { ListStyle = style; }