Podelo
Podelo

Reputation: 386

Custom plugin in MVVMCross

I'm working on MVVMCross v3 and I want to create my own plugin, I followed this tutorial (which is for the vNext)

http://slodge.blogspot.fr/2012/10/build-new-plugin-for-mvvmcrosss.html

To be compatible for the v3 I changed IMvxServiceConsumer and GetService to Mvx.Resolve.

But on the tutorial there are :

Then, for WinRT, WindowsPhone and MonoTouch clients, you also need to provide a Loader accessor in setup.cs - like:

protected override void AddPluginsLoaders(Cirrious.MvvmCross.Platform.MvxLoaderPluginRegistry loaders)

{
    loaders.AddConventionalPlugin<MyCompany.MvvmCross.Plugins.Mega.WindowsPhone.Plugin>();

    base.AddPluginsLoaders(loaders);
}

How can I do that in v3?

Thanks

Upvotes: 3

Views: 2593

Answers (1)

Stuart
Stuart

Reputation: 66882

If you want to write a new plugin, then :

For plugin initialisation, the nuget packages now do this via bootstrap files - e.g. see the files added for Location at:


The bootstrap way is the normal way to do initialisation now.

If you did want to use a non-bootstrap technique then you can do this:

  • In WinRT, WinPhone, and Droid, you don't need to use a loader, but you do need to call MyPlugin.PluginManager.Instance.EnsureLoaded before the plugin can be used.
  • In Touch, you would need to provide a loader during protected override void AddPluginsLoaders(MvxLoaderPluginRegistry loaders) - and you'd then still need to call EnsureLoaded() before the plugin can be used.

For examples of this 'old way' of working, see Setup.cs in the UI projects in https://github.com/slodge/MvvmCross-Tutorials/tree/master/Sample%20-%20TwitterSearch

Upvotes: 4

Related Questions