public static ViewNode Create(Node node) { var viewNode = new ViewNode { NiceUrl = node.NiceUrl, TemplateId = node.template, Name = node.Name, Level = node.Level, Id = node.Id, Properties = node.PropertiesAsList, StatusMessage = new StatusMessage { Success = true }, HostName = GetHostname() }; GetChildrenRecursive(node, viewNode); return viewNode; }
private static void GetChildrenRecursive(INode node, ViewNode viewNode) { viewNode.Children = new List<ViewNode>(); foreach (var child in node.ChildrenAsList) { var temp = new ViewNode { NiceUrl = child.NiceUrl, TemplateId = child.template, Name = child.Name, Level = child.Level, Id = child.Id, Properties = child.PropertiesAsList, StatusMessage = new StatusMessage {Success = true}, HostName = GetHostname(), Children = new List<ViewNode>() }; viewNode.Children.Add(temp); if(child.ChildrenAsList.Any()) GetChildrenRecursive(child, temp); } }