我試圖從msdn使用此示例瞭解如何爲文本模板生成創建自定義主機。文本模板自定義主機:如何實現ResolveDirectiveProcessor
CustomCmdLineHost
類實現ITextTemplatingEngineHost
接口,但不完全,ResolveDirectiveProcessor
沒有實現,它每次都會拋出一個異常,這是正常的。這裏是ResolveDirectiveProcessor
方法:
public Type ResolveDirectiveProcessor(string processorName)
{
//This host will not resolve any specific processors.
//Check the processor name, and if it is the name of a processor the
//host wants to support, return the type of the processor.
//---------------------------------------------------------------------
if (string.Compare(processorName, "XYZ", StringComparison.OrdinalIgnoreCase) == 0)
{
//return typeof();
}
//This can be customized to search specific paths for the file
//or to search the GAC
//If the directive processor cannot be found, throw an error.
throw new Exception("Directive Processor not found");
}
和processorName
中國率先這一功能是「T4VSHost」,
此刻的問題: 什麼是「T4VSHost」的類型在這個方法返回?
P.S .:我試過「Microsoft.Data.Entity.Design.VisualStudio.Directives.FallbackT4VSHostProcessor」,但它似乎並不存在於任何名稱空間中。
你是否像命令行一樣從命令行測試了這個? – Frank
@Frank否它被應用程序中的其他代碼調用 – dafriskymonkey