public ParserContext(ITextDocument source, ParserBase codeParser, ParserBase markupParser, ParserBase activeParser)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }
            if (codeParser == null)
            {
                throw new ArgumentNullException("codeParser");
            }
            if (markupParser == null)
            {
                throw new ArgumentNullException("markupParser");
            }
            if (activeParser == null)
            {
                throw new ArgumentNullException("activeParser");
            }
            if (activeParser != codeParser && activeParser != markupParser)
            {
                throw new ArgumentException(RazorResources.ActiveParser_Must_Be_Code_Or_Markup_Parser, "activeParser");
            }

            CaptureOwnerTask();

            Source       = new TextDocumentReader(source);
            CodeParser   = codeParser;
            MarkupParser = markupParser;
            ActiveParser = activeParser;
            Errors       = new List <RazorError>();
        }
Esempio n. 2
0
        public RazorParser(ParserBase codeParser, MarkupParser markupParser) {
            if (codeParser == null) { throw new ArgumentNullException("codeParser"); }
            if (markupParser == null) { throw new ArgumentNullException("markupParser"); }

            MarkupParser = markupParser;
            CodeParser = codeParser;
        }
        public ParserContext(ITextDocument source, ParserBase codeParser, ParserBase markupParser, ParserBase activeParser)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }
            if (codeParser == null)
            {
                throw new ArgumentNullException("codeParser");
            }
            if (markupParser == null)
            {
                throw new ArgumentNullException("markupParser");
            }
            if (activeParser == null)
            {
                throw new ArgumentNullException("activeParser");
            }
            if (activeParser != codeParser && activeParser != markupParser)
            {
                throw new ArgumentException(RazorResources.ActiveParser_Must_Be_Code_Or_Markup_Parser, "activeParser");
            }

            CaptureOwnerTask();

            Source = new TextDocumentReader(source);
            CodeParser = codeParser;
            MarkupParser = markupParser;
            ActiveParser = activeParser;
            Errors = new List<RazorError>();
        }
 public override ParserBase DecorateCodeParser(ParserBase incomingCodeParser)
 {
     if (incomingCodeParser is CSharpCodeParser)
     {
         return new MvcCSharpRazorCodeParser();
     }
     return base.DecorateCodeParser(incomingCodeParser);
 }
        /// <summary>
        /// Decorates the code parser.
        /// </summary>
        /// <param name="incomingCodeParser">The incoming code parser.</param>
        /// <returns></returns>
        public override ParserBase DecorateCodeParser(ParserBase incomingCodeParser)
        {
            if (incomingCodeParser is CSharpCodeParser)
                return new CSharp.NancyCSharpRazorCodeParser();
            if (incomingCodeParser is VBCodeParser)
                return new VisualBasic.NancyVisualBasicRazorCodeParser();

            return base.DecorateCodeParser(incomingCodeParser);
        }
Esempio n. 6
0
        /// <summary>
        /// Decorates the code parser.
        /// </summary>
        /// <param name="incomingCodeParser">The incoming code parser.</param>
        /// <returns></returns>
        public override ParserBase DecorateCodeParser(ParserBase incomingCodeParser)
        {
            if (incomingCodeParser is CSharpCodeParser)
            {
                return new NancyCSharpRazorCodeParser(this.razorAssemblyProvider);
            }

            return base.DecorateCodeParser(incomingCodeParser);
        }
        /// <summary>
        /// Decorates the code parser.
        /// </summary>
        /// <param name="incomingCodeParser">The code parser.</param>
        /// <returns>The decorated parser.</returns>
        public override ParserBase DecorateCodeParser(ParserBase incomingCodeParser)
        {
            if (incomingCodeParser is CSharpCodeParser)
                return new CSharp.CSharpCodeParser();

            if (incomingCodeParser is VBCodeParser)
                return new VisualBasic.VBCodeParser();

            return incomingCodeParser;
        }
        public override ParserBase DecorateMarkupParser(ParserBase incomingMarkupParser)
        {
            var parser = base.DecorateMarkupParser(incomingMarkupParser);
            if (!(parser is HtmlMarkupParser))
            {
                // That's not HTML => we don't know how to minify it
                return parser;
            }

            var newparser = new MinifyHtmlParser(parser, _minifier);
            return newparser;
        }
Esempio n. 9
0
 public override ParserBase DecorateCodeParser(ParserBase incomingCodeParser)
 {
     // If we're parsing C#
     if (CodeLanguage is CSharpRazorCodeLanguage)
     {
         // Return our special C# code parser
         return new ContentTypeCSharpCodeParser();
     }
     else
     {
         return base.DecorateCodeParser(incomingCodeParser);
     }
 }
Esempio n. 10
0
        public RazorParser(ParserBase codeParser, MarkupParser markupParser)
        {
            if (codeParser == null)
            {
                throw new ArgumentNullException("codeParser");
            }
            if (markupParser == null)
            {
                throw new ArgumentNullException("markupParser");
            }

            MarkupParser = markupParser;
            CodeParser   = codeParser;
        }
Esempio n. 11
0
        /// <summary>
        /// Decorates the code parser.
        /// </summary>
        /// <param name="incomingCodeParser">The incoming code parser.</param>
        /// <returns></returns>
        public override ParserBase DecorateCodeParser(ParserBase incomingCodeParser)
        {
            if (incomingCodeParser is CSharpCodeParser)
            {
                return new NancyCSharpRazorCodeParser(this.assemblyCatalog);
            }

            if (incomingCodeParser is VBCodeParser)
            {
                return new NancyVisualBasicRazorCodeParser(this.assemblyCatalog);
            }

            return base.DecorateCodeParser(incomingCodeParser);
        }
Esempio n. 12
0
        public RazorParser(ParserBase codeParser, ParserBase markupParser)
        {
            if (codeParser == null)
            {
                throw new ArgumentNullException("codeParser");
            }
            if (markupParser == null)
            {
                throw new ArgumentNullException("markupParser");
            }

            MarkupParser = markupParser;
            CodeParser = codeParser;

            Optimizers = new List<ISyntaxTreeRewriter>()
            {
                // Move whitespace from start of expression block to markup
                new WhiteSpaceRewriter(MarkupParser.BuildSpan),
                // Collapse conditional attributes where the entire value is literal
                new ConditionalAttributeCollapser(MarkupParser.BuildSpan),
            };
        }
Esempio n. 13
0
        public RazorParser(ParserBase codeParser, ParserBase markupParser)
        {
            if (codeParser == null)
            {
                throw new ArgumentNullException("codeParser");
            }
            if (markupParser == null)
            {
                throw new ArgumentNullException("markupParser");
            }

            MarkupParser = markupParser;
            CodeParser   = codeParser;

            Optimizers = new List <ISyntaxTreeRewriter>()
            {
                // Move whitespace from start of expression block to markup
                new WhiteSpaceRewriter(MarkupParser.BuildSpan),
                // Collapse conditional attributes where the entire value is literal
                new ConditionalAttributeCollapser(MarkupParser.BuildSpan),
            };
        }
Esempio n. 14
0
        public ParserContext(LookaheadTextReader source, ParserBase codeParser, MarkupParser markupParser, ParserBase activeParser, ParserVisitor visitor)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }
            if (codeParser == null)
            {
                throw new ArgumentNullException("codeParser");
            }
            if (markupParser == null)
            {
                throw new ArgumentNullException("markupParser");
            }
            if (activeParser == null)
            {
                throw new ArgumentNullException("activeParser");
            }
            if (visitor == null)
            {
                throw new ArgumentNullException("visitor");
            }
            if (activeParser != codeParser && activeParser != markupParser)
            {
                throw new ArgumentException(RazorResources.ActiveParser_Must_Be_Code_Or_Markup_Parser, "activeParser");
            }

            CaptureOwnerTask();

            Source       = source;
            CodeParser   = codeParser;
            MarkupParser = markupParser;
            ActiveParser = activeParser;
            _visitorStack.Push(visitor);
            ResetBuffers();
        }
 public override ParserBase DecorateCodeParser(ParserBase incomingCodeParser)
 {
     if (incomingCodeParser is CSharpCodeParser)
     {
         return new OpenRastaCSharpRazorCodeParser();
     }
     if (incomingCodeParser is VBCodeParser)
     {
         throw new InvalidOperationException("VB not supported yet.");
     }
     return base.DecorateCodeParser(incomingCodeParser);
 }
		public override ParserBase DecorateCodeParser (ParserBase incomingCodeParser)
		{
			return new PreprocessedCSharpRazorCodeParser ();
		}
		public override ParserBase DecorateCodeParser(ParserBase incomingCodeParser)
		{
			return ParserFactory != null? ParserFactory (this) : base.DecorateCodeParser(incomingCodeParser);
		}
