Esempio n. 1
0
        private static int FormatStart(TextBuffer buffer, int offset, string suffix, string elementName)
        {
            TextIter insertAt = buffer.GetIterAtOffset(offset);

            switch (elementName)
            {
            case "AssemblyName":
                DocumentUtils.AddString(buffer, ref insertAt, "Assembly Name: ", suffix);
                break;

            case "AssemblyPublicKey":
                DocumentUtils.AddString(buffer, ref insertAt, "Assembly PublicKey: ", suffix);
                break;

            case "AssemblyVersion":
                DocumentUtils.AddString(buffer, ref insertAt, "Assembly Version: ", suffix);
                break;

            case "MemberOfLibrary":
                DocumentUtils.AddString(buffer, ref insertAt, "From Library: ", suffix);
                break;

            case "ThreadSafetyStatement":
                DocumentUtils.AddString(buffer, ref insertAt, "Threading Safety: ", suffix);
                break;

            case "ThreadingSafetyStatement":
                DocumentUtils.AddString(buffer, ref insertAt, "Threading Safety: ", suffix);
                break;

            case "summary":
                DocumentUtils.AddString(buffer, ref insertAt, "Summary:\n", suffix);
                break;

            case "remarks":
                DocumentUtils.AddString(buffer, ref insertAt, "Remarks:\n", suffix);
                break;

            case "Members":
                DocumentUtils.AddString(buffer, ref insertAt, "Members:\n\n", suffix);
                break;

            case "MemberType":
                DocumentUtils.AddString(buffer, ref insertAt, "Member Type: ", suffix);
                break;

            case "ReturnType":
                DocumentUtils.AddString(buffer, ref insertAt, "Member Return Type: ", suffix);
                break;

            case "since":
                DocumentUtils.AddString(buffer, ref insertAt, "Since version: ", suffix);
                break;

            default:
                break;
            }

            return(insertAt.Offset);
        }
Esempio n. 2
0
        private static void DeserializeAttributesType(TextBuffer buffer, ref TextIter insertAt, XmlTextReader xmlReader, string tagSuffix)
        {
            string tagName   = String.Empty;
            string tagPrefix = xmlReader.Name + ":";

            DocumentTagTable tagTable = (DocumentTagTable)buffer.TagTable;

            while (xmlReader.MoveToNextAttribute())
            {
                tagName = tagPrefix + xmlReader.Name + tagSuffix;

                TextTag tag = tagTable.Lookup(tagName);
                if (tag == null)
                {
                    tag = tagTable.CreateDynamicTag(tagName);
                }

                buffer.InsertWithTags(ref insertAt, xmlReader.Value, tag);

                        #if DEBUG
                Console.WriteLine("Attribute: {0} End: {1}", tagName, insertAt.Offset);
                        #endif
            }

            DocumentUtils.AddNewLine(buffer, ref insertAt, tagSuffix);
        }
Esempio n. 3
0
        public void AddPaddingEmptyIntOffset()
        {
            int            initialOffset = 0;
            DocumentEditor editor        = new DocumentEditor();
            TextBuffer     buffer        = editor.Buffer;

            int nextOffset = DocumentUtils.AddPaddingEmpty(buffer, initialOffset, "#0");

            Assert.AreEqual(1, nextOffset, "APEIO");
        }
Esempio n. 4
0
        public void AddPaddingEmptyVoidOffset()
        {
            DocumentEditor editor = new DocumentEditor();
            TextBuffer     buffer = editor.Buffer;

            TextIter insertIter = buffer.StartIter;

            DocumentUtils.AddPaddingEmpty(buffer, ref insertIter, "#0");

            Assert.AreEqual(1, insertIter.Offset, "APEVO");
        }
Esempio n. 5
0
        public void AddStringIntOffset()
        {
            int            initialOffset, nextOffset;
            string         data   = "Inserting format Region";
            DocumentEditor editor = new DocumentEditor();
            TextBuffer     buffer = editor.Buffer;

            initialOffset = 0;

            nextOffset = DocumentUtils.AddString(buffer, initialOffset, data, "#0");
            Assert.AreEqual(data.Length + 1, nextOffset, "ASIO");
        }
