Esempio n. 1
0
        public override void WriteStartElement(string prefix, string localName, string ns)
        {
            Debug.Assert(localName != null && localName.Length != 0 && prefix != null && ns != null);

            _elementScope.Push((byte)_currentElementProperties);

            if (ns.Length == 0)
            {
                Debug.Assert(prefix.Length == 0);

                if (_trackTextContent && _inTextContent)
                {
                    ChangeTextContentMark(false);
                }

                _currentElementProperties = TernaryTreeReadOnly.FindElementProperty(localName);
                base._bufChars[_bufPos++] = (char)'<';
                base.RawText(localName);
                base._attrEndPos = _bufPos;
            }
            else
            {
                // Since the HAS_NS has no impact to the ElementTextBlock behavior,
                // we don't need to push it into the stack.
                _currentElementProperties = ElementProperties.HAS_NS;
                base.WriteStartElement(prefix, localName, ns);
            }
        }
Esempio n. 2
0
 private void Init(XmlWriterSettings settings)
 {
     if (elementPropertySearch == null)
     {
         attributePropertySearch = new TernaryTreeReadOnly(HtmlTernaryTree.htmlAttributes);
         elementPropertySearch   = new TernaryTreeReadOnly(HtmlTernaryTree.htmlElements);
     }
     this.elementScope             = new ByteStack(10);
     this.uriEscapingBuffer        = new byte[5];
     this.currentElementProperties = ElementProperties.DEFAULT;
     this.mediaType = settings.MediaType;
 }
 private void Init(XmlWriterSettings settings)
 {
     if (elementPropertySearch == null)
     {
         attributePropertySearch = new TernaryTreeReadOnly(HtmlTernaryTree.htmlAttributes);
         elementPropertySearch = new TernaryTreeReadOnly(HtmlTernaryTree.htmlElements);
     }
     this.elementScope = new ByteStack(10);
     this.uriEscapingBuffer = new byte[5];
     this.currentElementProperties = ElementProperties.DEFAULT;
     this.mediaType = settings.MediaType;
 }
Esempio n. 4
0
        public override void WriteStartAttribute(string prefix, string localName, string ns)
        {
            Debug.Assert(localName != null && localName.Length != 0 && prefix != null && ns != null);

            if (ns.Length == 0)
            {
                Debug.Assert(prefix.Length == 0);

                if (_trackTextContent && _inTextContent)
                {
                    ChangeTextContentMark(false);
                }

                if (base._attrEndPos == _bufPos)
                {
                    base._bufChars[_bufPos++] = (char)' ';
                }
                base.RawText(localName);

                if ((_currentElementProperties & (ElementProperties.BOOL_PARENT | ElementProperties.URI_PARENT | ElementProperties.NAME_PARENT)) != 0)
                {
                    _currentAttributeProperties = TernaryTreeReadOnly.FindAttributeProperty(localName) &
                                                  (AttributeProperties)_currentElementProperties;

                    if ((_currentAttributeProperties & AttributeProperties.BOOLEAN) != 0)
                    {
                        base._inAttributeValue = true;
                        return;
                    }
                }
                else
                {
                    _currentAttributeProperties = AttributeProperties.DEFAULT;
                }

                base._bufChars[_bufPos++] = (char)'=';
                base._bufChars[_bufPos++] = (char)'"';
            }
            else
            {
                base.WriteStartAttribute(prefix, localName, ns);
                _currentAttributeProperties = AttributeProperties.DEFAULT;
            }

            base._inAttributeValue = true;
        }
Esempio n. 5
0
        public override void WriteStartElement(string prefix, string localName, string ns)
        {
            Debug.Assert(localName != null && localName.Length != 0 && prefix != null && ns != null);

            if (_trackTextContent && _inTextContent)
            {
                ChangeTextContentMark(false);
            }

            base._elementScope.Push((byte)base._currentElementProperties);

            if (ns.Length == 0)
            {
                Debug.Assert(prefix.Length == 0);

                base._currentElementProperties = TernaryTreeReadOnly.FindElementProperty(localName);

                if (_endBlockPos == base._bufPos && (base._currentElementProperties & ElementProperties.BLOCK_WS) != 0)
                {
                    WriteIndent();
                }
                _indentLevel++;

                base._bufChars[_bufPos++] = (char)'<';
            }
            else
            {
                base._currentElementProperties = ElementProperties.HAS_NS | ElementProperties.BLOCK_WS;

                if (_endBlockPos == base._bufPos)
                {
                    WriteIndent();
                }
                _indentLevel++;

                base._bufChars[base._bufPos++] = (char)'<';
                if (prefix.Length != 0)
                {
                    base.RawText(prefix);
                    base._bufChars[base._bufPos++] = (char)':';
                }
            }
            base.RawText(localName);
            base._attrEndPos = _bufPos;
        }
//
// Private methods
//

        private void Init(XmlWriterSettings settings)
        {
            Debug.Assert((int)ElementProperties.URI_PARENT == (int)AttributeProperties.URI);
            Debug.Assert((int)ElementProperties.BOOL_PARENT == (int)AttributeProperties.BOOLEAN);
            Debug.Assert((int)ElementProperties.NAME_PARENT == (int)AttributeProperties.NAME);

            if (elementPropertySearch == null)
            {
                //elementPropertySearch should be init last for the mutli thread safe situation.
                attributePropertySearch = new TernaryTreeReadOnly(HtmlTernaryTree.htmlAttributes);
                elementPropertySearch   = new TernaryTreeReadOnly(HtmlTernaryTree.htmlElements);
            }

            elementScope             = new ByteStack(StackIncrement);
            uriEscapingBuffer        = new byte[5];
            currentElementProperties = ElementProperties.DEFAULT;

            mediaType = settings.MediaType;
        }
Esempio n. 7
0
        private void Init(XmlWriterSettings settings)
        {
            Debug.Assert((int)ElementProperties.URI_PARENT == (int)AttributeProperties.URI);
            Debug.Assert((int)ElementProperties.BOOL_PARENT == (int)AttributeProperties.BOOLEAN);
            Debug.Assert((int)ElementProperties.NAME_PARENT == (int)AttributeProperties.NAME);

            if (elementPropertySearch == null)
            {
                //elementPropertySearch should be init last for the mutli thread safe situation.
                attributePropertySearch = new TernaryTreeReadOnly(HtmlTernaryTree.htmlAttributes);
                elementPropertySearch = new TernaryTreeReadOnly(HtmlTernaryTree.htmlElements);
            }

            elementScope = new ByteStack(StackIncrement);
            _uriEscapingBuffer = new byte[5];
            currentElementProperties = ElementProperties.DEFAULT;

            _mediaType = settings.MediaType;
            _doNotEscapeUriAttributes = settings.DoNotEscapeUriAttributes;
        }