Beispiel #1
0
        public void GetStringTest_ShortForm()
        {
            // Arrange
            string           comment      = "some comment";
            Directive        directive    = new CommentDirective(comment);
            string           expectedText = $"{{c: {comment}}}";
            DirectiveHandler sut          = CommentHandler.Instance;

            // Act
            string text = sut.GetString(directive, shorten: true);

            // Assert
            Assert.AreEqual(expectedText, text);
        }
Beispiel #2
0
        private void Parse(ICollection <Part> parts, Expression type, Regex syntax, string content)
        {
            foreach (Match match in syntax.Matches(content))
            {
                Part part;
                switch (type)
                {
                case Expression.Directive:
                    part = DirectiveFactory.CreateDirective(match, new MacroResolver(Settings));
                    break;

                case Expression.Comment:
                    part = new CommentDirective(match);
                    break;

                case Expression.StandardControlBlock:
                    part = new StandardControlBlock(match);
                    break;

                case Expression.ExpressionControlBlock:
                    part = new ExpressionControlBlock(match);
                    break;

                case Expression.FeatureControlBlock:
                    part = new FeatureControlBlock(match);
                    break;

                default:
                    part = null;
                    break;
                }

                if (part != null)
                {
                    part.Line   = GetLineFromPosition(part.Position);
                    part.Source = TemplateFile;
                    parts.Add(part);
                }
            }
        }