private async Task InitializeAsync()
        {
            await Task.CompletedTask;

            _persistAndRestoreService.RestoreData();
            _themeSelectorService.SetTheme();
        }
コード例 #2
0
        public async Task <Unit> Handle(ApplicationInitializeCommand request, CancellationToken cancellationToken)
        {
            _logger.LogInformation("Initializing application");

            // Init vars
            var startUpArgs     = request.StartUpArgs;
            var requestUrl      = startUpArgs?.Skip(1).FirstOrDefault();
            var applicationMode = requestUrl.IsUrl() ? ApplicationMode.Select : ApplicationMode.Settings;

            _logger.LogInformation($"Determined startup arguments: {startUpArgs}");
            _logger.LogInformation($"Determined request url: {requestUrl}");
            _logger.LogInformation($"Determined application mode: {applicationMode}");

            // Init the application store
            _applicationState.StartUpArgs     = startUpArgs;
            _applicationState.ApplicationMode = applicationMode;

            // Restore the saved data
            _logger.LogInformation($"Restoring settings");
            _persistAndRestoreService.InitDataDirectory();
            _persistAndRestoreService.RestoreData();

            // Init browsers
            _logger.LogInformation($"Initializing browsers with their profiles");
            await _browserService.InitializeBrowsersAsync();

            // Init the browser store
            _browserState.RequestUrl             = requestUrl;
            _browserState.BrowserProfiles        = _browserService.GetBrowserProfilesAsync().Result;
            _browserState.SelectedBrowserProfile = _browserState.BrowserProfiles?.FirstOrDefault();

            // Try to auto select
            if (_applicationState.ApplicationMode == ApplicationMode.Select)
            {
                _logger.LogInformation($"Trying to determine the browser and profile to handle the requested url");

                var browserProfile = _browserState.BrowserProfiles
                                     .FirstOrDefault(bp => bp.Profile.SelectionRules.Any(rule => rule.IsMatch(requestUrl)));

                if (browserProfile != null)
                {
                    _logger.LogInformation($"Using '{browserProfile.Name}' to handle the requested url");
                    await _browserService.UseBrowserProfileAsync(
                        browserProfile,
                        _browserState.RequestUrl,
                        false);
                }
                else
                {
                    _logger.LogInformation($"No matching browser found to handle the requested url");
                }
            }

            // Init theme
            //var theme = _applicationService.GetTheme();
            //_applicationService.SetTheme(theme);

            return(Unit.Value);
        }
コード例 #3
0
 private async Task InitializeAsync()
 {
     if (!_isInitialized)
     {
         _persistAndRestoreService.RestoreData();
         _themeSelectorService.InitializeTheme();
         await Task.CompletedTask;
     }
 }
コード例 #4
0
        private async Task InitializeAsync()
        {
            if (!_isInitialized)
            {
//{[{
                _persistAndRestoreService.RestoreData();
//}]}
            }
        }
        private async Task InitializeAsync()
        {
            await Task.CompletedTask;

            _persistAndRestoreService.RestoreData();
            _themeSelectorService.SetTheme();
            _userDataService.Initialize();
            _identityService.LoggedIn  += OnLoggedIn;
            _identityService.LoggedOut += OnLoggedOut;
        }