Esempio n. 6
0
        public void AddStringVoidOffset()
        {
            string         data   = "Inserting format Region";
            DocumentEditor editor = new DocumentEditor();
            TextBuffer     buffer = editor.Buffer;

            TextIter insertIter = buffer.StartIter;

            DocumentUtils.AddString(buffer, ref insertIter, data, "#0");

            Assert.AreEqual(data.Length + 1, insertIter.Offset, "ASVO");
        }
Esempio n. 7
0
        private static void GetEndTags(TextIter currentIter, TextIter nextIter, TextTag [] tagArray, ArrayList endTags)
        {
            Array.Reverse(tagArray);
            foreach (TextTag tag in tagArray)
            {
                if (!DocumentUtils.TagEndsHere(tag, currentIter, nextIter))
                {
                    continue;
                }

                endTags.Add(tag);
            }
        }
Esempio n. 8
0
        public void GetAssociatedTextTag()
        {
            DocumentEditor editor = new DocumentEditor();
            TextBuffer     buffer = editor.Buffer;

            TextTag summaryTag = buffer.TagTable.Lookup("summary");

            Assert.IsNotNull(summaryTag);
            DocumentTag actualTag = (DocumentTag)DocumentUtils.GetAssociatedTextTag(buffer, summaryTag);

            Assert.AreEqual("summary:Text", actualTag.Name);
            Assert.IsTrue(actualTag.IsText);
        }
Esempio n. 9
0
        public void TagEndsHereSimple()
        {
            DocumentEditor editor = new DocumentEditor();
            TextBuffer     buffer = editor.Buffer;

            TextIter insertIter = buffer.StartIter;

            buffer.InsertWithTagsByName(ref insertIter, "Example Region", "Type");

            TextIter endIter  = buffer.GetIterAtOffset(insertIter.Offset - 1);
            TextIter nextIter = buffer.GetIterAtOffset(insertIter.Offset);
            bool     endsTag  = DocumentUtils.TagEndsHere(buffer.TagTable.Lookup("Type"), endIter, nextIter);

            Assert.IsTrue(endsTag, "TEH01");
        }
Esempio n. 10
0
        private static int InsertText(TextBuffer buffer, int offset, string data, Stack stack)
        {
            TagStart tagStart = (TagStart)stack.Peek();
            TextIter insertAt = buffer.GetIterAtOffset(offset);
            TextTag  textTag  = DocumentUtils.GetAssociatedTextTag(buffer, tagStart.Tag);

            DocumentUtils.AddText(buffer, ref insertAt, data, textTag);
//		buffer.InsertWithTags (ref insertAt, data, textTag);

                #if DEBUG
            Console.WriteLine("Text: {0} Value: {1} Start: {2}", textTag.Name, data, offset);
                #endif

            return(insertAt.Offset);
        }
Esempio n. 11
0
        public void AddPaddingEmptyVoidValidRegion()
        {
            DocumentEditor editor = new DocumentEditor();
            TextBuffer     buffer = editor.Buffer;

            TextIter insertIter = buffer.StartIter;

            DocumentUtils.AddPaddingEmpty(buffer, ref insertIter, "#0");

            TextTag expectedTag   = buffer.TagTable.Lookup("padding-empty#0");
            bool    beginsPadding = buffer.StartIter.BeginsTag(expectedTag);
            bool    endsPadding   = DocumentUtils.TagEndsHere(expectedTag, buffer.GetIterAtOffset(insertIter.Offset - 1), insertIter);

            Assert.IsTrue(beginsPadding, "APEVR01");
            Assert.IsTrue(endsPadding, "APEVR02");
        }
