如何获取 kotlin 中构造函数参数的 KClass?

发布于 2025-01-15 02:53:26 字数 201 浏览 3 评论 0原文

我想创建某种依赖注入系统,获取需要实例化的类列表以创建某种依赖关系树。为此,我想获取所有类,首先找到它们的“外部依赖项”(不包含在树中的类)。

我的问题是:在kotlin中,构造函数(KFunction)的参数被保存为我不知道如何获取我真正需要的类的类型。

所以问题是:如何获取kotlin中构造函数参数的实际KClass?

I want to create some sort of dependency injection system taking a list of classes that need to be instantiated to create a sort of dependency tree. For that I want to take all the classes and first of all find their "external dependencies" (the classes that are not contained in the tree).

My problem is: In kotlin, the parameters of a constructor (KFunction) are saved as types of which I don't know how to get the classes which I really need.

So the question is: How can I get the actual KClasses of constructor parameters in kotlin?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文