Esempio n. 18
0
        public ParserContext(LookaheadTextReader source, ParserBase codeParser, MarkupParser markupParser, ParserBase activeParser, ParserVisitor visitor) {
            if (source == null) { throw new ArgumentNullException("source"); }
            if (codeParser == null) { throw new ArgumentNullException("codeParser"); }
            if (markupParser == null) { throw new ArgumentNullException("markupParser"); }
            if (activeParser == null) { throw new ArgumentNullException("activeParser"); }
            if (visitor == null) { throw new ArgumentNullException("visitor"); }
            if (activeParser != codeParser && activeParser != markupParser) {
                throw new ArgumentException(RazorResources.ActiveParser_Must_Be_Code_Or_Markup_Parser, "activeParser");
            }

            CaptureOwnerTask();

            Source = source;
            CodeParser = codeParser;
            MarkupParser = markupParser;
            ActiveParser = activeParser;
            _visitorStack.Push(visitor);
            ResetBuffers();
        }
Esempio n. 19
0
 public virtual ParserContext CreateParserRun(LookaheadTextReader input, ParserBase codeParser, MarkupParser markupParser, ParserVisitor listener) {
     return new ParserContext(input, codeParser, markupParser, SelectActiveParser(codeParser, markupParser), listener);
 }
Esempio n. 20
0
        public override ParserBase DecorateCodeParser(ParserBase incomingCodeParser)
        {
            if (incomingCodeParser is System.Web.Razor.Parser.CSharpCodeParser)
                return new ServiceStackCSharpCodeParser();

            return base.DecorateCodeParser(incomingCodeParser);
        }
 protected override ParserBase SelectActiveParser(ParserBase codeParser, MarkupParser markupParser) {
     return markupParser;
 }
Esempio n. 22
0
 private ParserContext SetupTestContext(string document, Action<TextReader> positioningAction, ParserBase codeParser, ParserBase markupParser, ParserBase activeParser)
 {
     ParserContext context = new ParserContext(new SeekableTextReader(new StringReader(document)), codeParser, markupParser, activeParser);
     positioningAction(context.Source);
     return context;
 }
 private ParserContext SetupTestRun(string document, Action<TextReader> positioningAction, ParserBase codeParser, MarkupParser markupParser, ParserBase activeParser, ParserVisitor listener) {
     ParserContext context = new ParserContext(new BufferingTextReader(new StringReader(document)), codeParser, markupParser, activeParser, listener);
     positioningAction(context.Source);
     context.ResetBuffers();
     return context;
 }
Esempio n. 24
0
 /// <summary>
 /// Gets an instance of the code parser and is provided an opportunity to decorate or replace it
 /// </summary>
 /// <param name="incomingCodeParser">The code parser</param>
 /// <returns>Either the same code parser, after modifications, or a different code parser</returns>
 public virtual ParserBase DecorateCodeParser(ParserBase incomingCodeParser) {
     if (incomingCodeParser == null) { throw new ArgumentNullException("incomingCodeParser"); }
     return incomingCodeParser;
 }
 public override ParserBase DecorateCodeParser(ParserBase incomingCodeParser)
 {
     return Parser ?? base.DecorateCodeParser(incomingCodeParser);
 }
 /// <summary>
 /// Decorates the code parser.
 /// </summary>
 /// <param name="incomingCodeParser">The code parser.</param>
 /// <returns>The decorated parser.</returns>
 public override ParserBase DecorateCodeParser(ParserBase incomingCodeParser)
 {
     return decorateCodeParser(incomingCodeParser) ?? incomingCodeParser;
 }
Esempio n. 27
0
 public override ParserBase DecorateCodeParser(ParserBase incomingCodeParser)
 {
     return new MvcCSharpRazorCodeParser();
 }
Esempio n. 28
0
 public MinifyHtmlParser(ParserBase other, MinifyHtmlMinifier minifier)
 {
     _other = other;
     _minifier = minifier;
 }
 protected abstract ParserBase SelectActiveParser(ParserBase codeParser, ParserBase markupParser);
 public virtual ParserContext CreateParserContext(ITextDocument input, ParserBase codeParser, ParserBase markupParser)
 {
     return new ParserContext(input, codeParser, markupParser, SelectActiveParser(codeParser, markupParser));
 }