Esempio n. 12
0
        private static void GetArrays(TextIter currentIter, TextIter nextIter, ArrayList beginTags, ArrayList endTags)
        {
            TextTag [] tags       = currentIter.Tags;
            int        last_index = tags.Length - 1;
            TextTag    last       = tags [last_index];

            if (currentIter.BeginsTag(last))
            {
                GetBeginTags(currentIter, tags, beginTags);
            }

            if (DocumentUtils.TagEndsHere(last, currentIter, nextIter))
            {
                GetEndTags(currentIter, nextIter, tags, endTags);
            }
        }
Esempio n. 13
0
        public void AddPaddingEmptyIntValidRegion()
        {
            int            initialOffset, endOffset, nextOffset;
            DocumentEditor editor = new DocumentEditor();
            TextBuffer     buffer = editor.Buffer;

            initialOffset = 0;
            nextOffset    = DocumentUtils.AddPaddingEmpty(buffer, initialOffset, "#0");
            endOffset     = nextOffset - 1;

            TextTag expectedTag   = buffer.TagTable.Lookup("padding-empty#0");
            bool    beginsPadding = buffer.GetIterAtOffset(initialOffset).BeginsTag(expectedTag);
            bool    endsPadding   = DocumentUtils.TagEndsHere(expectedTag, buffer.GetIterAtOffset(endOffset), buffer.GetIterAtOffset(nextOffset));

            Assert.IsTrue(beginsPadding, "APEIVR01");
            Assert.IsTrue(endsPadding, "APEIVR02");
        }
Esempio n. 14
0
        public void AddNewLineInt()
        {
            int            initialOffset, endOffset, nextOffset;
            DocumentEditor editor = new DocumentEditor();
            TextBuffer     buffer = editor.Buffer;

            initialOffset = 0;
            nextOffset    = DocumentUtils.AddNewLine(buffer, initialOffset, "#0");
            endOffset     = nextOffset - 1;

            TextTag expectedTag   = buffer.TagTable.Lookup("newline#0");
            bool    beginsNewLine = buffer.GetIterAtOffset(initialOffset).BeginsTag(expectedTag);
            bool    endsNewLine   = DocumentUtils.TagEndsHere(expectedTag, buffer.GetIterAtOffset(endOffset), buffer.GetIterAtOffset(nextOffset));

            Assert.IsTrue(beginsNewLine, "ANLI01");
            Assert.IsTrue(endsNewLine, "ANLI02");
        }
Esempio n. 15
0
        public void AddStringVoidValidRegion()
        {
            string         data   = "Inserting format Region";
            DocumentEditor editor = new DocumentEditor();
            TextBuffer     buffer = editor.Buffer;

            TextIter insertIter = buffer.StartIter;

            DocumentUtils.AddString(buffer, ref insertIter, data, "#0");

            TextTag expectedTag  = buffer.TagTable.Lookup("format#0");
            bool    beginsFormat = buffer.StartIter.BeginsTag(expectedTag);
            bool    endsFormat   = DocumentUtils.TagEndsHere(expectedTag, buffer.GetIterAtOffset(insertIter.Offset - 2), buffer.GetIterAtOffset(insertIter.Offset - 1));

            Assert.IsTrue(beginsFormat, "ASVR01");
            Assert.IsTrue(endsFormat, "ASVR02");
        }
Esempio n. 16
0
        public void AddStringIntValidRegion()
        {
            int            initialOffset, endOffset, nextOffset;
            string         data   = "Inserting format Region";
            DocumentEditor editor = new DocumentEditor();
            TextBuffer     buffer = editor.Buffer;

            initialOffset = 0;
            nextOffset    = DocumentUtils.AddString(buffer, initialOffset, data, "#0");
            endOffset     = nextOffset - 2;

            TextTag expectedTag  = buffer.TagTable.Lookup("format#0");
            bool    beginsFormat = buffer.GetIterAtOffset(initialOffset).BeginsTag(expectedTag);
            bool    endsFormat   = DocumentUtils.TagEndsHere(expectedTag, buffer.GetIterAtOffset(endOffset), buffer.GetIterAtOffset(nextOffset - 1));

            Assert.IsTrue(beginsFormat, "ASIVR01");
            Assert.IsTrue(endsFormat, "ASIVR02");
        }
Esempio n. 17
0
        public void GetLastTag()
        {
            DocumentEditor editor = new DocumentEditor();
            TextBuffer     buffer = editor.Buffer;

            TextIter insertIter = buffer.StartIter;

            buffer.Insert(ref insertIter, "Start Extern Region ");
            buffer.InsertWithTagsByName(ref insertIter, "Intern Region", "Type:Attributes");
            int index = insertIter.Offset - 1;

            buffer.Insert(ref insertIter, "End Extern Region");
            buffer.ApplyTag("Type", buffer.StartIter, insertIter);

            TextTag expectedTag = buffer.TagTable.Lookup("Type:Attributes");
            TextTag actualTag   = DocumentUtils.GetLastTag(buffer.GetIterAtOffset(index));

            Assert.AreEqual(expectedTag, actualTag, "GLT01");
        }
Esempio n. 18
0
        private static int InsertEndElement(TextBuffer buffer, int offset, Stack stack, ref int depth)
        {
            TextIter insertAt, applyStart, applyEnd;
            TagStart tagStart = (TagStart)stack.Pop();
            string   suffix   = '#' + depth.ToString();

                #if DEBUG
            Console.WriteLine("Element: {0}, End: {1}", tagStart.Tag.Name, offset);
                #endif

            if (((DocumentTag)tagStart.Tag).IsEditable)
            {
                if (tagStart.Start + 1 == offset)
                {
                    offset = DocumentUtils.AddStub(buffer, offset, "To be added test", suffix);
                }

                insertAt = buffer.GetIterAtOffset(offset);
                buffer.Insert(ref insertAt, "]");
                offset += 1;
            }
            else if (tagStart.Start == offset)
            {
                offset = DocumentUtils.AddPaddingEmpty(buffer, offset, suffix);
            }

            applyStart = buffer.GetIterAtOffset(tagStart.Start);
            applyEnd   = buffer.GetIterAtOffset(offset);
            buffer.ApplyTag(tagStart.Tag, applyStart, applyEnd);
            offset = FormatEnd(buffer, offset, suffix, tagStart.Name);
            depth--;

                #if DEBUG
            Console.WriteLine("Applied: {0}, Start: {1}, End: {2}", tagStart.Tag.Name, tagStart.Start, offset);
                #endif

            // Padding between tag regions
            suffix = "#" + depth;
            offset = DocumentUtils.AddPadding(buffer, offset, suffix);

            return(offset);
        }
Esempio n. 19
0
        private void OnInsertText(object sender, InsertTextArgs args)
        {
            int    offset = args.Pos.Offset - args.Length;
            string text   = args.Text;

            TextIter previousIter = GetIterAtOffset(offset - 1);      // Previous is the iter before the insert offset.
            TextIter startIter    = GetIterAtOffset(offset);
            TextIter endIter      = GetIterAtOffset(offset + text.Length);

            // Only handle special inserting cases when we have a fully loaded document.
            if (document_loaded)
            {
                        #if DEBUG
                Console.WriteLine("DEBUG: Inserting: {0}", text);
                Console.WriteLine("DEBUG: Start Offset: {0} Char: {1}", startIter.Offset, startIter.Char);
                Console.WriteLine("DEBUG: End Offset: {0} Char: {1}", endIter.Offset, endIter.Char);
                        #endif

                TextTag lastEnd      = DocumentUtils.GetLastTag(endIter);
                TextTag lastPrevious = DocumentUtils.GetLastTag(previousIter);

                if (endIter.BeginsTag(lastEnd) && lastEnd.Editable)
                {
                                #if DEBUG
                    Console.WriteLine("DEBUG: Inserting text at start of editable region.");
                    Console.WriteLine("DEBUG: Tag Name: {0} Char: {1}", lastEnd.Name, endIter.Char);
                                #endif

                    ApplyTag(lastEnd, startIter, endIter);
                }
                else if (DocumentUtils.TagEndsHere(lastPrevious, previousIter, startIter) && lastPrevious.Editable)
                {
                                #if DEBUG
                    Console.WriteLine("DEBUG: Inserting text at end of editable region.");
                    Console.WriteLine("DEBUG: Tag Name: {0} Char: {1}", lastPrevious.Name, previousIter.Char);
                                #endif

                    ApplyTag(lastPrevious, startIter, endIter);
                }
            }
        }
