Note that there are some explanatory texts on larger screens.

plurals
  1. POPlatform-specific IoC in MVVMCross
    text
    copied!<p>I'm giving a MVVMCross a spin, to see if it will be of use in some bigger projects coming up, and it's great. I like the navigation, viewModel location and general cross-platform approach, which is just what I need. However, I'm a bit stuck on splitting out some of the dependency injection depending on the platform.</p> <p>So, we have the basic application, with a shared portable library, that initialises the service references when starting up:</p> <pre class="lang-java prettyprint-override"><code> public TwitterSearchApp() { InitaliseServices(); } private void InitaliseServices() { this.RegisterServiceInstance&lt;ITwitterSearchProvider&gt;(new TwitterSearchProvider()); } </code></pre> <p>Fine. That defines the service implementations that will be used across all the platforms. But what about the situation where I will need different implementations on different platforms - for instance perhaps storage/caching, where the core requirement is the same, but needs to be handled differently on a phone than on a tablet.</p> <p>I thought it might go in Setup somewhere:</p> <pre class="lang-java prettyprint-override"><code>public class Setup : MvxBaseWinRTSetup { public Setup(Frame rootFrame): base(rootFrame) { } protected override MvxApplication CreateApp() { var app = new TwitterSearchApp();//set platorm specific IoC here maybe? return app; } protected override void AddPluginsLoaders(Cirrious.MvvmCross.Platform.MvxLoaderPluginRegistry loaders) { // or perhaps here? loaders.AddConventionalPlugin&lt;Cirrious.MvvmCross.Plugins.Visibility.WinRT.Plugin&gt;(); base.AddPluginsLoaders(loaders); } } </code></pre> <p>but I'm not sure. I've seen the references to replacing the ViewModel locator, but is there are similar way of replacing the other IoC services?</p> <p>thanks, great job on the framework in general, I really like how it works (apart from this bit, which I don't understand properly yet)</p> <p>Toby</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload