コード例 #1
0
            // ignores eveything inside template {{ <template> }}
            private State processTemplate(char ch)
            {
                switch (ch)
                {
                case '}' when buffer.Last() == '}':
                    templateNestingLevel--;

                    if (templateNestingLevel <= 0)
                    {
                        buffer.Discard();
                        return(State.NormalText);
                    }
                    else
                    {
                        buffer.Add(ch);
                        return(State.Template);
                    }

                case '{' when buffer.Last() == '{':
                    templateNestingLevel++;

                    buffer.Add(ch);
                    return(State.Template);

                default:
                    buffer.Add(ch);
                    return(State.Template);
                }
            }
コード例 #2
0
        public void TemporaryBuffer_Discard()
        {
            using var buffer = new TemporaryBuffer <int>(1)
                  {
                      100,
                      200,
                      300
                  };

            buffer.Discard();

            Assert.Equal(0, buffer.Count);
            Assert.Empty(buffer);
        }
コード例 #3
0
        public void TemporaryBuffer_CommitAfterDicard()
        {
            using var buffer = new TemporaryBuffer <int>(1)
                  {
                      100,
                      200,
                      300
                  };

            buffer.DiscardLast();
            buffer.Add(700);
            buffer.Add(900);
            buffer.Discard();

            var data = new List <int>();

            buffer.Commit(data);

            Assert.Empty(data);
        }