Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
0
        private void SaveGroup(ConfigFileManager cfgFile, List<AddonInfo> addonList, string groupName)
        {
            string addons = string.Empty;
            foreach (AddonInfo ai in addonList)
            {
                if (ai.Selected || ai.IsRequired)
                {
                    addons += ai.Name;
                    addons += "|";

                    cfgFile.SetValue(ai.Name, ai.CodeBase);
                }
            }

            if (addons.Length > 0)
            {
                cfgFile.SetValue(groupName, addons.TrimEnd(new char[] { '|' }));
            }
            else
            {
                cfgFile.SetValue(groupName, string.Empty);
            }
        }