than just mvvm! • Compiled image sizes can be large – especially on MonoTouch • Application libraries are cut and paste – a boring, error prone manual job • Automated cross-platform refactoring is impossible • No common way to extend the platform • Each new platform added requires manual cut-and- paste duplication of projects
MyUI .Droid MvvmCross .Adapter.Droid MyUI .WinRT Plugin1 .Touch Plugin2 .Touch … Plugin1 .Wp7 Plugin2 .Wp7 … Plugin1 .Droid Plugin2 .Droid … Plugin1 .WinRT Plugin2 .WinRT … MvvmCross .Adapter.Wp7 MvvmCross .Adapter.WinRT • M The Portable part of each Plugin: • Provides the interface for that plugin • e.g. for Location it provides Start, Stop, and an OnLocationChanged event. • Provides an EnsureLoaded() call for initialisation at runtime Plugin1 .Portable Plugin2 .Portable …
MyUI .WinRT Plugin1 .Portable Plugin2 .Portable … MvvmCross .Adapter.Touch MvvmCross .Adapter.Droid MvvmCross .Adapter.Wp7 MvvmCross .Adapter.WinRT • M Plugin1 .Touch Plugin2 .Touch … Plugin1 .Wp7 Plugin2 .Wp7 … Plugin1 .Droid Plugin2 .Droid … Plugin2 .WinRT … Plugin1 .WinRT Plugin Implementations: • Provide platform specific implementations of each Plugin Interface • e.g. for Location a platform specific service will provide Start, Stop, and OnLocationChanged. • Are initialised at runtime using a mixture of: • Project references • Convention-based dynamic assembly loading • Setup Helpers on platforms that don’t support Assembly.Load()
to, string cc, string subject, string body, bool isHtml); } In the Portable Library – Plugins.Email.dll: public class PluginLoader : IMvxPluginLoader , IMvxServiceConsumer<IMvxPluginManager> { public static readonly PluginLoader Instance = new PluginLoader(); #region Implementation of IMvxPluginLoader public void EnsureLoaded() { var manager = this.GetService<IMvxPluginManager>(); manager.EnsureLoaded<PluginLoader>(); } #endregion }
– Plugins.Email.WindowsPhone.dll: public class Plugin : IMvxPlugin , IMvxServiceProducer<IMvxComposeEmailTask> { #region Implementation of IMvxPlugin public void Load() { this.RegisterServiceType<IMvxComposeEmailTask, MvxComposeEmailTask>(); } #endregion } public class MvxComposeEmailTask : MvxWindowsPhoneTask, IMvxComposeEmailTask { public void ComposeEmail(string to, string cc, string subject, string body, bool isHtml) { var task = new EmailComposeTask() { To = to, Subject = subject, Cc = cc, Body = body }; DoWithInvalidOperationProtection(task.Show); } }
• Compiled image sizes can be much smaller – especially on MonoTouch • Each Application is now a single library • Cross-platform refactoring now a reality • Manual cut-and-paste between projects eliminated • Plugin technique allows easy extensibility for everyone • New portable architecture makes it easier to add ans support new platforms – Silverlight, WPF, MonoMac, PlayStationSuite, …