Esempio n. 20
0
        private static int FormatEnd(TextBuffer buffer, int offset, string suffix, string elementName)
        {
            TextIter insertAt = buffer.GetIterAtOffset(offset);

            switch (elementName)
            {
            case "para":
            case "Docs":
            case "Base":
            case "BaseTypeName":
            case "Attribute":
            case "AttributeName":
            case "Members":
            case "Member":
            case "Type":
            case "link":
                break;

            case "see":
            case "since":
            case "paramref":
            case "Parameters":
            case "MemberSignature":
                break;

            case "summary":
            case "ThreadSafetyStatement":
            case "ThreadingSafetyStatement":
                DocumentUtils.AddString(buffer, ref insertAt, "\n\n", suffix);
                break;

            default:
                DocumentUtils.AddString(buffer, ref insertAt, "\n", suffix);
                break;
            }

            return(insertAt.Offset);
        }
Esempio n. 21
0
        public void TagEndsHereOverlaping()
        {
            DocumentEditor editor = new DocumentEditor();
            TextBuffer     buffer = editor.Buffer;

            TextIter insertIter = buffer.StartIter;

            buffer.InsertWithTagsByName(ref insertIter, "Example Region", "Type");
            int firstEndOffset = insertIter.Offset;

            buffer.InsertWithTagsByName(ref insertIter, "Second Region", "Type");

            TextIter firstEndIter   = buffer.GetIterAtOffset(firstEndOffset - 1);
            TextIter firstNextIter  = buffer.GetIterAtOffset(firstEndOffset);
            TextIter secondEndIter  = buffer.GetIterAtOffset(insertIter.Offset - 1);
            TextIter secondNextIter = buffer.GetIterAtOffset(insertIter.Offset);

            bool firstEndsTag  = DocumentUtils.TagEndsHere(buffer.TagTable.Lookup("Type"), firstEndIter, firstNextIter);
            bool secondEndsTag = DocumentUtils.TagEndsHere(buffer.TagTable.Lookup("Type"), secondEndIter, secondNextIter);

            Assert.IsFalse(firstEndsTag, "TEH01");
            Assert.IsTrue(secondEndsTag, "TEH02");
        }
Esempio n. 22
0
        private void OnDeleteRange(object sender, DeleteRangeArgs args)
        {
            TextIter startIter = GetIterAtOffset(args.Start.Offset - 1);
            TextIter endIter   = GetIterAtOffset(args.Start.Offset);

                #if DEBUG
            Console.WriteLine("DEBUG: Deleting range");
                #endif

            bool startsRegion = startIter.Char.Equals("[");
            bool endsRegion   = endIter.Char.Equals("]");

            if (startsRegion && endsRegion)
            {
                        #if DEBUG
                Console.WriteLine("DEBUG: Deleting whole editing region.");
                        #endif

                TextTag last = DocumentUtils.GetAssociatedTextTag(this, DocumentUtils.GetLastTag(startIter));
                Undoer.FreezeUndo();
                InsertWithTags(ref endIter, "Documentation for this section has not yet been entered.", last);
                Undoer.ThrawUndo();
            }
        }
