4

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?

2
  • 1
    Isn't it service location what you mean instead of IoC? I don't get the I(nversion) of IoC combined with Aop
    – Paco
    Commented Dec 20, 2010 at 18:42
  • I use AOP to get hooks into the properties, and then I can use a service locator to resolve the dependency, but the service locator is only in the aspect, not scattered throughout the program Commented Dec 21, 2010 at 15:31

1 Answer 1

7
+100

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

1
  • 2
    TinyIoC definitely works on MonoDroid, I've been using it lately. I'm actually working on a little framework of DI wrappers/helpers for MonoDroid and I'm currently using TinyIoC in it as well. Commented Dec 20, 2010 at 19:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.