Exemplo n.º 1
0
        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(">");
        }