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(); }
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 static string[] ReadAddonConfig(ConfigFileManager config, string keyBase) { string[] names = null; string namesRaw = config.GetValue(keyBase); if (!string.IsNullOrEmpty(namesRaw)) { names = namesRaw.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); foreach (string name in names) { _assemblies.Add(name, config.GetValue(name)); } } return names; }