Ejemplo n.º 1
0
        /// <summary>
        /// Register providers from user settings, where they were previously saved.
        /// </summary>
        public async Task RestoreProviders()
        {
            // Load available IProvider types into memory
            if (ProviderService.Available.Count == 0)
            {
                ProviderService.LoadProviders();
            }

            var tasks = new Dictionary <string, Task <bool> >();

            // ToList() is needed because the original Dictionary is changing while we iterating
            SettingsService.Current.SafeProviders
            .ToList()
            .ForEach(p => tasks[p.Key] = ProviderService.RegisterProvider(
                         ProviderService.GetProviderById(p.Value.Id), p.Key, p.Value.State, false));

            // Wait for tasks to finish and remove unloaded providers
            foreach (var task in tasks)
            {
                if (!ProviderService.Loaded.ContainsKey(task.Key) && !await task.Value)
                {
                    ToastService.Create(string.Format(Resources.ProviderRegistrationFailed, task.Key));
                    ProviderService.ClearProvider(task.Key);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Remove existing provider.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnRemoveProvider(object sender, EventArgs e)
        {
            if (removeProviderBox.SelectedItem == null)
            {
                return;
            }

            var name = removeProviderBox.SelectedItem.ToString();

            ProviderService.ClearProvider(name);
            removeProviderBox.ClearSelected();
        }