Major adjustments to how setup is created to try to remove reflection scanning of assemblies

This commit is contained in:
Nick Randolph 2018-03-13 14:38:11 +11:00
Родитель c7c344fe08
Коммит e01373b899
19 изменённых файлов: 155 добавлений и 206 удалений

Просмотреть файл

@ -3,30 +3,23 @@
// See the LICENSE file in the project root for more information.
using System;
using System.Linq;
using System.Threading.Tasks;
using Foundation;
using MvvmCross.Core;
using MvvmCross.Exceptions;
using MvvmCross.Forms.Presenters;
using MvvmCross.IoC;
using MvvmCross.Platform.Ios.Core;
using MvvmCross.ViewModels;
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
namespace MvvmCross.Forms.Platform.Ios.Core
{
public abstract class MvxFormsApplicationDelegate : FormsApplicationDelegate, IMvxApplicationDelegate
{
private MvxFormsIosSetup _setup;
protected MvxFormsIosSetup Setup
{
protected MvxFormsIosSetup Setup
{
get
{
if (_setup == null)
_setup = CreateSetup(this, Window);
return _setup;
return MvxSetup.PlatformInstance<MvxFormsIosSetup>();
}
}
@ -48,6 +41,7 @@ namespace MvvmCross.Forms.Platform.Ios.Core
public override bool FinishedLaunching(UIApplication uiApplication, NSDictionary launchOptions)
{
Window = new UIWindow(UIScreen.MainScreen.Bounds);
Setup.PlatformInitialize(this, Window);
Setup.Initialize();
RunAppStart(launchOptions);
@ -103,10 +97,16 @@ namespace MvvmCross.Forms.Platform.Ios.Core
}
public event EventHandler<MvxLifetimeEventArgs> LifetimeChanged;
}
protected virtual MvxFormsIosSetup CreateSetup(IMvxApplicationDelegate applicationDelegate, UIWindow window)
public abstract class MvxFormsApplicationDelegate<TMvxIosSetup, TApplication, TFormsApplication> : MvxFormsApplicationDelegate
where TMvxIosSetup : MvxFormsIosSetup<TApplication, TFormsApplication>, new()
where TApplication : IMvxApplication, new()
where TFormsApplication : Application, new()
{
static MvxFormsApplicationDelegate()
{
return MvxSetupExtensions.CreateSetup<MvxFormsIosSetup>(this.GetType().Assembly, applicationDelegate, window);
MvxSetup.RegisterSetupType<TMvxIosSetup>();
}
}
}

Просмотреть файл

@ -26,16 +26,6 @@ namespace MvvmCross.Forms.Platform.Ios.Core
private List<Assembly> _viewAssemblies;
private Application _formsApplication;
protected MvxFormsIosSetup(IMvxApplicationDelegate applicationDelegate, UIWindow window)
: base(applicationDelegate, window)
{
}
protected MvxFormsIosSetup(IMvxApplicationDelegate applicationDelegate, IMvxIosViewPresenter presenter)
: base(applicationDelegate, presenter)
{
}
protected override IEnumerable<Assembly> GetViewAssemblies()
{
if (_viewAssemblies == null)
@ -115,14 +105,6 @@ namespace MvvmCross.Forms.Platform.Ios.Core
where TApplication : IMvxApplication, new()
where TFormsApplication : Application, new()
{
protected MvxFormsIosSetup(IMvxApplicationDelegate applicationDelegate, UIWindow window) : base(applicationDelegate, window)
{
}
protected MvxFormsIosSetup(IMvxApplicationDelegate applicationDelegate, IMvxIosViewPresenter presenter) : base(applicationDelegate, presenter)
{
}
protected override IEnumerable<Assembly> GetViewAssemblies()
{
return new List<Assembly>(base.GetViewAssemblies().Union(new[] { typeof(TFormsApplication).GetTypeInfo().Assembly }));

Просмотреть файл

@ -27,11 +27,6 @@ namespace MvvmCross.Forms.Platform.Uap.Core
private List<Assembly> _viewAssemblies;
private Application _formsApplication;
protected MvxFormsWindowsSetup(XamlControls.Frame rootFrame, IActivatedEventArgs activatedEventArgs, string suspensionManagerSessionStateKey = null)
: base(rootFrame, activatedEventArgs, suspensionManagerSessionStateKey)
{
}
/// <summary>
/// Override to provide list of assemblies to search for views.
/// Additionally for UWP .NET Native compilation include the assemblies containing custom controls and renderers to be passed to <see cref="Xamarin.Forms.Forms.Init" /> method.
@ -95,11 +90,6 @@ namespace MvvmCross.Forms.Platform.Uap.Core
where TApplication : IMvxApplication, new()
where TFormsApplication : Application, new()
{
public MvxFormsWindowsSetup(XamlControls.Frame rootFrame, IActivatedEventArgs activatedEventArgs, string suspensionManagerSessionStateKey = null)
: base(rootFrame, activatedEventArgs, suspensionManagerSessionStateKey)
{
}
protected override IEnumerable<Assembly> GetViewAssemblies()
{
return new List<Assembly>(base.GetViewAssemblies().Union(new[] { typeof(TFormsApplication).GetTypeInfo().Assembly }));

Просмотреть файл

@ -19,6 +19,7 @@ namespace MvvmCross.Forms.Platform.Uap.Views
{
if (RootFrame?.Content == null)
{
Setup.PlatformInitialize(RootFrame, activationArgs, nameof(Suspend));
Setup.Initialize();
var startup = Mvx.Resolve<IMvxAppStart>();

Просмотреть файл

@ -21,6 +21,32 @@ namespace MvvmCross.Core
{
public abstract class MvxSetup
{
protected static Type RegisteredSetupType { get; set; }
public static void RegisterSetupType<TMvxSetup>() where TMvxSetup: MvxSetup,new()
{
RegisteredSetupType = typeof(TMvxSetup);
}
private static MvxSetup instance;
public static MvxSetup Instance
{
get
{
if (instance != null) return instance;
if (RegisteredSetupType != null) {
instance = Activator.CreateInstance(RegisteredSetupType) as MvxSetup;
} else {
instance = MvxSetupExtensions.CreateSetup<MvxSetup>();
}
return instance;
}
}
public static TMvxSetup PlatformInstance<TMvxSetup>() where TMvxSetup:MvxSetup
{
return Instance as TMvxSetup;
}
protected abstract IMvxApplication CreateApp();
protected abstract IMvxViewsContainer CreateViewsContainer();
@ -37,8 +63,7 @@ namespace MvvmCross.Core
public virtual void InitializePrimary()
{
if (State != MvxSetupState.Uninitialized)
{
if (State != MvxSetupState.Uninitialized) {
throw new MvxException("Cannot start primary - as state already {0}", State);
}
State = MvxSetupState.InitializingPrimary;
@ -46,8 +71,7 @@ namespace MvvmCross.Core
InitializeLoggingServices();
SetupLog.Trace("Setup: Primary start");
State = MvxSetupState.InitializedPrimary;
if (State != MvxSetupState.InitializedPrimary)
{
if (State != MvxSetupState.InitializedPrimary) {
throw new MvxException("Cannot start seconday - as state is currently {0}", State);
}
State = MvxSetupState.InitializingSecondary;
@ -147,8 +171,7 @@ namespace MvvmCross.Core
protected virtual void PerformBootstrapActions()
{
var bootstrapRunner = new MvxBootstrapRunner();
foreach (var assembly in GetBootstrapOwningAssemblies())
{
foreach (var assembly in GetBootstrapOwningAssemblies()) {
bootstrapRunner.Run(assembly);
}
}
@ -205,8 +228,7 @@ namespace MvvmCross.Core
protected virtual void InitializeLoggingServices()
{
var logProvider = CreateLogProvider();
if (logProvider != null)
{
if (logProvider != null) {
Mvx.RegisterSingleton(logProvider);
SetupLog = logProvider.GetLogFor<MvxSetup>();
var globalLog = logProvider.GetLogFor<MvxLog>();
@ -220,8 +242,7 @@ namespace MvvmCross.Core
protected virtual IMvxLogProvider CreateLogProvider()
{
switch (GetDefaultLogProviderType())
{
switch (GetDefaultLogProviderType()) {
case MvxLogProviderType.Console:
return new ConsoleLogProvider();
case MvxLogProviderType.EntLib:
@ -285,8 +306,7 @@ namespace MvvmCross.Core
.SelectMany(assembly => assembly.GetTypes())
.Where(TypeContainsPluginAttribute);
foreach (var pluginType in pluginTypes)
{
foreach (var pluginType in pluginTypes) {
pluginManager.EnsurePluginLoaded(pluginType);
}
@ -377,8 +397,7 @@ namespace MvvmCross.Core
Mvx.RegisterSingleton(viewModelByNameRegistry);
var viewModelAssemblies = GetViewModelAssemblies();
foreach (var assembly in viewModelAssemblies)
{
foreach (var assembly in viewModelAssemblies) {
viewModelByNameRegistry.AddAll(assembly);
}
@ -461,8 +480,7 @@ namespace MvvmCross.Core
public virtual void EnsureInitialized(Type requiredBy)
{
switch (State)
{
switch (State) {
case MvxSetupState.Uninitialized:
Initialize();
break;

Просмотреть файл

@ -28,6 +28,20 @@ namespace MvvmCross.Core
}
}
public static TSetup CreateSetup<TSetup>() where TSetup : MvxSetup
{
var setupType = FindSetupType<TSetup>();
if (setupType == null) {
throw new MvxException("Could not find a Setup class for application");
}
try {
return (TSetup)Activator.CreateInstance(setupType);
} catch (Exception exception) {
throw exception.MvxWrap("Failed to create instance of {0}", setupType.FullName);
}
}
public static Type FindSetupType<TSetup>(Assembly assembly)
{
var query = from type in assembly.ExceptionSafeGetTypes()
@ -37,5 +51,16 @@ namespace MvvmCross.Core
return query.FirstOrDefault();
}
public static Type FindSetupType<TSetup>()
{
var query = from assembly in AppDomain.CurrentDomain.GetAssemblies()
from type in assembly.ExceptionSafeGetTypes()
where type.Name == "Setup"
where typeof(TSetup).IsAssignableFrom(type)
select type;
return query.FirstOrDefault();
}
}
}

Просмотреть файл

@ -3,11 +3,8 @@
// See the LICENSE file in the project root for more information.
using System;
using System.Linq;
using Foundation;
using MvvmCross.Core;
using MvvmCross.Exceptions;
using MvvmCross.IoC;
using MvvmCross.ViewModels;
using UIKit;
@ -15,14 +12,11 @@ namespace MvvmCross.Platform.Ios.Core
{
public abstract class MvxApplicationDelegate : UIApplicationDelegate, IMvxApplicationDelegate
{
private MvxIosSetup _setup;
protected MvxIosSetup Setup
{
get
{
if (_setup == null)
_setup = CreateSetup(this, Window);
return _setup;
return MvxSetup.PlatformInstance<MvxIosSetup>();
}
}
@ -44,6 +38,9 @@ namespace MvvmCross.Platform.Ios.Core
public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
{
Window = new UIWindow(UIScreen.MainScreen.Bounds);
Setup.PlatformInitialize(this, Window);
Setup.Initialize();
RunAppStart(launchOptions);
@ -55,7 +52,7 @@ namespace MvvmCross.Platform.Ios.Core
protected virtual void RunAppStart(object hint = null)
{
var startup = Mvx.Resolve<IMvxAppStart>();
if(!startup.IsStarted)
if (!startup.IsStarted)
startup.Start(GetAppStartHint(hint));
Window.MakeKeyAndVisible();
@ -73,10 +70,15 @@ namespace MvvmCross.Platform.Ios.Core
}
public event EventHandler<MvxLifetimeEventArgs> LifetimeChanged;
}
protected virtual MvxIosSetup CreateSetup(IMvxApplicationDelegate applicationDelegate, UIWindow window)
public abstract class MvxApplicationDelegate<TMvxIosSetup, TApplication> : MvxApplicationDelegate
where TMvxIosSetup : MvxIosSetup<TApplication>, new()
where TApplication : IMvxApplication, new()
{
static MvxApplicationDelegate()
{
return MvxSetupExtensions.CreateSetup<MvxIosSetup>(this.GetType().Assembly, applicationDelegate, window);
MvxSetup.RegisterSetupType<TMvxIosSetup>();
}
}
}

Просмотреть файл

@ -23,30 +23,31 @@ using MvvmCross.Presenters;
namespace MvvmCross.Platform.Ios.Core
{
public abstract class MvxIosSetup
: MvxSetup
public interface IMvxIosSetup
{
private readonly IMvxApplicationDelegate _applicationDelegate;
private readonly UIWindow _window;
void PlatformInitialize(IMvxApplicationDelegate applicationDelegate, UIWindow window);
void PlatformInitialize(IMvxApplicationDelegate applicationDelegate, IMvxIosViewPresenter presenter);
}
public abstract class MvxIosSetup
: MvxSetup, IMvxIosSetup
{
protected IMvxApplicationDelegate ApplicationDelegate { get; private set; }
protected UIWindow Window { get; private set; }
private IMvxIosViewPresenter _presenter;
protected MvxIosSetup(IMvxApplicationDelegate applicationDelegate, UIWindow window)
public virtual void PlatformInitialize(IMvxApplicationDelegate applicationDelegate, UIWindow window)
{
_window = window;
_applicationDelegate = applicationDelegate;
Window = window;
ApplicationDelegate = applicationDelegate;
}
protected MvxIosSetup(IMvxApplicationDelegate applicationDelegate, IMvxIosViewPresenter presenter)
public virtual void PlatformInitialize(IMvxApplicationDelegate applicationDelegate, IMvxIosViewPresenter presenter)
{
_applicationDelegate = applicationDelegate;
ApplicationDelegate = applicationDelegate;
_presenter = presenter;
}
protected UIWindow Window => _window;
protected IMvxApplicationDelegate ApplicationDelegate => _applicationDelegate;
protected sealed override IMvxViewsContainer CreateViewsContainer()
{
var container = CreateIosViewsContainer();
@ -90,7 +91,7 @@ namespace MvvmCross.Platform.Ios.Core
protected virtual void RegisterLifetime()
{
Mvx.RegisterSingleton<IMvxLifetime>(_applicationDelegate);
Mvx.RegisterSingleton<IMvxLifetime>(ApplicationDelegate);
}
protected IMvxIosViewPresenter Presenter
@ -104,7 +105,7 @@ namespace MvvmCross.Platform.Ios.Core
protected virtual IMvxIosViewPresenter CreateViewPresenter()
{
return new MvxIosViewPresenter(_applicationDelegate, _window);
return new MvxIosViewPresenter(ApplicationDelegate, Window);
}
protected virtual void RegisterPresenter()
@ -174,17 +175,9 @@ namespace MvvmCross.Platform.Ios.Core
}
}
public abstract class MvxIosSetup<TApplication> : MvxIosSetup
public class MvxIosSetup<TApplication> : MvxIosSetup
where TApplication : IMvxApplication, new()
{
protected MvxIosSetup(IMvxApplicationDelegate applicationDelegate, UIWindow window) : base(applicationDelegate, window)
{
}
protected MvxIosSetup(IMvxApplicationDelegate applicationDelegate, IMvxIosViewPresenter presenter) : base(applicationDelegate, presenter)
{
}
protected override IMvxApplication CreateApp() => Mvx.IocConstruct<TApplication>();
protected override IEnumerable<Assembly> GetViewModelAssemblies()

Просмотреть файл

@ -26,26 +26,43 @@ using MvvmCross.Presenters;
namespace MvvmCross.Platform.Uap.Core
{
public abstract class MvxWindowsSetup
: MvxSetup
public interface IMvxWindowsSetup
{
private readonly IMvxWindowsFrame _rootFrame;
private readonly string _suspensionManagerSessionStateKey;
void PlatformInitialize(Frame rootFrame, IActivatedEventArgs activatedEventArgs, string suspensionManagerSessionStateKey = null);
void PlatformInitialize(Frame rootFrame, string suspensionManagerSessionStateKey = null);
void PlatformInitialize(IMvxWindowsFrame rootFrame);
}
public abstract class MvxWindowsSetup
: MvxSetup, IMvxWindowsSetup
{
private IMvxWindowsFrame _rootFrame;
private string _suspensionManagerSessionStateKey;
private IMvxWindowsViewPresenter _presenter;
protected MvxWindowsSetup(Frame rootFrame, IActivatedEventArgs activatedEventArgs,
string suspensionManagerSessionStateKey = null) : this(rootFrame, suspensionManagerSessionStateKey)
// Oww, this is nasty but can't think of a way around it.
protected static Assembly viewAssembly;
public static void RegisterSetupType<TMvxSetup>() where TMvxSetup : MvxWindowsSetup, new()
{
viewAssembly = Assembly.GetCallingAssembly();
MvxSetup.RegisterSetupType<TMvxSetup>();
}
public virtual void PlatformInitialize(Frame rootFrame, IActivatedEventArgs activatedEventArgs,
string suspensionManagerSessionStateKey = null)
{
PlatformInitialize(rootFrame, suspensionManagerSessionStateKey);
ActivationArguments = activatedEventArgs;
}
protected MvxWindowsSetup(Frame rootFrame, string suspensionManagerSessionStateKey = null)
: this(new MvxWrappedFrame(rootFrame))
public virtual void PlatformInitialize(Frame rootFrame, string suspensionManagerSessionStateKey = null)
{
PlatformInitialize(new MvxWrappedFrame(rootFrame));
_suspensionManagerSessionStateKey = suspensionManagerSessionStateKey;
}
protected MvxWindowsSetup(IMvxWindowsFrame rootFrame)
public virtual void PlatformInitialize(IMvxWindowsFrame rootFrame)
{
_rootFrame = rootFrame;
}
@ -183,34 +200,16 @@ namespace MvvmCross.Platform.Uap.Core
{
return new MvxPostfixAwareViewToViewModelNameMapping("View", "Page");
}
}
public class MvxWindowsSetup<TApplication> : MvxWindowsSetup
where TApplication : IMvxApplication, new()
{
protected readonly Assembly viewAssembly;
public MvxWindowsSetup(Frame rootFrame, IActivatedEventArgs activatedEventArgs,
string suspensionManagerSessionStateKey = null) : base(rootFrame, activatedEventArgs, suspensionManagerSessionStateKey)
{
viewAssembly = Assembly.GetCallingAssembly();
}
public MvxWindowsSetup(Frame rootFrame, string suspensionManagerSessionStateKey = null) : base(rootFrame, suspensionManagerSessionStateKey)
{
viewAssembly = Assembly.GetCallingAssembly();
}
public MvxWindowsSetup(IMvxWindowsFrame rootFrame) : base(rootFrame)
{
viewAssembly = Assembly.GetCallingAssembly();
}
protected override IEnumerable<Assembly> GetViewAssemblies()
{
return base.GetViewAssemblies().Union(new[] { viewAssembly });
}
}
public class MvxWindowsSetup<TApplication> : MvxWindowsSetup
where TApplication : IMvxApplication, new()
{
protected override IEnumerable<Assembly> GetViewModelAssemblies()
{
return new[] { typeof(TApplication).GetTypeInfo().Assembly };

Просмотреть файл

@ -20,14 +20,11 @@ namespace MvvmCross.Platform.Uap.Views
{
protected IActivatedEventArgs ActivationArguments { get; private set; }
private MvxWindowsSetup _setup;
protected MvxWindowsSetup Setup
{
get
{
if (_setup == null)
_setup = CreateSetup(RootFrame, ActivationArguments, nameof(Suspend));
return _setup;
return MvxSetup.PlatformInstance<MvxWindowsSetup>();
}
}
@ -51,14 +48,13 @@ namespace MvvmCross.Platform.Uap.Views
var rootFrame = InitializeFrame(activationArgs);
if (activationArgs.PrelaunchActivated == false)
{
if (activationArgs.PrelaunchActivated == false) {
RunAppStart(activationArgs);
}
Window.Current.Activate();
}
protected override void OnActivated(IActivatedEventArgs activationArgs)
{
base.OnActivated(activationArgs);
@ -72,8 +68,8 @@ namespace MvvmCross.Platform.Uap.Views
protected virtual void RunAppStart(IActivatedEventArgs activationArgs)
{
if (RootFrame.Content == null)
{
if (RootFrame.Content == null) {
Setup.PlatformInitialize(RootFrame, ActivationArguments, nameof(Suspend));
Setup.Initialize();
var startup = Mvx.Resolve<IMvxAppStart>();
@ -95,16 +91,14 @@ namespace MvvmCross.Platform.Uap.Views
{
var rootFrame = Window.Current.Content as Frame;
if (rootFrame == null)
{
if (rootFrame == null) {
rootFrame = CreateFrame();
rootFrame.NavigationFailed += OnNavigationFailed;
Window.Current.Content = rootFrame;
}
if (activationArgs.PreviousExecutionState == ApplicationExecutionState.Terminated)
{
if (activationArgs.PreviousExecutionState == ApplicationExecutionState.Terminated) {
OnResumeFromTerminateState();
}
@ -153,10 +147,6 @@ namespace MvvmCross.Platform.Uap.Views
{
return Task.CompletedTask;
}
protected virtual MvxWindowsSetup CreateSetup(Frame rootFrame, IActivatedEventArgs activationArgs, string suspension)
{
return MvxSetupExtensions.CreateSetup<MvxWindowsSetup>(this.GetType().Assembly, rootFrame, activationArgs, suspension);
}
}
}

Просмотреть файл

@ -9,16 +9,16 @@ namespace Playground.Forms.Uwp
{
sealed partial class App
{
static App()
{
MvxWindowsSetup.RegisterSetupType< MvxFormsWindowsSetup < Core.App, FormsApp >> ();
}
public App()
{
InitializeComponent();
}
protected override MvxWindowsSetup CreateSetup(Frame rootFrame, IActivatedEventArgs e, string suspension)
{
return new MvxFormsWindowsSetup<Core.App, FormsApp>(rootFrame, e, suspension);
}
protected override Type HostWindowsPageType()
{
return typeof(MainPage);

Просмотреть файл

@ -2,7 +2,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Playground.Forms.Uwp"
xmlns:mvxf="using:MvvmCross.Forms.Views.Base"
xmlns:mvxf="using:MvvmCross.Forms.Views"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

Просмотреть файл

@ -1,14 +1,12 @@
using Foundation;
using MvvmCross;
using MvvmCross.Forms.Platform.Ios.Core;
using MvvmCross.Platform.Ios.Core;
using MvvmCross.ViewModels;
using Playground.Forms.UI;
using UIKit;
namespace Playground.Forms.iOS
{
[Register("AppDelegate")]
public partial class AppDelegate : MvxFormsApplicationDelegate
public partial class AppDelegate : MvxFormsApplicationDelegate<MvxFormsIosSetup<Core.App, FormsApp>, Core.App, FormsApp>
{
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{

Просмотреть файл

@ -144,7 +144,6 @@
<ItemGroup>
<Compile Include="Main.cs" />
<Compile Include="AppDelegate.cs" />
<Compile Include="Setup.cs" />
<Compile Include="Views\OverrideAttributeView.cs" />
<Compile Include="Views\OverrideAttributeView.designer.cs">
<DependentUpon>OverrideAttributeView.cs</DependentUpon>

Просмотреть файл

@ -1,15 +0,0 @@
using MvvmCross.Forms.Platform.Ios.Core;
using MvvmCross.Platform.Ios.Core;
using Playground.Forms.UI;
using UIKit;
namespace Playground.Forms.iOS
{
public class Setup : MvxFormsIosSetup<Core.App, FormsApp>
{
public Setup(IMvxApplicationDelegate applicationDelegate, UIWindow window)
: base(applicationDelegate, window)
{
}
}
}

Просмотреть файл

@ -1,20 +1,19 @@
using MvvmCross.Platform.Uap.Core;
using MvvmCross.Platform.Uap.Views;
using Windows.ApplicationModel.Activation;
using Windows.UI.Xaml.Controls;
namespace Playground.Uwp
{
public sealed partial class App : MvxApplication
{
static App()
{
MvxWindowsSetup.RegisterSetupType<MvxWindowsSetup<Core.App>>();
}
public App()
{
InitializeComponent();
}
protected override MvxWindowsSetup CreateSetup(Frame rootFrame, IActivatedEventArgs activatedEventArgs, string suspension)
{
return new MvxWindowsSetup<Core.App>(rootFrame, activatedEventArgs, suspension);
}
}
}

Просмотреть файл

@ -2,6 +2,7 @@
using MvvmCross;
using MvvmCross.Platform.Ios.Core;
using MvvmCross.ViewModels;
using Playground.Core;
using UIKit;
namespace Playground.iOS
@ -9,7 +10,7 @@ namespace Playground.iOS
// The UIApplicationDelegate for the application. This class is responsible for launching the
// User Interface of the application, as well as listening (and optionally responding) to application events from iOS.
[Register("AppDelegate")]
public partial class AppDelegate : MvxApplicationDelegate
public partial class AppDelegate : MvxApplicationDelegate<MvxIosSetup<App>, App>
{
}
}

Просмотреть файл

@ -123,7 +123,6 @@
<ItemGroup>
<Compile Include="Main.cs" />
<Compile Include="AppDelegate.cs" />
<Compile Include="Setup.cs" />
<Compile Include="Views\ChildView.cs" />
<Compile Include="Views\ChildView.designer.cs">
<DependentUpon>ChildView.cs</DependentUpon>

Просмотреть файл

@ -1,32 +0,0 @@
using MvvmCross.Platform.Ios.Core;
using MvvmCross.Platform.Ios.Presenters;
using MvvmCross.ViewModels;
using Playground.Core;
using UIKit;
namespace Playground.iOS
{
public class Setup : MvxIosSetup
{
public Setup(IMvxApplicationDelegate applicationDelegate, UIWindow window)
: base(applicationDelegate, window)
{
}
public Setup(IMvxApplicationDelegate applicationDelegate, IMvxIosViewPresenter presenter)
: base(applicationDelegate, presenter)
{
}
protected override IMvxApplication CreateApp()
{
return new App();
}
protected override IMvxIosViewPresenter CreateViewPresenter()
{
return new MvxIosViewPresenter(ApplicationDelegate, Window);
}
}
}