示例#1
0
        //-----------------------------------------------
        // Helper methods
        //-----------------------------------------------

        private void FlushAttributes()
        {
            int    idx = 0, idxNext;
            string localName;

            while (idx != _numEntries)
            {
                // Get index of next attribute's name (0 if this is the last attribute)
                idxNext = _arrAttrs[idx].NextNameIndex;
                if (idxNext == 0)
                {
                    idxNext = _numEntries;
                }

                // If localName is null, then this is a duplicate attribute that has been marked as "deleted"
                localName = _arrAttrs[idx].LocalName;
                if (localName != null)
                {
                    string prefix = _arrAttrs[idx].Prefix;
                    string ns     = _arrAttrs[idx].Namespace;

                    _wrapped.WriteStartAttribute(prefix, localName, ns);

                    // Output all of this attribute's text or typed values
                    while (++idx != idxNext)
                    {
                        string text = _arrAttrs[idx].Text;

                        if (text != null)
                        {
                            _wrapped.WriteString(text);
                        }
                        else
                        {
                            _wrapped.WriteValue(_arrAttrs[idx].Value);
                        }
                    }

                    _wrapped.WriteEndAttribute();
                }
                else
                {
                    // Skip over duplicate attributes
                    idx = idxNext;
                }
            }

            // Notify event listener that attributes have been flushed
            if (_onRemove != null)
            {
                _onRemove(_wrapped);
            }
        }