Caliburn.Micro, Devforce, TDD, Silverunit

Aug 6, 2010 at 4:19 AM
Edited Aug 6, 2010 at 4:24 AM
We are currently working on a simple demo application using Caliburn.Micro, Devforce from Ideablade as a backend and Silverunit to accomplish TDD. We are picking the "Game Library" apart in order to learn and understand. As of now we got the basics CURD operations up and running. There are a couple of points we are still unsure of. Here they are:

1. When we first create a viewmodel (and view) we want it to be populated with data from the database. We want to use the coroutine pattern i.e. something like: public IEnumerable<IResult> LoadData()
yield return Show.Busy();
var search = new LoadCustomers().AsSesult();
yield return search;
The whole coroutine pattern was meant to be used as a response to a button being clicked or something like that. If we use it to just load the data in/after the constructor of the viewmodel how do we best initiate it? (newup a context, call execute...???? or should we just call the backend by hand?)

2. In the "Game Library" you newup one of those data-access objects every time that you yield something back towards the fake backend (i.e. GetGame, SearchGame, CheckGameIn, AddGameToLibrary...) In our CURD application we do the same thing but I am not sure if that is meant to be done this way?

3. Understanding Async operations in Caliburn is still hard for us. In the beginnng I was under the impression that Caliburn could figure out somehow on its own if an IResult should be executed async or not (initialize with Dispatcher ....) I found out now that in the Handle Method of the Backend I still have to call the database explicitly in an async way. Is that so, or am I missing something really big here?
In the fake backend you do this:
private void Invoke(object request, params object[] args)
ThreadPool.QueueUserWorkItem(state => {

var requestType = request.GetType();
var handler = _methods.Where(x => requestType.IsAssignableFrom(x.GetParameters().First().ParameterType)).First();

handler.Invoke(this, args);

before you call the correct Handle. What part of it is just used for faking and what is meant to stay? Our Handle method then looks something like :

public void Handle(LoadMitarbeiter search, Action<IEnumerable<Mitarbeiter>> reply)
var op =_mgr.Mitarbeiters.OrderBy(x => x.Name).ExecuteAsync();
op.Completed += (s, args) =>
// ToDo: Handle Errors
Any tips would really be appreciated.
Thank you