Xamarin MvvmCross初始化
在这个问题上,我想知道如何初始化MvvmCross系统 当时给出的答案有效,但随着MvvmCross的最新更新,我使用的函数(MvxAndroidSetupSingleton.GetOrCreateSetup())已被弃用 我现在已经更改了初始化,到目前为止它似乎还可以工作,但它是否正确?我应该采取不同的措施来提高可移植性吗 安装类,在Android平台特定的DLL中:Xamarin MvvmCross初始化,xamarin,xamarin.android,mvvmcross,Xamarin,Xamarin.android,Mvvmcross,在这个问题上,我想知道如何初始化MvvmCross系统 当时给出的答案有效,但随着MvvmCross的最新更新,我使用的函数(MvxAndroidSetupSingleton.GetOrCreateSetup())已被弃用 我现在已经更改了初始化,到目前为止它似乎还可以工作,但它是否正确?我应该采取不同的措施来提高可移植性吗 安装类,在Android平台特定的DLL中: public class Setup : MvxAndroidSetup { public Setup(Cont
public class Setup
: MvxAndroidSetup
{
public Setup(Context applicationContext)
: base(applicationContext)
{
}
protected override IMvxApplication CreateApp()
{
// Create logger class which can be used from now on
var logger = new AndroidLogger();
Mvx.RegisterSingleton(typeof(ILogger), logger);
var app = new App();
InitialisePlatformSpecificStuff();
return app;
}
private void InitialisePlatformSpecificStuff()
{
// For instance register platform specific classes with IoC
}
}
以及便携式核心库中的my App类:
public class App
: MvxApplication
{
public App()
{
}
public override void Initialize()
{
base.Initialize();
AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler;
InitialisePlugins();
InitaliseServices();
InitialiseStartNavigation();
}
private void InitaliseServices()
{
CreatableTypes().EndingWith("Service").AsInterfaces().RegisterAsLazySingleton();
}
private void InitialiseStartNavigation()
{
}
private void InitialisePlugins()
{
// initialise any plugins where are required at app startup
// e.g. Cirrious.MvvmCross.Plugins.Visibility.PluginLoader.Instance.EnsureLoaded();
}
public static void UnhandledExceptionHandler(object sender, UnhandledExceptionEventArgs e)
{
// Log exception info etc
}
我使用的函数(MvxAndroidSetupSingleton.GetOrCreateSetup())已被弃用
需要对MvvmCross初始化进行更改,以帮助用户避免“多个splashscreen”问题-请参阅
这些变化的核心是:
- var setup = MvxAndroidSetupSingleton.GetOrCreateSetup(activity.ApplicationContext);
- setup.EnsureInitialized(androidView.GetType());
并将其替换为:
+ var setupSingleton = MvxAndroidSetupSingleton.EnsureSingletonAvailable(activity.ApplicationContext);
+ setupSingleton.EnsureInitialized();
因此,您的更改需要反映相同的代码。oops。我忘了包括我在OnCreate中使用的设置代码。。。这正是你表现出来的。