Beispiel #1
0
        /// <summary>
        /// Any initialization steps that can be done in the background.
        /// </summary>
        public override void Initialize()
        {
            // init des location services.
            typeof(LocationService).Assembly.CreatableTypes()
            .EndingWith("Service")
            .AsInterfaces()
            .RegisterAsLazySingleton();

            // static registration => same instance
            Mvx.IoCProvider.RegisterSingleton(Plugin.Settings.CrossSettings.Current);
            Mvx.IoCProvider.RegisterSingleton <ITcxActivityService>(() => new TcxActivityService());
            Mvx.IoCProvider.RegisterSingleton <IDbActivityService>(() => new DbActivityService());
            Mvx.IoCProvider.RegisterSingleton <DatabaseContext>(() => new DatabaseContext());
            var context = Mvx.IoCProvider.Resolve <DatabaseContext>();

            Mvx.IoCProvider.RegisterSingleton <IRideService>(() => new RideService(context));

            // dynamic registration => new service on resolving
            Mvx.IoCProvider.RegisterType <ICountdownService>(() => new CountdownService());

            this.RegisterAppStart <ViewModels.MainPageViewModel>();

            SkiaHelper.Initialize((float)DeviceDisplay.MainDisplayInfo.Density);

            base.Initialize();
        }
Beispiel #2
0
        protected override async void OnInitialized()
        {
            Xamarin.Forms.Internals.Log.Listeners.Add(new DelegateLogListener((arg1, arg2) => Console.WriteLine($"{arg1}: {arg2}")));

            InitializeComponent();

            SkiaHelper.Initialize((float)DeviceDisplay.MainDisplayInfo.Density);

            await NavigationService.NavigateAsync("NavigationPage/ActivityHeaderPage");
        }