what is and where can I find MvcTextTemplateHost

后端 未结 4 490
太阳男子
太阳男子 2021-01-19 07:07

I would like to know what this is MvcTextTemplateHost. I have this in my create.tt but I cant find it in my bin folder (searching with object viewer). I read up and found ou

4条回答
  •  暖寄归人
    2021-01-19 07:25

    You can find all .tt files in VS installation direction, for example to get MVC4 .tt files, go to: ($VSDir)\Common7\IDE\ItemTemplates\CSharp\Web\MVC 4\CodeTemplates

    To get the list of the properties of MvcTextTemplateHost, as they are dynamic, you can add the following code to your .tt file:

    <#
    Type myType = mvcHost.GetType();
    IList props = new List(myType.GetProperties());
    
    foreach (PropertyInfo prop in props)
    {
    #>
        <#= prop.Name #>
    <#
    }
    #>
    

    I ran it as I create a List View in MVC4, and some of the properties that came up are:

    ViewName 
    IsPartialView 
    IsContentPage 
    ReferenceScriptLibraries
    AutoEventWireup 
    MasterPageFile 
    ...
    

提交回复
热议问题