private static void UninstallMarkedItems(ConfigFileManager config)
        {
            string[] names = null;
            string namesRaw = config.GetValue("MarkedForUninstall");

            if (!string.IsNullOrEmpty(namesRaw))
            {
                names = namesRaw.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (string name in names)
                {
                    try
                    {
                        UninstallAddonLibrary(name);
                    }
                    catch(Exception ex)
                    {
                        //ErrorDispatcher.DispatchError(ex);
                        Logger.LogException(ex);
                    }
                }

                config.DeleteValue("MarkedForUninstall");
                config.Save();
            }
        }
        private void ScheduleForUninstall(string assembly)
        {
            string addons = string.Empty;

            List<AddonInfo> itemsToDisable = new List<AddonInfo>();

            foreach (AddonInfo ai in addonList.AllAddons)
            {
                string[] codebaseParts = ai.CodeBase.Split(new char[]{'|'});
                if (codebaseParts.Length > 0 && 
                    codebaseParts[0].ToLowerInvariant() == assembly.ToLowerInvariant())
                {
                    addons += ai.TranslatedName;
                    addons += "\n";
                    itemsToDisable.Add(ai);
                }
            }

            if (itemsToDisable.Count < 1)
                return;

            if (itemsToDisable.Count == 1 ||
                (MessageDisplay.Query(Translator.Translate("TXT_SHAREDADDONS", addons),
                    Translator.Translate("TXT_CAUTION"), MessageBoxIcon.Question) == DialogResult.Yes))
            {
                // Clear for uninstalling.

                ConfigFileManager cfgFile = new ConfigFileManager(AddonsConfig.AddonsConfigFile);

                foreach (AddonInfo ai in itemsToDisable)
                {
                    cfgFile.DeleteValue(ai.Name);
                    addonList.RemoveAddon(ai);
                }

                cfgFile.Save();

                AddonsConfig.MarkForUninstall(assembly);
                _uninstallScheduled = true;
            }

            
        }
        internal static void MarkForUninstall(string assembly)
        {
            ConfigFileManager config = new ConfigFileManager(filePath);
            string markedForUninstall = config.GetValue("MarkedForUninstall", string.Empty);

            List<string> filesToDelete = new List<string>();

            IEnumerable<string> files = Directory.EnumerateFiles(Application.StartupPath, string.Format("{0}*", assembly));
            if (files != null)
            {
                foreach (string asmFile in files)
                {
                    Assembly asm = Assembly.LoadFrom(asmFile);
                    if (asm != null)
                    {
                        filesToDelete.Add(asmFile);

                        foreach (CultureInfo ci in AppConfig.SupportedCultures)
                        {
                            try
                            {
                                Assembly satAsm = asm.GetSatelliteAssembly(ci);
                                if (satAsm != null)
                                {
                                    string path = satAsm.Location.ToLowerInvariant();
                                    if (!filesToDelete.Contains(path))
                                    {
                                        filesToDelete.Add(path.ToLowerInvariant());
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                Logger.LogException(ex);
                            }
                        }

                        foreach (string file in filesToDelete)
                        {
                            markedForUninstall += file;
                            markedForUninstall += "|";
                        }
                    }
                }
            }

            config.SetValue("MarkedForUninstall", markedForUninstall);
            config.Save();
        }
        protected override void SaveInternal()
        {
            if (GetEnabledAddonCount(addonList.NavigationAddons) > 0)
            {
                if (!IsConfigurationChanged())
                {
                    //Nothing changed, therefore nothing is to be saved.
                    return;
                }

                if (AddonsConfig.IsInitialConfig || MessageDisplay.Query(Translator.Translate("TXT_ADDONS_CHANGED_RESTART"),
                    Translator.Translate("TXT_APP_RESTART"),
                    MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    ConfigFileManager cfgFile = new ConfigFileManager(AddonsConfig.AddonsConfigFile);

                    SaveGroup(cfgFile, addonList.NavigationAddons, "NavigationAddons");
                    SaveGroup(cfgFile, addonList.PropertyAddons, "PropertyAddons");
                    SaveGroup(cfgFile, addonList.PreviewAddons, "PreviewAddons");

                    cfgFile.Save();

                    if (!AddonsConfig.IsInitialConfig)
                    {
                        Logger.LogInfo("Updated addons configuration was saved. Requesting to reload.");
                        SettingsForm.RequestRestart();

                        //AddonDetector.FireReloadAddons();
                    }
                }
                else if (!AddonsConfig.IsInitialConfig)
                {
                    MessageDisplay.Show(Translator.Translate("TXT_ADDONS_NOT_CHANGED"), 
                        "Info", MessageBoxIcon.Information);
                }
            }
            else
            {
                throw new SettingsSaveException("You must enable at least one navigation addon !");
            }
        }