public AppServices(ITogglApi api, ITogglDatabase database) { Scheduler = System.Reactive.Concurrency.Scheduler.Default; TimeService = new TimeService(Scheduler); var errorHandlingService = new ErrorHandlingService(NavigationServiceSubstitute, AccessRestrictionStorageSubsitute); syncErrorHandlingService = new SyncErrorHandlingService(errorHandlingService); var dataSource = new TogglDataSource( database, TimeService, AnalyticsServiceSubstitute); SyncManager = TogglSyncManager.CreateSyncManager( database, api, dataSource, TimeService, AnalyticsServiceSubstitute, LastTimeUsageStorageSubstitute, Scheduler, AutomaticSyncingService); syncErrorHandlingService.HandleErrorsOf(SyncManager); }
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); }
public AppServices(ITogglApi api, ITogglDatabase database) { Scheduler = System.Reactive.Concurrency.Scheduler.Default; TimeService = new TimeService(Scheduler); var errorHandlingService = new ErrorHandlingService(NavigationServiceSubstitute, AccessRestrictionStorageSubsitute); syncErrorHandlingService = new SyncErrorHandlingService(errorHandlingService); ISyncManager createSyncManager(ITogglDataSource dataSource) { var syncManager = TogglSyncManager.CreateSyncManager( database, api, dataSource, TimeService, AnalyticsServiceSubstitute, LastTimeUsageStorageSubstitute, Scheduler, StopwatchProvider); syncErrorHandlingService.HandleErrorsOf(syncManager); return(syncManager); } var togglDataSource = new TogglDataSource( api, database, TimeService, createSyncManager, AnalyticsServiceSubstitute); SyncManager = togglDataSource.SyncManager; }
private static TestConfigurator configureTogglSyncGraph() { var configurator = new TestConfigurator(); var entryPoints = new StateMachineEntryPoints(); var dependencyContainer = new TestDependencyContainer(); dependencyContainer.MockKeyValueStorage = Substitute.For <IKeyValueStorage>(); dependencyContainer.MockPushNotificationsTokenService = Substitute.For <IPushNotificationsTokenService>(); dependencyContainer.MockTimeService = Substitute.For <ITimeService>(); dependencyContainer.MockRemoteConfigService = Substitute.For <IRemoteConfigService>(); dependencyContainer.MockPushNotificationsTokenStorage = Substitute.For <IPushNotificationsTokenStorage>(); configurator.AllDistinctStatesInOrder.Add(entryPoints); TogglSyncManager.ConfigureTransitions( configurator, Substitute.For <ITogglDatabase>(), Substitute.For <ITogglApi>(), Substitute.For <ITogglDataSource>(), Substitute.For <IScheduler>(), Substitute.For <ITimeService>(), Substitute.For <IAnalyticsService>(), Substitute.For <ILastTimeUsageStorage>(), entryPoints, Substitute.For <ISyncStateQueue>(), dependencyContainer ); return(configurator); }
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); }
public static void Initialize(this FoundationMvvmCross self, App app, IScheduler scheduler) { Func <ITogglDataSource, ISyncManager> createSyncManager(ITogglApi api) => dataSource => TogglSyncManager.CreateSyncManager(self.Database, api, dataSource, self.TimeService, self.AnalyticsService, retryDelayLimit, scheduler); ITogglDataSource createDataSource(ITogglApi api) => new TogglDataSource(api, self.Database, self.TimeService, self.ApiErrorHandlingService, self.BackgroundService, createSyncManager(api), TimeSpan.FromMinutes(5), self.ShortcutCreator) .RegisterServices(); var loginManager = new LoginManager(self.ApiFactory, self.Database, self.GoogleService, self.ShortcutCreator, self.AccessRestrictionStorage, createDataSource); app.Initialize(loginManager, self.NavigationService, self.AccessRestrictionStorage); }
public TogglDataSource(ITogglDatabase database, ITogglApi api, ITimeService timeService, IScheduler scheduler) { Ensure.Argument.IsNotNull(api, nameof(api)); Ensure.Argument.IsNotNull(database, nameof(database)); Ensure.Argument.IsNotNull(timeService, nameof(timeService)); Ensure.Argument.IsNotNull(scheduler, nameof(scheduler)); this.database = database; User = new UserDataSource(database.User); Tags = new TagsDataSource(database.Tags); Tasks = new TasksDataSource(database.Tasks); Workspaces = new WorkspacesDataSource(database); Projects = new ProjectsDataSource(database.Projects); TimeEntries = new TimeEntriesDataSource(database.IdProvider, database.TimeEntries, timeService); AutocompleteProvider = new AutocompleteProvider(database); SyncManager = TogglSyncManager.CreateSyncManager(database, api, this, timeService, scheduler); }
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); }
private static TestConfigurator configureTogglSyncGraph() { var configurator = new TestConfigurator(); var entryPoints = new StateMachineEntryPoints(); configurator.AllDistinctStatesInOrder.Add(entryPoints); TogglSyncManager.ConfigureTransitions( configurator, Substitute.For <ITogglDatabase>(), Substitute.For <ITogglApi>(), Substitute.For <ITogglDataSource>(), Substitute.For <IScheduler>(), Substitute.For <ITimeService>(), Substitute.For <IAnalyticsService>(), entryPoints, Substitute.For <ISyncStateQueue>() ); return(configurator); }
public AppServices(ITogglApi api, ITogglDatabase database) { TogglApi = api; Scheduler = System.Reactive.Concurrency.Scheduler.Default; TimeService = new TimeService(Scheduler); var errorHandlingService = new ErrorHandlingService(NavigationServiceSubstitute, AccessRestrictionStorageSubsitute); syncErrorHandlingService = new SyncErrorHandlingService(errorHandlingService); var dataSource = new TogglDataSource( database, TimeService, AnalyticsServiceSubstitute); var dependencyContainer = new TestDependencyContainer(); dependencyContainer.MockKeyValueStorage = KeyValueStorage; dependencyContainer.MockPushNotificationsTokenService = PushNotificationsTokenService; dependencyContainer.MockTimeService = TimeService; dependencyContainer.MockPushNotificationsTokenStorage = PushNotificationsTokenStorage; dependencyContainer.MockRemoteConfigService = RemoteConfigService; SyncManager = TogglSyncManager.CreateSyncManager( database, api, dataSource, TimeService, AnalyticsServiceSubstitute, LastTimeUsageStorageSubstitute, Scheduler, AutomaticSyncingService, dependencyContainer); syncErrorHandlingService.HandleErrorsOf(SyncManager); }