Exemplo 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);
        }
Exemplo n.º 2
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");
        }
Exemplo n.º 3
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");
        }
Exemplo n.º 4
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");
        }
Exemplo n.º 5
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");
        }
Exemplo n.º 6
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);
        }