Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>MvvmCross plugins are designed to work as an assembly based layer on top of IoC.</p> <p>By using a shared pattern for namespaces and assemblies, along with a couple of helper classes (Plugin and PluginLoader), plugins provide a way to share and reuse portable native code components.</p> <p>The reason why iOS (and Mac) use a slightly different plugin loading scheme is because the MonoTouch's AoT compiler will not allow dynamic <code>Assembly.Load</code> loading.</p> <p>Because of this iOS has to use a different type of <code>PluginManager</code> and a different type of <code>Bootstrap</code> class to the other platforms. There's a bit more info on this in "How plugins are loaded" in <a href="https://github.com/MvvmCross/MvvmCross/wiki/MvvmCross-plugins#how-plugins-are-loaded" rel="nofollow">https://github.com/MvvmCross/MvvmCross/wiki/MvvmCross-plugins#how-plugins-are-loaded</a></p> <hr> <p>If you wanted to add the <code>Loader</code> type plugin registry to Android as well as iOS, then I think you could do this in a custom <code>PluginManager</code> class and could then create this during Setup using an override of <code>protected override IMvxPluginManager CreatePluginManager()</code>.</p> <p>Something like:</p> <pre><code>public class MyPluginManager : MvxFilePluginManager, IMvxLoaderPluginManager { private readonly Dictionary&lt;string, Func&lt;IMvxPlugin&gt;&gt; _finders = new Dictionary&lt;string, Func&lt;IMvxPlugin&gt;&gt;(); public MyPluginManager(string platformDllPostfix, string assemblyExtension = "") : base(platformDllPostfix, assemblyExtension) { } public IDictionary&lt;string, Func&lt;IMvxPlugin&gt;&gt; Finders { get { return _finders; } } protected override IMvxPlugin FindPlugin(Type toLoad) { var pluginName = toLoad.Namespace; if (string.IsNullOrEmpty(pluginName)) { throw new MvxException("Invalid plugin type {0}", toLoad); } Func&lt;IMvxPlugin&gt; finder; if (_finders.TryGetValue(pluginName, out finder)) { return finder(); } return base.FindPlugin(toLoad); } } </code></pre> <p>initialised in your Setup using:</p> <pre><code> protected override IMvxPluginManager CreatePluginManager() { return new MyPluginManager(".Droid", ".dll"); } </code></pre> <p>you would then need to ensure that your <code>loader</code> based plugins uses bootstrap classes based off of <code>MvxLoaderPluginBootstrapAction</code> and not <code>MvxPluginBootstrapAction</code></p> <hr> <p>As another alternative, if you are not interested in reusing your plugins individually - if you would rather not ship lots of individual plugin assemblies - then you could put all your interfaces and implementations into one single assembly - and they could then share a single <code>Bootstrap</code>, <code>Plugin</code> and <code>PluginLoader</code> between them.</p> <hr> <p>As a final alternative, for your custom needs, you can always consider using your own custom bootstrap classes - the standard <code>Setup</code> will create and <code>Run</code> any constructable class in your UI assembly which implements <code>IMvxBootstrapAction</code> - so you could replace <code>SettingsPluginBootstrap</code> with some custom <code>Run</code> action that suits your apps needs.</p> <pre><code>public class SettingsBootstrapAction : IMvxBootstrapAction { public void Run() { // my stuff here } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

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