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


  • 相关阅读:
    BZOJ 2574: [Poi1999]Store-Keeper
    BZOJ 1024: [SCOI2009]生日快乐
    BZOJ 2541: [Ctsc2000]冰原探险
    hihoCoder 1303 数论六·模线性方程组
    Codeforces 710 D. Two Arithmetic Progressions
    BZOJ 1670: [Usaco2006 Oct]Building the Moat护城河的挖掘
    ZJOI2014 2048
    51Nod 1766 树上的最远点对
    Codeforces 727 F. Polycarp's problems
    BZOJ 3736: [Pa2013]Karty
  • 原文地址:https://www.cnblogs.com/llcto/p/2794766.html
Copyright © 2011-2022 走看看