Exemplo n.º 1
0
            private void writeToString(ref string output, int tab_depth)
            {
                // tab strings for nicer formatting...
                int    i          = 0;
                string sTab_space = "";

                while (i < tab_depth)
                {
                    sTab_space += "\t";
                    i++;
                }
                bool isElement = this.GetEType() == EDataType.e_element;

                jDebug.jASSERT(GetEType() <= EDataType.e_element);

                // add opening tag to output
                output += sTab_space;
                output += "<" + this.GetTagNameFull();
                // add attributes to opening tag
                if (m_AttrList != null)
                {
                    foreach (var a in m_AttrList)
                    {
                        output += (" " + a.Value.GetTagNameFull() + "=\"" + a.Value.ConvertToString() + "\" ");
                        i++;
                    }
                }
                //output += ("{{ " + GetTagName() + "= " + this.GetEType().ToString() + "}}");

                if (size() == 0)
                {
                    // if textnode add content to output return early...
                    if (isElement)
                    {
                        output += "/>\n";
                        return;
                    }
                    else
                    {
                        output += ">";
                        output += Base().ConvertToString();
                    }
                }
                else
                {
                    jDebug.jASSERT(IsEType(EDataType.e_element));
                    output += ">";
                    output += ("\n");
                    // recurse through all child elements
                    for (jxE e = m_Child; e != null; e = e.m_Next)
                    {
                        e.writeToString(ref output, tab_depth + 1);
                    }
                }
                // close opening tag

                if (isElement)
                {
                    output += sTab_space;
                }
                output += "</" + GetTagNameFull() + ">\n";
            }