MonoDroid 中的 IoC 与 AOP (PostSharp)

发布于 2024-10-08 08:10:16 字数 606 浏览 0 评论 0原文

我正在开发一个 MonoDroid 应用程序,而且确实还没有一个好的 DI 解决方案(至少我知道)。

我已经让 PostSharp 在 MonoDroid 上工作,并且我使用位置拦截方面作为一种在不使用服务定位器的情况下将依赖项注入字段/属性的方法(无论如何都在方面之外)。

这是我到目前为止正在处理的内容: https://github .com/mgroves/MonodroidStockPortfolio/blob/develop/MonoStockPortfolio/Framework/IoCAttribute.cs

它很粗糙,并且肯定需要重构,但您可以从基本结构中得到想法。但是,我并不完全相信这种方法是最好的方法。无论有或没有 PostSharp,您将如何在 MonoDroid 应用程序中使用 DI/IoC?

I'm working on a MonoDroid app, and there really isn't a good DI solution yet (at least that I know of).

I've gotten PostSharp to work on MonoDroid, and I'm using the Location Intercept aspect as a way to inject dependencies into fields/properties without using a service locator (outside of the aspect anyway).

Here's what I'm working with so far: https://github.com/mgroves/MonodroidStockPortfolio/blob/develop/MonoStockPortfolio/Framework/IoCAttribute.cs

It's rough, and definitely needs refactoring, but you get the idea from the basic structure. However, I'm not completely convinced that this approach is the best way. How would you go about using DI/IoC in a MonoDroid app, with or without PostSharp?

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

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

发布评论

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

评论(1

烟柳画桥 2024-10-15 08:10:16

它是比 AOP 更“经典的容器”,并且 MonoDroid 不是我测试过的平台(尽管它已经在 Mono、MonoTouch、Silverlight、Windows Mobile 和 WinPhone7 上进行了测试),但如果 TinyIoC 符合要求,它应该可以工作:

http://hg.grumpydev.com/tinyioc/wiki/Home

It's more "classic container" rather than AOP, and MonoDroid isn't a platform I've tested it on (it's been tested on Mono, MonoTouch, Silverlight, Windows Mobile and WinPhone7 though), but TinyIoC should work if it fits the bill:

http://hg.grumpydev.com/tinyioc/wiki/Home

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