Rocky,
I see there have been a few discussions around using strings in the ViewModel parts of Csla.Xml namespace.
I wonder if one of the ways around the use of strings in the ViewModel Async method calls might be to use a code generator (T4) to write all the strings out to a MetaData file. For instance Daneil Vaughan has created some templates already.
http://danielvaughan.org/post/MetaGen-A-project-metadata-generator-for-Visual-Studio-using-T4.aspx
What do you think?
Yeah, with the sync methods we were able to accept a lambda expression, and so the factory method can be passed as a parameter.
The async factory methods are complex, because they require a callback parameter that includes a double-indirected generic type. If I remember correctly, you can still use a lambda in .NET (WPF), but not Silverlight. It has been a while since I looked at this though, so I could be mis-remembering.
Code generation is often a solution for magic strings - at least of a sort. Not ideal, but sometimes as good as can be done.
Csla.Xaml.ViewModelBase<T> supports lambda expressions to avoid the use of strings for async and sync factory methods
Async:
this.BeginRefresh(handler => ClientEdit.BeginGetItem(clientId, userState, handler));
this.DoRefresh(() => ClientEdit.GetItem(clientId));
Copyright (c) Marimer LLC