Esempio n. 23
0
        private static int InsertStartElement(TextBuffer buffer, int offset, XmlTextReader xmlReader, Stack stack, ref int depth, ref int count)
        {
            string           elementName = xmlReader.Name;
            string           suffix = String.Empty;
            DocumentTagTable tagTable = (DocumentTagTable)buffer.TagTable;
            bool             emptyElement = xmlReader.IsEmptyElement;
            bool             isDynamic = DocumentTagTable.IsDynamic(elementName);
            TextIter         insertAt, applyStart, applyEnd;

            depth++;

            // We define a suffix so each dynamic tag has an unique name.
            // Suffix has format: #{depth level}
            if (isDynamic)
            {
                suffix = "#" + depth;
            }

            // We add any needed string to give format to the document.
            offset = FormatStart(buffer, offset, suffix, elementName);

            TagStart tagStart = new TagStart();

            tagStart.Start = offset;
            tagStart.Name  = elementName;

            // We first lookup the tag name, if the element is dynamic, we can
            // have three scenarios.
            // 1) The tag is not in the table: So we create it in the spot.
            // 2) Tag is in table but it priority is wrong: We created a new
            // dynamic tag with an extra suffix. Format #{depth level}.{count}
            // 3) Tag is in table with right priority: We reuse it and we don't
            // create a new dymamic tag.
            tagStart.Tag = tagTable.Lookup(elementName + suffix);
            if (isDynamic && tagStart.Tag == null)
            {
                tagStart.Tag = tagTable.CreateDynamicTag(elementName + suffix);
            }
            else if (isDynamic && tagStart.Tag != null && tagStart.Tag.Priority < ((TagStart)stack.Peek()).Tag.Priority)
            {
                suffix      += "." + count;
                tagStart.Tag = tagTable.CreateDynamicTag(elementName + suffix);
                count++;
            }

                #if DEBUG
            try {
                Console.WriteLine("Element: {0} Start: {1}", tagStart.Tag.Name, tagStart.Start);
            } catch (NullReferenceException) {
                Console.WriteLine("Error: Missing {0} element", xmlReader.Name);
                Environment.Exit(1);
            }
                #endif

            // If element has attributes we have to get them and deserialize them.
            if (xmlReader.HasAttributes)
            {
                offset = DeserializeAttributes(buffer, offset, xmlReader, suffix);
            }

            // Special case when an elment is empty.
            // Case A: If element is editable a string stub is inserted to allow edition.
            // Case B: If element is not editable then a padding is inserted to handle
            // TextTag behaviour in which zero length ranges are lost.
            if (emptyElement)
            {
                if (((DocumentTag)tagStart.Tag).IsEditable)
                {
                    insertAt = buffer.GetIterAtOffset(offset);
                    buffer.Insert(ref insertAt, "[");
                    offset += 1;

                    offset = DocumentUtils.AddStub(buffer, offset, "Click to Add Documentation", suffix);

                    insertAt = buffer.GetIterAtOffset(offset);
                    buffer.Insert(ref insertAt, "]");
                    offset += 1;
                }
                else
                {
                    offset = DocumentUtils.AddPaddingEmpty(buffer, offset, suffix);
                }

                applyStart = buffer.GetIterAtOffset(tagStart.Start);
                applyEnd   = buffer.GetIterAtOffset(offset);
                buffer.ApplyTag(tagStart.Tag, applyStart, applyEnd);
                offset = FormatEnd(buffer, offset, suffix, elementName);

                // Padding between tag regions
                offset = DocumentUtils.AddPadding(buffer, offset, suffix);
                depth--;

                        #if DEBUG
                Console.WriteLine("Empty Element: {0}, Start: {1}, End: {2}", tagStart.Tag.Name, tagStart.Start, offset);
                        #endif
            }
            else
            {
                stack.Push(tagStart);

                if (((DocumentTag)tagStart.Tag).IsEditable)
                {
                    insertAt = buffer.GetIterAtOffset(offset);
                    buffer.Insert(ref insertAt, "[");
                    offset += 1;
                }
            }

            return(offset);
        }
