生成接口代理
班级遇到问题;我有一个如下所示的类:
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当我需要代理时,我找到了这个教程来自 Krzysztof Koźmic 的评价是无价的。
When I needed proxies, I found this tutorial from Krzysztof Koźmic to be invaluable.