6
您好我剛剛開始使用T4模板,我需要根據控制器中的操作生成一個JavaScript文件。T4命名空間不能直接包含諸如字段或方法的成分
我都想通了,忘記了控制器和行動,我唯一的問題是,我在T4模板文件中得到這個錯誤,我不明白它的代碼:
編譯變革:命名空間不能直接包含成員如字段或方法
這是我的代碼:
<#@ template debug="false" hostspecific="false" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ assembly name="$(TargetPath)" #>
<#@ import namespace="System.Reflection" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ import namespace="eConnect.WebApi.Helpers.T4.ControllerDetails" #>
<#@ import namespace="System.Web.Http;"#>
<#@ output extension=".js" #>
define(['services/logger',
'services/jsonDataService',
'services/config',
'services/cachingService'],
function (logger, jsonDataService, config, cache) {
var dataService = { };
return dataService;
});
<#
var controllers = ControllersInfo.GetControllers();
foreach(var controller in controllers) {
Dictionary<string, ParameterInfo[]> actions = ControllersInfo.GetAllCustomActionsInController(controller, new HttpGetAttribute());
}
#>
還有一個EXTE rnal類獲取控制器和操作,但我認爲它不是當前問題的必要條件。
我在做什麼錯?