MVVMCross中的自定义插件

编程入门 行业动态 更新时间:2024-10-23 15:21:43
本文介绍了MVVMCross中的自定义插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在MVVMCross v3上工作,我想创建自己的插件,我遵循了本教程(适用于vNext)

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

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

为了与v3兼容,我将IMvxServiceConsumer和GetService更改为Mvx.Resolve.

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

但是在本教程中有:

然后,对于WinRT,WindowsPhone和MonoTouch客户端,还需要在setup.cs中提供一个Loader访问器,例如:

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); }

如何在v3中做到这一点?

How can I do that in v3?

谢谢

推荐答案

如果要编写新插件,则:

If you want to write a new plugin, then :

  • 最新示例为 github/slodge/MvvmCross-Tutorials/tree/master/GoodVibrations
  • 在 speakerdeck/cirrious/plugins-中,此示例有一些注释in-mvvmcross
  • the up-to-date sample is github/slodge/MvvmCross-Tutorials/tree/master/GoodVibrations
  • there are some notes on this sample in speakerdeck/cirrious/plugins-in-mvvmcross

对于插件初始化,nuget软件包现在通过引导文件执行此操作-例如在以下位置查看为位置添加的文件:

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

  • (WinRT,WinPhone,Droid)- github/slodge/NPlus1DaysOfMvvmCross/blob/master/N-08-Location/Location.Droid/Bootstrap/LocationPluginBootstrap.cs
  • (触摸)- github/slodge/NPlus1DaysOfMvvmCross/blob/master/N-08-Location/Location.Touch/Bootstrap/LocationPluginBootstrap.cs
  • (WinRT, WinPhone, Droid) - github/slodge/NPlus1DaysOfMvvmCross/blob/master/N-08-Location/Location.Droid/Bootstrap/LocationPluginBootstrap.cs
  • (Touch) - github/slodge/NPlus1DaysOfMvvmCross/blob/master/N-08-Location/Location.Touch/Bootstrap/LocationPluginBootstrap.cs

引导程序方法是现在进行初始化的常规方法.

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:

  • 在WinRT,WinPhone和Droid中,您不需要使用加载程序,但是在使用插件之前,您需要先调用MyPlugin.PluginManager.Instance.EnsureLoaded.
  • 在Touch中,您需要在protected override void AddPluginsLoaders(MvxLoaderPluginRegistry loaders)-期间提供一个加载程序,并且然后您仍然需要调用EnsureLoaded()才能使用该插件.
  • 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.

有关这种旧方式"工作的示例,请参见 github/slodge/MvvmCross-Tutorials/tree/master/Sample%20-%20TwitterSearch

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

更多推荐

MVVMCross中的自定义插件

本文发布于:2023-11-24 03:29:11,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1623809.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:自定义   插件   MVVMCross

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!