public static void Initialize(this MvvmCrossFoundation foundation)
        {
            initializeInversionOfControl(foundation);

            Func <ITogglDataSource, ISyncManager> createSyncManager(ITogglApi api) => dataSource =>
            TogglSyncManager.CreateSyncManager(foundation.Database, api, dataSource, foundation.TimeService, foundation.AnalyticsService, foundation.LastTimeUsageStorage, retryDelayLimit, foundation.Scheduler);

            ITogglDataSource createDataSource(ITogglApi api)
            {
                var dataSource = new TogglDataSource(
                    api,
                    foundation.Database,
                    foundation.TimeService,
                    foundation.ErrorHandlingService,
                    foundation.BackgroundService,
                    createSyncManager(api),
                    TimeSpan.FromMinutes(5),
                    foundation.NotificationService,
                    foundation.ShortcutCreator,
                    foundation.AnalyticsService)
                                 .RegisterServices();

                Mvx.ConstructAndRegisterSingleton <IInteractorFactory, InteractorFactory>();
                Mvx.ConstructAndRegisterSingleton <IAutocompleteProvider, AutocompleteProvider>();

                return(dataSource);
            }

            var loginManager =
                new LoginManager(foundation.ApiFactory, foundation.Database, foundation.GoogleService, foundation.ShortcutCreator, foundation.AccessRestrictionStorage, foundation.AnalyticsService, foundation.PrivateSharedStorageService, createDataSource, foundation.Scheduler);

            Mvx.RegisterSingleton <ILoginManager>(loginManager);
        }
Esempio n. 2
0
        private static void initializeInversionOfControl(MvvmCrossFoundation foundation)
        {
            Mvx.RegisterSingleton(foundation.BackgroundService);
            Mvx.RegisterSingleton(foundation.DialogService);
            Mvx.RegisterSingleton(foundation.Database);
            Mvx.RegisterSingleton(foundation.BrowserService);
            Mvx.RegisterSingleton(foundation.UserAgent);
            Mvx.RegisterSingleton(foundation.Scheduler);
            Mvx.RegisterSingleton(foundation.ApiFactory);
            Mvx.RegisterSingleton(foundation.TimeService);
            Mvx.RegisterSingleton(foundation.MailService);
            Mvx.RegisterSingleton(foundation.RatingService);
            Mvx.RegisterSingleton(foundation.ShortcutCreator);
            Mvx.RegisterSingleton(foundation.LicenseProvider);
            Mvx.RegisterSingleton(foundation.ShortcutCreator);
            Mvx.RegisterSingleton(foundation.AnalyticsService);
            Mvx.RegisterSingleton(foundation.PlatformConstants);
            Mvx.RegisterSingleton(foundation.Database.IdProvider);
            Mvx.RegisterSingleton(foundation.RemoteConfigService);
            Mvx.RegisterSingleton(foundation.SuggestionProviderContainer);
            Mvx.RegisterSingleton(foundation.UserPreferences);
            Mvx.RegisterSingleton(foundation.OnboardingStorage);
            Mvx.RegisterSingleton(foundation.AccessRestrictionStorage);
            Mvx.RegisterSingleton(foundation.LastTimeUsageStorage);
            Mvx.RegisterSingleton(foundation.ErrorHandlingService);
            Mvx.RegisterSingleton(foundation.PasswordManagerService ?? new StubPasswordManagerService());
            Mvx.RegisterSingleton(foundation.SchedulerProvider);

            // Feedback service is obsolete and is used only in the Android App and should be removed soon
            if (foundation.FeedbackService != null)
            {
                Mvx.RegisterSingleton(foundation.FeedbackService);
            }
        }
        public static void Initialize(this MvvmCrossFoundation foundation)
        {
            initializeInversionOfControl(foundation);

            (ISyncManager, IInteractorFactory) initializeAfterLogin(ITogglApi api)
            {
                var syncManager = TogglSyncManager.CreateSyncManager(
                    foundation.Database,
                    api,
                    foundation.DataSource,
                    foundation.TimeService,
                    foundation.AnalyticsService,
                    foundation.LastTimeUsageStorage,
                    foundation.Scheduler,
                    foundation.StopwatchProvider,
                    foundation.AutomaticSyncingService);

                Mvx.RegisterSingleton(api);
                Mvx.RegisterSingleton(syncManager);
                Mvx.ConstructAndRegisterSingleton <IInteractorFactory, InteractorFactory>();

                foundation.SyncErrorHandlingService.HandleErrorsOf(syncManager);

                var interactorFactory = Mvx.Resolve <IInteractorFactory>();

                return(syncManager, interactorFactory);
            }

            var userAccessManager =
                new UserAccessManager(foundation.ApiFactory, foundation.Database, foundation.GoogleService, foundation.PrivateSharedStorageService, initializeAfterLogin);

            Mvx.RegisterSingleton <IUserAccessManager>(userAccessManager);

            foundation.BackgroundSyncService.SetupBackgroundSync(userAccessManager);
        }
 private static void initializeInversionOfControl(MvvmCrossFoundation foundation)
 {
     Mvx.RegisterSingleton(foundation.DataSource);
     Mvx.RegisterSingleton(foundation.DataSource.Tags);
     Mvx.RegisterSingleton(foundation.DataSource.User);
     Mvx.RegisterSingleton(foundation.DataSource.Tasks);
     Mvx.RegisterSingleton(foundation.DataSource.Clients);
     Mvx.RegisterSingleton(foundation.DataSource.Projects);
     Mvx.RegisterSingleton(foundation.DataSource.TimeEntries);
     Mvx.RegisterSingleton(foundation.StopwatchProvider);
     Mvx.RegisterSingleton(foundation.BackgroundService);
     Mvx.RegisterSingleton(foundation.AutomaticSyncingService);
     Mvx.RegisterSingleton(foundation.BackgroundSyncService);
     Mvx.RegisterSingleton(foundation.DialogService);
     Mvx.RegisterSingleton(foundation.Database);
     Mvx.RegisterSingleton(foundation.BrowserService);
     Mvx.RegisterSingleton(foundation.UserAgent);
     Mvx.RegisterSingleton(foundation.Scheduler);
     Mvx.RegisterSingleton(foundation.ApiFactory);
     Mvx.RegisterSingleton(foundation.TimeService);
     Mvx.RegisterSingleton(foundation.RatingService);
     Mvx.RegisterSingleton(foundation.ShortcutCreator);
     Mvx.RegisterSingleton(foundation.LicenseProvider);
     Mvx.RegisterSingleton(foundation.ShortcutCreator);
     Mvx.RegisterSingleton(foundation.AnalyticsService);
     Mvx.RegisterSingleton(foundation.PlatformInfo);
     Mvx.RegisterSingleton(foundation.NotificationService);
     Mvx.RegisterSingleton(foundation.Database.IdProvider);
     Mvx.RegisterSingleton(foundation.RemoteConfigService);
     Mvx.RegisterSingleton(foundation.SuggestionProviderContainer);
     Mvx.RegisterSingleton(foundation.UserPreferences);
     Mvx.RegisterSingleton(foundation.OnboardingStorage);
     Mvx.RegisterSingleton(foundation.AccessRestrictionStorage);
     Mvx.RegisterSingleton(foundation.LastTimeUsageStorage);
     Mvx.RegisterSingleton(foundation.ErrorHandlingService);
     Mvx.RegisterSingleton(foundation.SyncErrorHandlingService);
     Mvx.RegisterSingleton(foundation.PermissionsService);
     Mvx.RegisterSingleton(foundation.CalendarService);
     Mvx.RegisterSingleton(foundation.SchedulerProvider);
     Mvx.RegisterSingleton(foundation.PlatformInfo);
     Mvx.RegisterSingleton(foundation.IntentDonationService);
     Mvx.RegisterSingleton(foundation.PrivateSharedStorageService);
     Mvx.RegisterSingleton(foundation.PasswordManagerService ?? new StubPasswordManagerService());
     Mvx.RegisterSingleton(foundation.RxActionFactory);
 }
Esempio n. 5
0
        public static void Initialize(this MvvmCrossFoundation foundation)
        {
            initializeInversionOfControl(foundation);

            Func <ITogglDataSource, ISyncManager> createSyncManager(ITogglApi api) => dataSource =>
            TogglSyncManager.CreateSyncManager(
                foundation.Database,
                api,
                dataSource,
                foundation.TimeService,
                foundation.AnalyticsService,
                foundation.LastTimeUsageStorage,
                foundation.Scheduler,
                foundation.StopwatchProvider);

            ITogglDataSource createDataSource(ITogglApi api)
            {
                var dataSource = new TogglDataSource(
                    api,
                    foundation.Database,
                    foundation.TimeService,
                    createSyncManager(api),
                    foundation.AnalyticsService)
                                 .RegisterServices();

                Mvx.RegisterSingleton <ITogglApi>(api);
                Mvx.ConstructAndRegisterSingleton <IInteractorFactory, InteractorFactory>();
                Mvx.ConstructAndRegisterSingleton <IAutocompleteProvider, AutocompleteProvider>();

                foundation.SyncErrorHandlingService.HandleErrorsOf(dataSource.SyncManager);

                return(dataSource);
            }

            var userAccessManager =
                new UserAccessManager(foundation.ApiFactory, foundation.Database, foundation.GoogleService, foundation.ShortcutCreator, foundation.PrivateSharedStorageService, createDataSource);

            Mvx.RegisterSingleton <IUserAccessManager>(userAccessManager);

            foundation.BackgroundSyncService.SetupBackgroundSync(userAccessManager);
            foundation.AutomaticSyncingService.SetupAutomaticSync(userAccessManager);
        }
Esempio n. 6
0
        public static MvvmCrossFoundation RevokeNewUserIfNeeded(this MvvmCrossFoundation foundation)
        {
            var now      = foundation.TimeService.CurrentDateTime;
            var lastUsed = foundation.OnboardingStorage.GetLastOpened();

            foundation.OnboardingStorage.SetLastOpened(now);
            if (!lastUsed.HasValue)
            {
                return(foundation);
            }

            var offset = now - lastUsed;

            if (offset < TimeSpan.FromDays(newUserThreshold))
            {
                return(foundation);
            }

            foundation.OnboardingStorage.SetIsNewUser(false);
            return(foundation);
        }
Esempio n. 7
0
 private static void initializeInversionOfControl(MvvmCrossFoundation foundation)
 {
     Mvx.RegisterSingleton(foundation.BackgroundService);
     Mvx.RegisterSingleton(foundation.DialogService);
     Mvx.RegisterSingleton(foundation.Database);
     Mvx.RegisterSingleton(foundation.BrowserService);
     Mvx.RegisterSingleton(foundation.UserAgent);
     Mvx.RegisterSingleton(foundation.Scheduler);
     Mvx.RegisterSingleton(foundation.ApiFactory);
     Mvx.RegisterSingleton(foundation.TimeService);
     Mvx.RegisterSingleton(foundation.MailService);
     Mvx.RegisterSingleton(foundation.ShortcutCreator);
     Mvx.RegisterSingleton(foundation.LicenseProvider);
     Mvx.RegisterSingleton(foundation.ShortcutCreator);
     Mvx.RegisterSingleton(foundation.AnalyticsService);
     Mvx.RegisterSingleton(foundation.PlatformConstants);
     Mvx.RegisterSingleton(foundation.Database.IdProvider);
     Mvx.RegisterSingleton(foundation.SuggestionProviderContainer);
     Mvx.RegisterSingleton(foundation.UserPreferences);
     Mvx.RegisterSingleton(foundation.OnboardingStorage);
     Mvx.RegisterSingleton(foundation.AccessRestrictionStorage);
     Mvx.RegisterSingleton(foundation.ApiErrorHandlingService);
     Mvx.RegisterSingleton(foundation.PasswordManagerService ?? new StubPasswordManagerService());
 }