Esempio n. 24
0
        public static void Serialize(TextBuffer buffer, TextIter start, TextIter end, XmlTextWriter xmlWriter)
        {
            TextIter    currentIter    = start;
            TextIter    nextIter       = start;
            bool        readingValue   = false;
            bool        readingText    = false;
            string      attributeName  = "";
            string      attributeValue = "";
            string      elementText    = "";
            DocumentTag docTag;

            nextIter.ForwardChar();

            // We iterate over all the buffer.
            while (!currentIter.Equal(end))
            {
                ArrayList beginTags, endTags;
                beginTags = new ArrayList();
                endTags   = new ArrayList();
                GetArrays(currentIter, nextIter, beginTags, endTags);

                        #if DEBUG
                Console.WriteLine("Offset: {0} Char: {1}", currentIter.Offset, currentIter.Char);
                        #endif

                if (readingValue)
                {
                    attributeValue += currentIter.Char;
                }

                if (readingText)
                {
                    elementText += currentIter.Char;
                }

                foreach (TextTag tag in beginTags)
                {
                                #if DEBUG
                    Console.WriteLine("Begin Tags: {0} Begins: {1} Ends: {2}", tag.Name, currentIter.BeginsTag(tag) ? "True" : "False", DocumentUtils.TagEndsHere(tag, currentIter, nextIter)? "True" : "False");
                                #endif

                    docTag = tag as DocumentTag;

                    if (docTag.IsElement)
                    {
                        string elementName = docTag.Name.Split('#')[0];
                        xmlWriter.WriteStartElement(null, elementName, null);

                                        #if DEBUG
                        Console.WriteLine("Wrote Start Element: " + elementName);
                                        #endif
                    }
                    else if (docTag.IsAttribute)
                    {
                        attributeName = docTag.Name.Split(':')[1].Split('#')[0];
                        xmlWriter.WriteStartAttribute(null, attributeName, null);

                                        #if DEBUG
                        Console.WriteLine("Wrote Start Attribute: {0}", attributeName);
                                        #endif

                        readingValue   = true;
                        attributeValue = currentIter.Char;
                    }
                    else if (docTag.IsSerializableText)
                    {
                        readingText = true;
                        elementText = currentIter.Char;
                    }
                }

                foreach (TextTag tag in endTags)
                {
                                #if DEBUG
                    Console.WriteLine("End Tags: {0} Begins: {1} Ends: {2}", tag.Name, currentIter.BeginsTag(tag) ? "True" : "False", DocumentUtils.TagEndsHere(tag, currentIter, nextIter)? "True" : "False");
                                #endif

                    docTag = tag as DocumentTag;
                    if (docTag.IsElement)
                    {
                        xmlWriter.WriteEndElement();

                                        #if DEBUG
                        Console.WriteLine("Wrote End Element: " + docTag.Name);
                                        #endif
                    }
                    else if (docTag.IsAttribute)
                    {
                        xmlWriter.WriteString(attributeValue);
                        xmlWriter.WriteEndAttribute();

                                        #if DEBUG
                        Console.WriteLine("Wrote End Attribute: {0} Value: {1}", attributeName, attributeValue);
                                        #endif

                        readingValue   = false;
                        attributeValue = attributeName = String.Empty;
                    }
                    else if (docTag.IsSerializableText)
                    {
                        if (docTag.Name.IndexOf("significant-whitespace") != -1)
                        {
                            xmlWriter.WriteString(DocumentUtils.Unescape(elementText));
                        }
                        else
                        {
                            xmlWriter.WriteString(elementText);
                        }

                        elementText = String.Empty;
                        readingText = false;
                    }
                }

                currentIter.ForwardChar();
                nextIter.ForwardChar();

                        #if DEBUG
                Console.WriteLine("State: {0} Char: {1} \n", xmlWriter.WriteState.ToString(), currentIter.Char);
                        #endif

//			while (Application.EventsPending ())
//				Application.RunIteration ();
            }
        }