2

I get this error when I use AddConventionalPlugin:

You must pass in the type of a plugin instance - like

typeof(Cirrious.MvvmCross.Plugins.Visibility.WindowsPhone.Plugin) 

because my plugin is something like:

Cirrious.MvvmCross.Plugins.Visibility.Wp7.Plugin 

I think Wp7 and Wp8 will be splitted in 2 projects because they will use a different SDK.

Is there a way to bypass this problem ?

Thanks in advance for your help.

1 Answer 1

2

The 'convention' part is simply the naming convention.

i.e. it's just looking for something that will provide an IMvxPlugin for:

 Cirrious.MvvmCross.Plugins.Visibility 

using the rule 'add "WindowsPhone"' to get:

 Cirrious.MvvmCross.Plugins.Visibility.WindowsPhone.Plugin 

If the rule changes for WP8... then we can just change the convention in https://github.com/slodge/MvvmCross/blob/vnext/Cirrious/Cirrious.MvvmCross.WindowsPhone/Platform/MvxBaseWindowsPhoneSetup.cs


While WP8 is still a bit unclear... You can do this yourself in your project in your Setup.cs using code like:

 protected override IMvxPluginManager CreatePluginManager() { var toReturn = new MvxLoaderBasedPluginManager(); var registry = new MvxLoaderPluginRegistry(".WP7",toReturn.Loaders); AddPluginsLoaders(registry); return toReturn; } 

or you could even mix and match versions - i.e. you could do something like:

 protected override IMvxPluginManager CreatePluginManager() { var toReturn = new MvxLoaderBasedPluginManager(); var sharedRegistry = new MvxLoaderPluginRegistry(".WindowsPhone",toReturn.Loaders); sharedRegistry.AddConventionBasedPlugin<SharedP1>(); sharedRegistry.AddConventionBasedPlugin<SharedP1>(); sharedRegistry.AddConventionBasedPlugin<SharedP3>(); var wp7Registry = new MvxLoaderPluginRegistry(".WP7",toReturn.Loaders); wp7Registry.AddConventionBasedPlugin<WP7P1>(); wp7Registry.AddConventionBasedPlugin<WP7P2>(); return toReturn; } 

Finally, there's nothing forcing you to use conventions at all - you can always just provide your own plugin loading methods providing Func<IMvxPlugin> - e.g.

 protected override IMvxPluginManager CreatePluginManager() { var toReturn = new MvxLoaderBasedPluginManager(); toReturn.Loaders.Add('Cirrious.MvvmCross.Plugins.Visibility.WindowsPhone.Plugin', () => { // do whatever code you want to do... return thePlugin; }); return toReturn; } 

You can mix and match these techniques


Alternatively, you can provide a totally new implementation of IMvxPluginManager if you want to. The interface is just:

public interface IMvxPluginManager { bool IsPluginLoaded<T>() where T : IMvxPluginLoader; void EnsureLoaded<T>() where T : IMvxPluginLoader; } 

So, you could, for example provide a very simply manager like

public class SimplePluginManager : IMvxPluginManager { public SimplePluginManager() { // load the plugins your app needs here! Cirrious.MvvmCross.Plugins.Visibility.Wp7.Plugin.Load(); Cirrious.MvvmCross.Plugins.Color.WindowsPhone.Plugin.Load(); } public bool IsPluginLoaded<T>() where T : IMvxPluginLoader { return true; } public void EnsureLoaded<T>() where T : IMvxPluginLoader { } } 
Sign up to request clarification or add additional context in comments.

1 Comment

The problem seems to be solved as I get a new error. I will dig to find a solution. Thank you for your quick help.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.