/// <summary>
        /// Gets the RazorCodeLanguage registered for the specified file extension
        /// </summary>
        /// <param name="fileExtension">The extension, with or without a "."</param>
        /// <returns>The language registered for that extension</returns>
        public static RazorCodeLanguage GetLanguageByExtension(string fileExtension)
        {
            RazorCodeLanguage service = null;

            Languages.TryGetValue(fileExtension.TrimStart('.'), out service);
            return(service);
        }
 /// <summary>
 /// Creates a host which uses the specified code language and the HTML markup language
 /// </summary>
 /// <param name="codeLanguage">The code language to use</param>
 public RazorEngineHost(RazorCodeLanguage codeLanguage)
     : this(codeLanguage, () => new HtmlMarkupParser())
 {
     if (codeLanguage == null)
     {
         throw new ArgumentNullException(nameof(codeLanguage));
     }
 }
Example #3
0
 /// <summary>
 /// Creates a host which uses the specified code language and the HTML markup language
 /// </summary>
 /// <param name="codeLanguage">The code language to use</param>
 public RazorEngineHost(RazorCodeLanguage codeLanguage)
     : this(codeLanguage, () => new HtmlMarkupParser())
 {
     if (codeLanguage == null)
     {
         throw new ArgumentNullException(nameof(codeLanguage));
     }
 }
        public RazorEngineHost(
            RazorCodeLanguage codeLanguage,
            Func <ParserBase> markupParserFactory)
            : this()
        {
            if (codeLanguage == null)
            {
                throw new ArgumentNullException(nameof(codeLanguage));
            }

            if (markupParserFactory == null)
            {
                throw new ArgumentNullException(nameof(markupParserFactory));
            }

            CodeLanguage         = codeLanguage;
            _markupParserFactory = markupParserFactory;
        }
Example #5
0
        public RazorEngineHost(
            RazorCodeLanguage codeLanguage,
            Func<ParserBase> markupParserFactory)
            : this()
        {
            if (codeLanguage == null)
            {
                throw new ArgumentNullException(nameof(codeLanguage));
            }

            if (markupParserFactory == null)
            {
                throw new ArgumentNullException(nameof(markupParserFactory));
            }

            CodeLanguage = codeLanguage;
            _markupParserFactory = markupParserFactory;
        }