Thursday, February 14, 2013

"I want my MvvmCross app to start differently on Droid"

 I got asked this by email... please don't ask things by email - please ask by http://stackoverflow.com/questions/tagged/mvvmcross - thanks :)

If you want your app to start differently... then just use a different start interface.

For example, your app could register an interface and startup object like:

public enum SimpleStartType
{
DirectLogin,
Twitter,
Facebook,
Instructions,
// ...
}
public interface ISimpleStart
{
void Start(SimpleStartType type);
}
public class SimpleStart : ISimpleStart
{
public void Start(SimpleStartType type)
{
switch (type)
{
case DirectLogin:
this.RequestNavigate<DirectLoginViewModel>();
break;
// ...
}
}
}
// somewhere in App.cs
this.RegisterServiceInstance<ISimpleStart>(new SimpleStart());
view raw SimpleStart hosted with ❤ by GitHub

Then each platform could just call GetService for this interface and can choose it's own startup path....

No comments:

Post a Comment