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();
        }
    }


  • 相关阅读:
    Node.js meitulu图片批量下载爬虫1.04版
    Node.js meitulu图片批量下载爬虫1.03版
    Node.js meitulu图片批量下载爬虫1.02版
    Node.js 解析gzip网页(https)
    Node.js 访问https网站
    Node.js meitulu图片批量下载爬虫1.01版
    我曾经七次鄙视自己的灵魂 卡里.纪伯伦
    ZT:有些人,活了一辈子,其实不过是认真过了一天,其余时间都在重复这一天而已
    节点对象图与DOM树形图
    DOM(文档对象模型)基础加强
  • 原文地址:https://www.cnblogs.com/llcto/p/2794766.html
Copyright © 2011-2022 走看看