zoukankan      html  css  js  c++  java
  • [源码学习]记录RazorParser Call Stack

    SystemWebMvc\Mvc\VirtualPathProviderViewEngine.cs

    继承关系 RazorViewEngine : BuildManagerViewEngine : VirtualPathProviderViewEngine

    VirtualPathProviderViewEngine类

    FindView方法 134行

    string viewPath = GetPath(controllerContext, ViewLocationFormats, AreaViewLocationFormats, "ViewLocationFormats", viewName, controllerName, _cacheKeyPrefix_View, useCache, out viewLocationsSearched);
     
    GetPath方法 167行

    return (nameRepresentsPath) ?
                    GetPathFromSpecificName(controllerContext, name, cacheKey, ref searchedLocations) :
                    GetPathFromGeneralName(controllerContext, viewLocations, name, controllerName, areaName, cacheKey, ref searchedLocations);
     

    GetPathFromGeneralName方法 180行

    if (FileExists(controllerContext, virtualPath))


    BuildManagerViewEngine 类

    FileExists方法 42行

    return BuildManager.FileExists(virtualPath);


    BuildManagerWrapper 类

    FileExists方法 8行

    return BuildManager.GetObjectFactory(virtualPath, false) != null;


    ********************

    只有注册了Rozor的BuildProcider,BuildManager才会调用
     

    System.Web.WebPages.Razor\Properties\AssemblyInfo.cs

    13行

    [assembly: PreApplicationStartMethod(typeof(PreApplicationStartCode), "Start")]


    System.Web.WebPages.Razor\PreApplicationStartCode.cs

    26行

    BuildProvider.RegisterBuildProvider(".cshtml"typeof(RazorBuildProvider));
    BuildProvider.RegisterBuildProvider(".vbhtml"typeof(RazorBuildProvider));


    ********************

    RazorBuildProvider 类

    CodeCompilerType属性 98行

    EnsureGeneratedCode();


    EnsureGeneratedCode方法 166行

    RazorTemplateEngine engine = new RazorTemplateEngine(Host);
    GeneratorResults results = null;
    using (TextReader reader = InternalOpenReader()) {
        results = engine.GenerateCode(reader, className: null, rootNamespace: null, sourceFileName: Host.PhysicalPath);
    }



    System.Web.Razor\RazorTemplateEngine.cs

    126行

    public GeneratorResults GenerateCode(TextReader input, string className, string rootNamespace, string sourceFileName) {
         return GenerateCode(input, className, rootNamespace, sourceFileName, null);
    }


    130行

    [SuppressMessage("Microsoft.Reliability""CA2000:Dispose objects before losing scope", Justification = "Input object would be disposed if we dispose the wrapper.  We don't own the input so we don't want to dispose it")]
    public GeneratorResults GenerateCode(TextReader input, string className, string rootNamespace, string sourceFileName, CancellationToken? cancelToken) {
        return GenerateCodeCore(new BufferingTextReader(input), className, rootNamespace, sourceFileName, cancelToken);
    }


    148行

    RazorParser parser = CreateParser();
    Debug.Assert(parser != null);
    parser.Parse(input, consumer);


    System.Web.Razor\Parser\RazorParser.cs

    35行

    public virtual void Parse(LookaheadTextReader input, ParserVisitor visitor) {
        // Setup the parser context
        ParserContext context = new ParserContext(input, CodeParser, MarkupParser, MarkupParser, visitor) {
            DesignTimeMode = DesignTimeMode
        };

        MarkupParser.Context = context;
        CodeParser.Context = context;

        // Execute the context
        try {
            MarkupParser.ParseDocument();
        }
        finally {
            context.OnComplete();
        }
    }


  • 相关阅读:
    SpringBoot异步处理请求
    5本最佳的 Java 面向对象理论和设计模式的书籍
    彻底弄懂 HTTP 缓存机制 —— 基于缓存策略三要素分解法
    Java 性能优化的五大技巧
    Java 8 最佳技巧
    Java 并发的四种风味:Thread、Executor、ForkJoin 和 Actor
    在 Java 8 中避免 Null 检查
    关于创建java线程池问题的思考
    LuoguP1858 多人背包(DP)
    Luogu[YNOI2019]排序(DP,线段树)
  • 原文地址:https://www.cnblogs.com/llcto/p/2794766.html
Copyright © 2011-2022 走看看