如何创建具有IEnumerable<>类型的CodeFunction2?

编程入门 行业动态 更新时间:2024-10-14 02:18:12
本文介绍了如何创建具有IEnumerable<>类型的CodeFunction2?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我真的需要创建如下所示的内容,我正在构建两个类,第一个是名为ableNameAsSingular(即AddressEntity)的类,在我的第二个Worker类中,我需要具有类似以下内容的内容

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)它也返回空值

任何帮助或建议都将受到极大的欢迎。另外,如果有人知道有太多的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"错误消息

推荐答案

已设法使其与以下各项配合使用:

string returnType = "System.Collections.Generic.IEnumerable<" + tableNameAsSingular + ">"; CodeFunction2 finderFunction = (CodeFunction2)entityServiceClass.AddFunction("Get" + table.Name, vsCMFunction.vsCMFunctionFunction, returnType, -1, vsCMAccess.vsCMAccessPublic, null);

更多推荐

如何创建具有IEnumerable&lt;&gt;类型的CodeFunction2?

本文发布于:2023-11-09 04:25:54,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1571400.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:类型   amp   IEnumerable   lt   gt

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!