WatchNode Process(Expression eIn, ref string content, string prefix, int count) { content += prefix + string.Format("[{0}]:", count.ToString()); WatchNode node = null; if (eIn.IsContainer) { if ((eIn as Expression.Container).Item != null) { //TODO: make clickable hyperlinks to show the element in Revit //http://stackoverflow.com/questions/7890159/programmatically-make-textblock-with-hyperlink-in-between-text string id = ""; Element revitEl = (eIn as Expression.Container).Item as Autodesk.Revit.DB.Element; if (revitEl != null) { id = revitEl.Id.ToString(); } content += (eIn as Expression.Container).Item.ToString() + ":" + id + "\n"; node = new WatchNode((eIn as Expression.Container).Item.ToString()); node.Link = id; } } else if (eIn.IsFunction || eIn.IsSpecial) { content += eIn.ToString() + "\n"; node = new WatchNode(eIn.ToString()); } else if (eIn.IsList) { content += eIn.GetType().ToString() + "\n"; string newPrefix = prefix + "\t"; int innerCount = 0; node = new WatchNode(eIn.GetType().ToString()); foreach(Expression eIn2 in (eIn as Expression.List).Item) { node.Children.Add(Process(eIn2, ref content, newPrefix, innerCount)); innerCount++; } } else if (eIn.IsNumber) { content += (eIn as Expression.Number).Item.ToString() + "\n"; node = new WatchNode((eIn as Expression.Number).Item.ToString()); } else if (eIn.IsString) { content += (eIn as Expression.String).Item.ToString() + "\n"; node = new WatchNode((eIn as Expression.String).Item.ToString()); } else if (eIn.IsSymbol) { content += (eIn as Expression.Symbol).Item.ToString() + "\n"; node = new WatchNode((eIn as Expression.Symbol).Item.ToString()); } return node; }