生成接口代理

发布于 2024-09-27 11:21:23 字数 383 浏览 0 评论 0原文

班级遇到问题;我有一个如下所示的类:

public class MyPresenter
{
    public MyPresenter(IMyView view) { }
}

public class SomePresenter
{
    public SomePresenter(ISomeView view) { }
}

自定义视图继承自基本 IView 实例。我遇到了一种情况,我需要动态创建一个实现 IMyView 或 ISomeView (取决于某些场景)的自定义类并访问模型,我想我可以使用像 Castle DynamicProxy 这样的工具来做到这一点。但我不太确定从哪里开始,并且我需要能够动态创建自定义 IMyView 或其他类实例。

谢谢。

Ran into an issue with a class; I have a class that looks like:

public class MyPresenter
{
    public MyPresenter(IMyView view) { }
}

public class SomePresenter
{
    public SomePresenter(ISomeView view) { }
}

The custom views inherit from a base IView instance. I ran into a situation where I need to create a custom class on the fly that implements IMyView or ISomeView (depending on some scenario) and access the model, and I was thinking I could use a tool like Castle DynamicProxy to do it. But I'm not quite sure where to start, and I need to be able to create a custom IMyView or other class instance on the fly.

Thanks.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

忆伤 2024-10-04 11:21:23

当我需要代理时,我找到了这个教程来自 Krzysztof Koźmic 的评价是无价的。

When I needed proxies, I found this tutorial from Krzysztof Koźmic to be invaluable.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文