public NavigationService(NavigationDataBag navigationDataBag, INavigationRouteService navigationRouteService, MvvmApp mvvmApp)
        {
            this.navigationDataBag      = navigationDataBag;
            this.navigationRouteService = navigationRouteService;
            this.mvvmApp = mvvmApp;
            this.mvvmApp.FormsApplication.PropertyChanged += FormsApplication_PropertyChanged;

            if (this.mvvmApp.FormsApplication.MainPage != null)
            {
                this.OnMainPageChanged();
            }
        }
Пример #2
0
        public static IServiceCollection AddMvvmServices(this IServiceCollection serviceDescriptors, MvvmApp mvvmApp)
        {
            serviceDescriptors.AddSingleton(mvvmApp);
            serviceDescriptors.AddSingleton <MvvmEngine>();

            serviceDescriptors.AddSingleton <INavigationService, NavigationService>();
            serviceDescriptors.AddSingleton <INavigationRouteService, NavigationRouteService>();

            serviceDescriptors.AddSingleton <NavigationDataBag>();
            serviceDescriptors.AddSingleton <IMessagingCenter>(MessagingCenter.Instance);

            // Register event service as all its public interfaces
            serviceDescriptors.AddSingleton <EventService>();
            serviceDescriptors.AddSingleton <IEventConsumer>(svc => svc.GetRequiredService <EventService>());
            serviceDescriptors.AddSingleton <IEventProducer>(svc => svc.GetRequiredService <EventService>());

            return(serviceDescriptors);
        }