private ElementNode FindOrCreateElementNode(ElementModel elementModel, ElementNode parentNode) { ElementNode node; if (!_elementModelMap.TryGetValue(elementModel.Id, out node)) { //We have not created our element yet node = ElementNodeService.Instance.CreateSingle(parentNode, NamingUtilities.Uniquify(_elementNames, TokenizeName(elementModel.Name))); _elementModelMap.Add(elementModel.Id, node); _elementNames.Add(node.Name); if (elementModel.IsLightNode) { var order = node.Properties.Add(OrderDescriptor.ModuleId) as OrderModule; if (order != null) { order.Order = elementModel.Order; } _leafNodes.Add(node); PreviewCustomProp.AddLightNodes(elementModel, node); } } else { //Our element exists, so add this one as a child. parentNode.AddChild(node); } return(node); }
public void VisitElement(ElementNode node) { if (Exiting) { if (node.SelfCloseTag) { Payload.Append(" />"); } else if (node.HasCloseTag) { Payload.Append("</"); Payload.Append(node.Name); Payload.Append(">"); } return; } Payload.Append("<"); Payload.Append(node.Name); if (node.Attributes.Count > 0) { foreach (KeyValuePair <string, string> attr in node.Attributes) { if (BindVals != null) { if (SillyAttribute.IsSillyAttribute(attr.Key)) { SillyAttribute boundAttr = null; if (BindVals.TryGetValue(attr.Value, out boundAttr)) { node.DeleteChildren(); if (boundAttr.BoundValues().Count == 0) { node.AddChild(new TextNode("Error rendering " + attr.Value + ": trying to bind null node")); } else { foreach (TreeNodeGizmo childNode in boundAttr.BoundValues()) { node.AddChild(childNode); } } continue; } } } Payload.Append(" "); Payload.Append(attr.Key); if (!String.IsNullOrEmpty(attr.Value)) { Payload.Append("=\""); Payload.Append(attr.Value); Payload.Append("\""); } } } Payload.Append(">"); }