Further into the MVVMCross framework, let's begin by building the MvxApplication
class.
public class App : MvxApplication { public override void Initialize() { CreatableTypes() .EndingWith("Service") .AsInterfaces() .RegisterAsLazySingleton(); } }
Pay attention to the CreatableTypes
function being called; the function uses reflection to find all classes in the core assembly that are Creatable
, meaning they have a public constructor and they are not abstract. Then, following this function, only register the class interfaces with their names ending in Service
as lazy singletons.
There is one more part to add to the Application
class. We must register the starting point, so add the following line under the RegisterAsLazySingleton
function:
RegisterAppStart<MainPageViewModel>();
3.135.198.174