如何在CodeRush中获取实现接口的类?
我试图编写一个返回实现接口的类列表的方法,但无法做到。
像我这样的一些方法
public List<Class> GetImplementedClasses(Interface Interface1)
{
. . .
}
尝试使用interface1.AllChildren和许多其他尝试。他们都没有给出任何结果。
是否可以使用 DXCore API 编写这样的方法?
示例:
如果我通过 Interface1,我应该从方法 GetImplementedClasses 获取 Class1 和 Class2。
提前致谢。
I was trying to write a method that returns a list of classes that implements an Interface, but could not do it.
Some method like
public List<Class> GetImplementedClasses(Interface Interface1)
{
. . .
}
I tried to use interface1.AllChildren and many other tries. Non of them gave any results.
Is it possible to write such a method using DXCore APIs?
EXAMPLE:
If I pass Interface1, I should get Class1 and Class2 from the method GetImplementedClasses.
Thanks in Advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Intrerface 类中有一个“GetDescendants”方法,可能对您的任务有用。该代码将类似于以下内容:
There's a "GetDescendants" method in the Intrerface class that might be useful for your task. The code will look similar to this:
我不确定 dxcore,但在常规 C# 中,我编写了 an扩展方法,获取部署中可用的所有类型;你可以这样使用它:
I'm not sure about dxcore, but in regular C# I've written an extension method which gets all the Types available in a deployment; you could use it like this: