예제 #1
0
        protected override void InitializeApp(IMvxPluginManager pluginManager, IMvxApplication app)
        {
#if !USE_PRODUCTION_API
            System.Net.ServicePointManager.ServerCertificateValidationCallback
                += (sender, certificate, chain, sslPolicyErrors) => true;
#endif

            const string clientName  = "Daneel";
            var          version     = NSBundle.MainBundle.InfoDictionary["CFBundleShortVersionString"].ToString();
            var          database    = new Database();
            var          scheduler   = Scheduler.Default;
            var          timeService = new TimeService(scheduler);
            var          topViewControllerProvider = (ITopViewControllerProvider)Presenter;
            var          mailService                 = new MailService(topViewControllerProvider);
            var          dialogService               = new DialogService(topViewControllerProvider);
            var          platformConstants           = new PlatformConstants();
            var          suggestionProviderContainer = new SuggestionProviderContainer(
                new MostUsedTimeEntrySuggestionProvider(database, timeService, maxNumberOfSuggestions)
                );

            var appVersion        = Version.Parse(version);
            var userAgent         = new UserAgent(clientName, version);
            var keyValueStorage   = new UserDefaultsStorage();
            var settingsStorage   = new SettingsStorage(Version.Parse(version), keyValueStorage);
            var schedulerProvider = new IOSSchedulerProvider();

            var foundation =
                TogglFoundation
                .ForClient(userAgent, appVersion)
                .WithDatabase(database)
                .WithScheduler(scheduler)
                .WithMailService(mailService)
                .WithTimeService(timeService)
                .WithApiEnvironment(environment)
                .WithGoogleService <GoogleService>()
                .WithRatingService <RatingService>()
                .WithLicenseProvider <LicenseProvider>()
                .WithAnalyticsService(analyticsService)
                .WithSchedulerProvider(schedulerProvider)
                .WithPlatformConstants(platformConstants)
                .WithRemoteConfigService <RemoteConfigService>()
                .WithApiFactory(new ApiFactory(environment, userAgent))
                .WithBackgroundService(new BackgroundService(timeService))
                .WithApplicationShortcutCreator <ApplicationShortcutCreator>()
                .WithSuggestionProviderContainer(suggestionProviderContainer)

                .StartRegisteringPlatformServices()
                .WithDialogService(dialogService)
                .WithLastTimeUsageStorage(settingsStorage)
                .WithBrowserService <BrowserService>()
                .WithKeyValueStorage(keyValueStorage)
                .WithUserPreferences(settingsStorage)
                .WithOnboardingStorage(settingsStorage)
                .WithNavigationService(navigationService)
                .WithAccessRestrictionStorage(settingsStorage)
                .WithPasswordManagerService <OnePasswordService>()
                .WithErrorHandlingService(new ErrorHandlingService(navigationService, settingsStorage))
                .Build();

            foundation.RevokeNewUserIfNeeded().Initialize();

            base.InitializeApp(pluginManager, app);
        }