Just wanted to share a helpful hint I got from Rishi. In cases where your ViewModel has a dependency on some service for which an implementation is not yet registered, you can use Future<T> to get an object which you can use to resolve the dependency at a later time.
For example, if you use the new IShowIndicatorViewService (btw, Rishi was calling it IIndicatorViewService in an earlier mail to this group, but looks like the name has changed), it could be that the ViewModel depending on it has a constructor like so:
[ResolveConstructor]
public SomeVM(IShowIndicatorViewService indicatorService)
{
}
Depending on how your app is structured, it’s possible that an implementation of the service can’t be resolved, as the implementation is registered with a behavior in xaml, which could run after your constructor:
<nControls:WorkIndicator IsWorking="True">
<i:Interaction.Behaviors>
<nBehaviors:IndicatorViewServiceBehavior ViewServiceName="DefaultIndicator" IsDefault="True"/>
</i:Interaction.Behaviors>
</nControls:WorkIndicator>
The fix is to write the dependency like so:
[ResolveConstructor]
public SomeVM(Future<IShowIndicatorViewService> indicatorService)
{
}
Of course this doesn’t “fix” the case where you need the indicatorService in the constructor itself, but this should normally not be the case, normally one needs it when loading data, which is not done hopefully in the constructor J
nRoute supports more of these so-called “locator adapters”, quoting from http://www.orktane.com/Blog/post/2010/04/13/nRoute-Now-More-Wholesome.aspx :
Cheers,
Adi
Freundliche Grüsse / Best regards
Adrian Hara
Cloud Developer
LinkedIn
coresystems ag
Villa im Park | Dorfstrasse 69
5210 Windisch | Switzerland
Phone +41 56 500 22 22
Fax +41 56 444 20 50
Infoline +41 848 088 088
www.coresystems.ch
www.coresuite.com
follow us on twitter
Visit us at CeBIT:
SAP Partner Booth: Hall 5, Booth A18
Cloud Computing: Hall 4, Booth A58
OS X Business Park: Hall 2, Booth A20
Microsoft Booth: Hall 4, Booth P47
The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and / or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.