Beispiel #1
0
            public async Task RetriesTransientErrorsForDocumentOperations(Action <ISetup <TestHttpClientHandler, Task <HttpResponseMessage> > > setup)
            {
                setup(HttpClientHandler.Setup(x => x.OnSendAsync(It.IsAny <HttpRequestMessage>(), It.IsAny <CancellationToken>())));

                await Assert.ThrowsAnyAsync <Exception>(() => IndexesOperationsWrapper.GetClient("test-index").Documents.CountAsync());

                VerifyAttemptCount(2);
            }
Beispiel #2
0
            public async Task RetriesTransientErrorsForIndexOperations(Action <ISetup <TestHttpClientHandler, Task <HttpResponseMessage> > > setup)
            {
                setup(HttpClientHandler.Setup(x => x.OnSendAsync(It.IsAny <HttpRequestMessage>(), It.IsAny <CancellationToken>())));

                await Assert.ThrowsAnyAsync <Exception>(() => SearchServiceClient.Indexes.ListAsync());

                VerifyAttemptCount(2);
            }
Beispiel #3
0
        public override async Task <IWorkbook> ConfigureAsync(Frame rootFrame)
        {
            if (rootFrame == null)
            {
                throw new ArgumentNullException(nameof(rootFrame));
            }

            bool sendAnalytics = WinSettings.Instance.GetValue <bool>(CoreSettings.SendAnalytics);

            string deviceId = "n/a";

            try
            {
                var settings = WinSettings.Instance;
                if (!settings.HasValue(CoreSettings.DeviceId) || settings.GetValue <string>(CoreSettings.DeviceId) == "N/A")
                {
                    string id = this.ComputeDeviceId();
                    settings.SetValue(CoreSettings.DeviceId, id);
                }

                deviceId = settings.GetValue <string>(CoreSettings.DeviceId);
            }
            catch (Exception ex)
            {
                TrackingManagerHelper.Exception(ex, "Error while setting device id");
            }

            var platformService = new PlatformService(this.version, deviceId, () => CrashHandler.GetDiagnosticsInformation());

            Ioc.RegisterInstance <IPlatformService, PlatformService>(platformService);

            TrackingManager trackingManager = new TrackingManager(sendAnalytics, platformService.DeviceFamily);

            Ioc.RegisterInstance <ITrackingManager, TrackingManager>(trackingManager);

            HttpClientHandler.Setup();

            ResourcesLocator.Initialize("ms-appx://", UriKind.Absolute);
            if (!WinSettings.Instance.GetValue <bool>(CoreSettings.UseDarkTheme))
            {
                ResourcesLocator.UpdateTheme(true);
            }

            var persistence = Ioc.RegisterInstance <IPersistenceLayer, WinPersistenceLayer>(new WinPersistenceLayer(automaticSave: true));

            LogService.Log("Bootstraper", string.Format("Version: {0}", ApplicationVersion.GetAppVersion()));

            var navigationService = new NavigationService(rootFrame, platformService);

            Ioc.RegisterInstance <INavigationService, NavigationService>(navigationService);

            var messageBoxService = new MessageBoxService(navigationService);

            Ioc.RegisterInstance <IMessageBoxService, MessageBoxService>(messageBoxService);

            Ioc.RegisterInstance <ISpeechService, SpeechService>(new SpeechService(messageBoxService));

            var workbook = this.InitializeWorkbook(persistence, platformService);

            // we just read the latest value of data from the DB, so even if there was a background sync
            // we now have the latest version, so we remove the background sync flag here
            workbook.Settings.SetValue(CoreSettings.SyncBackgroundOccured, false);

            this.keyboardShortcutManager = new KeyboardShortcutManager(workbook, rootFrame, navigationService, trackingManager);

            var backgroundTaskManager = new BackgroundTaskManager(workbook);

            backgroundTaskManager.InitializeAsync();
            Ioc.RegisterInstance <IBackgroundTaskManager, BackgroundTaskManager>(backgroundTaskManager);

            var notificationService = new NotificationService();

            Ioc.RegisterInstance <INotificationService, NotificationService>(notificationService);

            var startupManager = Ioc.Build <StartupManager>();

            Ioc.RegisterInstance <IStartupManager, StartupManager>(startupManager);

            Ioc.RegisterInstance <IAlarmManager, AlarmManager>(new AlarmManager(workbook));

            var tileManager = new TileManager(workbook, trackingManager, notificationService, false);

            tileManager.LoadSecondaryTilesAsync();
            Ioc.RegisterInstance <ITileManager, TileManager>(tileManager);

            var synchronizationManager = await InitializeSyncAsync(workbook, platformService, trackingManager);

            // it is important to remove old task after sync is initialized otherwise changes would not
            // tracked and put in the changelog for the next sync
            workbook.RemoveOldTasks();

            var cortanaService = new CortanaRuntimeService(workbook);

            // no need to await this call because it can runs in the background
            Task.Run(() =>
            {
                JumpListManager.SetupJumpListAsync();
                cortanaService.SetupDefinitionsAsync();
            });
            Ioc.RegisterInstance <ICortanaRuntimeService, CortanaRuntimeService>(cortanaService);

            return(workbook);
        }