I'm having trouble wrapping my head around what seems to be a fairly fundamental requirement in Mono (or M4A anyway), and I'm looking for guidance.
My experience in software development leads me to want to do separation of concerns and push toward patterns like MVC/MVP, but Mono seems to push back. Loads of things seem to require a Context or an Activity, which makes it challenging to separate out single services and work units. As a concrete example, I'm trying to create a Presenter that provides location information. I don't want to just use the LocationManager as-is because architecturally it's not right (in my mind anyway), plus I often will be getting location data from elsewhere. So in my LocationPresenter, I want to encapsulate a LocationManager. To do that I need to call GetSystemService on a Context. So here's my first need - a Context. For now I usd IoC and just injected the MainLauncher Activity as a context and use that. It feels a bit dirty but works. Then I said, "hey, I'd like to get location change notifications", so I implemented ILocationListener in my Presenter. Bear in mind it derives from no other classes. First, it made me implement a Handle property. That can't be good - I don't know where those come from or what it's going to be tied to. When I run the app, no surprisingly it crashes with a "Java.Lang.RuntimeException: listener==null", I assume because I don't have the infrastructure in my Presenter that the LocationManager wants. It doesn't appear to be calling for the Handle (not hitting the break point) but it's failing. Maybe I'm on the wrong thread - but RunFromUiThread is again part of an Activity , which I'm not. All examples have the listener as an Activity, which I assume will work, but it's not what I want. So the question here, I guess, is how are other people handling this? Should I just resign myself to everything needing to be an Activity? I hit similar issues when I was doing mapping. I hit similar issue when I want to have a "common object resource" class. Does M4A require me to alter some of my fundamental architecture thinking, or am I just missing something? -Chris
_______________________________________________ Monodroid mailing list Monodroid@lists.ximian.com UNSUBSCRIBE INFORMATION: http://lists.ximian.com/mailman/listinfo/monodroid