[英]MVC T4 MvcTextTemplateHost and Customized “Controller” T4 Template
[英]T4 template for an MVC Controller with Entity Framework - member properties of the host (MvcTextTemplateHost)?
有沒有人完全引用我可以在MVC 3附帶的T4模板ControllerWithContext.tt中使用的Host對象的成員?
我已經嘗試了我能想到的每一個谷歌搜索,但唯一相關的結果是這個頁面: http : //blogs.msdn.com/b/webdevtools/archive/2009/01/29/t4-templates-a-quick -啟動引導換ASP凈MVC-developers.aspx
但它只顯示4個屬性(ItemName,NameSpace,ExtraActionMethods,ControllerRootName)而不是完整列表。 在模板中有像RelatedProperties,EntitySetName,ModelType和ContextType之類的東西。
我正在嘗試查找完整的屬性列表,其類型和說明。 任何幫助將不勝感激。
當您在Visual Studio 2010中使用“添加視圖”或“添加控制器”對話框時,我已經為T4模板提供了一個非正式的ASP.NET MVC 3屬性列表。它沒有涵蓋在NuGet包管理器中使用MvcScaffolding時可用的屬性安慰。 使用T4模板確定屬性信息以反映MvcTextTemplateHost上的公共屬性。
添加控制器 :
+--------------------+---------------+----------------------------------------------------------------------------------------+
| Property Name | Type | Description |
+--------------------+---------------+----------------------------------------------------------------------------------------+
| AddActionMethods | Boolean | Adds action methods to the generated controller class. |
| AreaName | System.String | The name of the Area that the controller is created for. |
| ContextType | System.Type | The type of the data context. |
| ControllerName | String | The name of the controller class that will be generated. |
| ControllerRootName | String | The name of the controller class excluding the Controller part at the end of the name. |
| EntitySetName | String | Name of the property on the data context class containing the set of entities. |
| ModelType | System.Type | The type of the model class specified in the Add Controller dialog. |
| Namespace | String | Namespace that will be used for the generated controller class. |
| PrimaryKeys | PrimaryKey[] | Primary keys for the model. See table at end for PrimaryKey properties. |
| RelatedProperties | Dictionary | Related properties on the model. See table at end for RelatedModel properties. |
+--------------------+---------------+----------------------------------------------------------------------------------------+
添加視圖 :
+-----------------------------+---------------+------------------------------------------------------------------------------------------+
| Property Name | Type | Description |
+-----------------------------+---------------+------------------------------------------------------------------------------------------+
| AreaName | System.String | The name of the Area that the view is being created for. |
| ContentPlaceHolderIDs | List<string> | List of content place holder IDs in the master page. |
| IsContentPage | Boolean | True if the generated view will be created with a master page or a Razor layout page. |
| IsPartialView | Boolean | True if the generated view is a partial view (e.g. an ASP.NET user control). |
| MasterPageFile | String | Master page file or Razor layout to be used with view (e.g. ~/Views/Shared/Site.Master). |
| Namespace | String | Namespace that will be used for the generated view. |
| PrimaryContentPlaceHolderID | String | Primary content place holder ID to be used when creating a view using a master page. |
| ReferenceScriptLibraries | Boolean | True if checked in the Add View dialog. |
| ViewDataType | System.Type | The view model's type. |
| ViewDataTypeName | String | Fully qualified name for the view model's type. |
| ViewName | String | Name of the view. |
+-----------------------------+---------------+------------------------------------------------------------------------------------------+
共同屬性 :
+---------------------+-------------------------+-----------------------------------------------------------------------------------------------+
| Property Name | Type | Description |
+---------------------+-------------------------+-----------------------------------------------------------------------------------------------+
| AssemblyPath | List<string> | List of assemblies referenced by the project and the project's output assembly. Internal use. |
| Errors | CompilerErrorCollection | Used to stored errors that occur whilst processing the T4 template. Internal use. |
| FileEncoding | System.Text.Encoding | The encoding of the file that will be generated. |
| FileExtension | String | Not set. |
| FrameworkVersion | System.Version | The .NET framework version. |
| OutputFileExtension | System.String | The extension of the file that will be generated. |
| TemplateFile | System.String | The full path to the T4 template file being used. |
+---------------------+-------------------------+-----------------------------------------------------------------------------------------------+
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.