Whee.WordBuilder.ProjectV2.ProjectSerializer.ReadLineBreakToken C# (CSharp) Метод

ReadLineBreakToken() публичный Метод

public ReadLineBreakToken ( IProjectNode node ) : Token
node IProjectNode
Результат Token
        public Token ReadLineBreakToken(IProjectNode node)
        {
            m_warningsToNode = node;
            CheckForComments(node);
            StringBuilder sb = new StringBuilder();
            int start = m_Offset;
            int len = ReadLineBreaks(sb);

            if (len > 0)
            {
                return CreateToken(node, TokenType.LineBreak, sb.ToString(), start, len);
            }

            if (Peek() == -1)
            {
                return CreateToken(node, TokenType.LineBreak, "", start, 0);
            }

            return null;
        }

Usage Example

Пример #1
0
        public void TestIndentationLevelVerification()
        {
            Mockery mockery = new Mockery();
            IProjectNode pn = mockery.NewMock<IProjectNode>();
            ProjectSerializer ps = new ProjectSerializer("\tged\r\n\t  hest \r\n\tnejj\r\n", null, null);
            ps.SpacesIndent = 2;

            Token t = ps.ReadIndentationToken(pn);

            Assert.AreEqual(TokenType.Indentation, t.Type);
            Assert.AreEqual("\t", t.Text);

            t = ps.ReadTextToken(pn);

            Assert.AreEqual(TokenType.Text, t.Type);
            Assert.AreEqual("ged", t.Text);

            t = ps.ReadLineBreakToken(pn);

            t = ps.ReadIndentationToken(pn);

            Assert.AreEqual(TokenType.Indentation, t.Type);
            Assert.AreEqual("\t  ", t.Text);
            Assert.AreEqual(2, ps.GetIndentationLevel(t.Text));

            t = ps.ReadTextToken(pn);

            Assert.AreEqual(TokenType.Text, t.Type);
            Assert.AreEqual("hest", t.Text);

            t = ps.ReadLineBreakToken(pn);

            t = ps.ReadIndentationToken(pn);

            Assert.AreEqual(TokenType.Indentation, t.Type);
            Assert.AreEqual("\t", t.Text);
            Assert.AreEqual(1, ps.GetIndentationLevel(t.Text));

            ps.RollBackToken(t);

            t = ps.ReadIndentationToken(pn);

            Assert.AreEqual(TokenType.Indentation, t.Type);
            Assert.AreEqual("\t", t.Text);
            Assert.AreEqual(1, ps.GetIndentationLevel(t.Text));
        }
All Usage Examples Of Whee.WordBuilder.ProjectV2.ProjectSerializer::ReadLineBreakToken