Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where can I find the API specification for MvcTextTemplateHost?

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/ModifyingTheDefaultCodeGenerationscaffoldingTemplatesInASPNETMVC.aspx, but I'm interested in digging a bit more in the MvcTextTemplateHost Class to see what else it offers, so we can customize a bit more our controllers, and see how does it interact with the "Add controller..." dialog.

But I cannot find (after searching at Google, of course...) the reference to this class, nor MSDN either any other MS site... any ideas?

Thanks, Sergi

like image 668
Sergi Avatar asked May 09 '11 15:05

Sergi


3 Answers

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.

like image 150
Scott Hanselman Avatar answered Sep 18 '22 10:09

Scott Hanselman


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; }
like image 25
sabbour Avatar answered Sep 18 '22 10:09

sabbour


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.

like image 31
Jason Robertson Avatar answered Sep 17 '22 10:09

Jason Robertson