Esempio n. 1
0
        public void ProcessTest()
        {
            var target = new DirectiveParser("*=");

            string content = @"
            *= require test1.css
             *= require test2
            body {}
            h1 {}
            *= require test3  ";
            string result = @"
            body {}
            h1 {}
            ";
            var context = new TestParserContext();
            target.Parse(new StringReader(content), context);

            Assert.AreEqual(3, context.Directives.Count);
            Assert.AreEqual(result, context.FilteredContent.ToString());
        }
Esempio n. 2
0
        private void Parse(DirectiveParser parser)
        {
            var context = new ParserContext(File);
            parser.Parse(new StringReader(Content), context);
            var newContent = context.FilteredContent.ToString();
            if (newContent != String.Empty)
            {
                Content = newContent;
            }

            foreach (var directive in context.Directives)
            {
                if (directive.Type == DirectiveType.RequireDirectory)
                {
                    _children.AddRange(_loader
                        .FromDirectory(directive.Parameter)
                        .Select(i => i.Load()));
                }
                else if (directive.Type == DirectiveType.RequireTree)
                {
                    _children.AddRange(_loader
                        .FromTree(directive.Parameter)
                        .Select(i => i.Load()));
                }
                else if (directive.Type == DirectiveType.Require)
                {
                    _children.Add(_loader.Load(directive.Parameter));
                }
                else if (directive.Type == DirectiveType.RequireSelf)
                {
                    _children.Add(CreateManifestContentAsset());
                }
            }
        }
Esempio n. 3
0
 static DirectiveParser()
 {
     CssParser = new DirectiveParser("*=");
     JsParser = new DirectiveParser("//=");
     DefaultParsers = new List<DirectiveParser> { CssParser, JsParser };
 }