コード例 #1
0
            public HtmlElementPrinter(String tagName, int stackDepth, HtmlElementPrinter parentElementPrinter)
            {
                this.tagName              = tagName;
                this.stackDepth           = stackDepth;
                this.parentElementPrinter = parentElementPrinter;

                //create the appropriate indentation strategy for this element
                this.indentStrategy = CreateIndentStrategy(tagName, this);
            }
コード例 #2
0
            public BlockElementIndentStrategy(HtmlElementPrinter elementPrinter)
                : base(elementPrinter)
            {
                //if this element is is the very first content in the parent element, then suppress
                //adding the visual line break so that we don't end up with extra whitespace.
                HtmlElementPrinter parent = elementPrinter.getParent();

                if (parent != null)
                {
                    forceVisualLeadingLineBreak = parent.ChildCount > 0;
                }
            }
コード例 #3
0
        public void WriteStartElement(String name)
        {
            HtmlElementPrinter currentPrinter = null;

            if (openElements.Count > 0)
            {
                currentPrinter = GetCurrentElementPrinter();
            }

            HtmlElementPrinter elementPrinter = new HtmlElementPrinter(name, openElements.Count, currentPrinter);

            if (currentPrinter != null)
            {
                currentPrinter.BeforeAddChildElement(sb, name);
            }

            elementPrinter.WriteElementStart(sb);
            openElements.Push(elementPrinter);
        }
コード例 #4
0
 public ElementIndentStrategy(HtmlElementPrinter elementPrinter)
 {
     this.elementPrinter = elementPrinter;
 }
コード例 #5
0
 private static ElementIndentStrategy CreateIndentStrategy(String tagName, HtmlElementPrinter printer)
 {
     if (BlockTagNames.ContainsKey(tagName))
     {
         return(new BlockElementIndentStrategy(printer));
     }
     else
     {
         return(new ElementIndentStrategy(printer));
     }
 }
コード例 #6
0
        public void WriteEndElement(bool requiresEndTag)
        {
            HtmlElementPrinter elementPrinter = (HtmlElementPrinter)openElements.Pop();

            elementPrinter.WriteElementEnd(sb, requiresEndTag);
        }
コード例 #7
0
 public BlockElementIndentStrategy(HtmlElementPrinter elementPrinter)
     : base(elementPrinter)
 {
     //if this element is is the very first content in the parent element, then supress
     //adding the visual line break so that we don't end up with extra whitespace.
     HtmlElementPrinter parent = elementPrinter.getParent();
     if (parent != null)
         forceVisualLeadingLineBreak = parent.ChildCount > 0;
 }
コード例 #8
0
 public ElementIndentStrategy(HtmlElementPrinter elementPrinter)
 {
     this.elementPrinter = elementPrinter;
 }
コード例 #9
0
 private static ElementIndentStrategy CreateIndentStrategy(String tagName, HtmlElementPrinter printer)
 {
     if (BlockTagNames.ContainsKey(tagName))
         return new BlockElementIndentStrategy(printer);
     else
         return new ElementIndentStrategy(printer);
 }
コード例 #10
0
            public HtmlElementPrinter(String tagName, int stackDepth, HtmlElementPrinter parentElementPrinter)
            {
                this.tagName = tagName;
                this.stackDepth = stackDepth;
                this.parentElementPrinter = parentElementPrinter;

                //create the appropriate indentation stategy for this element
                this.indentStrategy = CreateIndentStrategy(tagName, this);
            }
コード例 #11
0
        public void WriteStartElement(String name)
        {
            HtmlElementPrinter currentPrinter = null;
            if (openElements.Count > 0)
            {
                currentPrinter = GetCurrentElementPrinter();
            }

            HtmlElementPrinter elementPrinter = new HtmlElementPrinter(name, openElements.Count, currentPrinter);

            if (currentPrinter != null)
                currentPrinter.BeforeAddChildElement(sb, name);

            elementPrinter.WriteElementStart(sb);
            openElements.Push(elementPrinter);
        }