【发布时间】:2009-10-12 15:38:51
【问题描述】:
我确实需要创建类似以下的内容,我正在构建 2 个类,第一个是名称为 tableNameAsSingular (即 AddressEntity) 的类,在我的第二个工作类中,我需要具有以下内容
public IEnumerable<AddressEntity> GetAddressEntity()
{
// the good stuff...
}
创建函数时,我有以下内容..
Type t = Type.GetType("IEnumerable<" + tableNameAsSingular + ">");
CodeFunction2 finderFunction = (CodeFunction2)entityServiceClass.AddFunction("Get" + table.Name, vsCMFunction.vsCMFunctionFunction, t, -1, vsCMAccess.vsCMAccessPublic, null);
但 t 始终为空
当我执行Type.GetType(tableNameAsSingular) 时,它也会返回 null
我们将不胜感激任何帮助或指点。此外,如果有人知道大量的 EnvDTE 代码生成知识在哪里,我会非常感激!
更新
我现在已经尝试使用以下字符串作为字符串:
public void AddFinderMethod()
{
string t = "IEnumerable<" + tableNameAsSingular + ">";
CodeFunction2 finderFunction = (CodeFunction2)entityServiceClass.AddFunction("Get" + table.Name, vsCMFunction.vsCMFunctionFunction, t, -1, vsCMAccess.vsCMAccessPublic, null);
// Code here remove as it does not get this far yet.
}
但我在 AddFunction 方法中收到“IEnumerable<ProductEntity> is not a valid identifier”错误消息
【问题讨论】:
标签: c# code-generation envdte