Where can I find the API specification for MvcTextTemplateHost?

后端 未结 5 1737
迷失自我
迷失自我 2021-01-02 18:53

I\'m trying to use a custom T4 template for adding new Controllers to a MVC 3 project. I have my own template as Scott Hanselman wrote on http://www.hanselman.com/blog/Modif

相关标签:
5条回答
  • 2021-01-02 19:04

    This is the closest thing to a spec we have but it is way out of date: http://blogs.msdn.com/b/webdevtools/archive/2009/01/29/t4-templates-a-quick-start-guide-for-asp-net-mvc-developers.aspx

    You can use reflection or, you could take a look at the view templates, especially the identical helper methods at the bottom of each file, to see most of what is available in the MvcTextTemplateHost class.

    0 讨论(0)
  • 2021-01-02 19:05
    public bool AddActionMethods { get; set; }
    internal ProjectItem AreaFolder { get; set; }
    public string AreaName { get; set; }
    public List<string> AssemblyPath { get; set; }
    public bool AutoEventWireup { get; set; }
    public List<string> ContentPlaceHolderIDs { get; set; }
    public Type ContextType { get; set; }
    public string ControllerName { get; set; }
    public string ControllerRootName { get; set; }
    public string EntitySetName { get; set; }
    public CompilerErrorCollection Errors { get; set; }
    [Dynamic]
    public object ExtendedProperties { [return: Dynamic] get; }
    public Encoding FileEncoding { get; set; }
    public string FileExtension { get; set; }
    public Version FrameworkVersion { get; set; }
    internal AppDomain GenerationAppDomain { get; set; }
    public bool IsContentPage { get; set; }
    public bool IsPartialView { get; set; }
    public string MasterPageFile { get; set; }
    IList<string> ITextTemplatingEngineHost.StandardAssemblyReferences { get; }
    IList<string> ITextTemplatingEngineHost.StandardImports { get; }
    public Type ModelType { get; set; }
    public string Namespace { get; set; }
    public string OutputFileExtension { get; set; }
    public IPluralizer Pluralizer { get; set; }
    public string PrimaryContentPlaceHolderID { get; set; }
    public PrimaryKey[] PrimaryKeys { get; set; }
    public bool ReferenceScriptLibraries { get; set; }
    public Dictionary<string, RelatedModel> RelatedProperties { get; set; }
    public string TemplateFile { get; set; }
    public Type ViewDataType { get; set; }
    public string ViewDataTypeName { get; set; }
    public string ViewName { get; set; }
    
    0 讨论(0)
  • 2021-01-02 19:20

    Reflector would be your best option. It allows you to decompile the DLL. You can download it directly at http://shop.reflector.net/download.

    0 讨论(0)
  • 2021-01-02 19:23

    You'll find that this is only extensible to a point. Instead spend time with the new MvcScaffolding package from Steven Sanderson. He's extended this original stuff WAY WAY beyond my plans.

    • Introduction: Scaffold your ASP.NET MVC 3 project with the MvcScaffolding package
    • Standard usage: Typical use cases and options
    • One-to-Many Relationships
    • Scaffolding Actions and Unit Tests
    • Overriding the T4 templates
    • Creating custom scaffolders
    • Scaffolding custom collections of files
    0 讨论(0)
  • 2021-01-02 19:28
    using Microsoft.VisualStudio.Web.Mvc.Scaffolding.BuiltIn;
    using Microsoft.VisualStudio.Web.Mvc.UserInterface;
    

    C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.VisualStudio.TextTemplating.10.0\v4.0_10.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.TextTemplating.10.0.dll Microsoft.VisualStudio.TextTemplating.10.0.dll

    C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.VisualStudio.TextTemplating.10.0\v4.0_10.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.TextTemplating.10.0.dll Microsoft.VisualStudio.TextTemplating.Interfaces.10.0.dll

    C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE Microsoft.VisualStudio.Web.Mvc.4.0.dll

    If you add theses as references to your ASP.NET MVC Web project and set it to the correct dll for your MVC version (last dll reference above) 2.0 3.01 0r 4.0 (still Beta)

    You can copy the T4 code (not the tags) in and run it in a controller which will give intellisense and debugability you would need to set the right properties data and so on, on the MvcTextTemplateHost object on creation and populate it with meaningful data to see what it is doing (in theory this will work I hope)

    As previously stated opening these in .NET Reflector will divulge some info. I have not looked into the code of MVCScaffolding the source is on codeplex its on my todo list). Question i have at the moment is what with and how are the RelatedProperties populated in the MvcTextTemplateHost when it runs in VS.NET 2010 T4.

    Also can make use of Tangible T4 Editor for intellisense.

    0 讨论(0)
提交回复
热议问题