ICSharpCode.Core.AddInManager.InstallAddIns C# (CSharp) Метод

InstallAddIns() публичный статический Метод

Installs the AddIns from AddInInstallTemp to the UserAddInPath. In case of installation errors, a error message is displayed to the user and the affected AddIn is added to the disabled list.
public static InstallAddIns ( List disabled ) : void
disabled List
Результат void
        public static void InstallAddIns(List<string> disabled)
        {
            if (!Directory.Exists(addInInstallTemp))
                return;
            LoggingService.Info("AddInManager.InstallAddIns started");
            if (!Directory.Exists(userAddInPath))
                Directory.CreateDirectory(userAddInPath);
            string removeFile = Path.Combine(addInInstallTemp, "remove.txt");
            bool allOK = true;
            List<string> notRemoved = new List<string>();
            if (File.Exists(removeFile)) {
                using (StreamReader r = new StreamReader(removeFile)) {
                    string addInName;
                    while ((addInName = r.ReadLine()) != null) {
                        addInName = addInName.Trim();
                        if (addInName.Length == 0)
                            continue;
                        string targetDir = Path.Combine(userAddInPath, addInName);
                        if (!UninstallAddIn(disabled, addInName, targetDir)) {
                            notRemoved.Add(addInName);
                            allOK = false;
                        }
                    }
                }
                if (notRemoved.Count == 0) {
                    LoggingService.Info("Deleting remove.txt");
                    File.Delete(removeFile);
                } else {
                    LoggingService.Info("Rewriting remove.txt");
                    using (StreamWriter w = new StreamWriter(removeFile)) {
                        notRemoved.ForEach(w.WriteLine);
                    }
                }
            }
            foreach (string sourceDir in Directory.GetDirectories(addInInstallTemp)) {
                string addInName = Path.GetFileName(sourceDir);
                string targetDir = Path.Combine(userAddInPath, addInName);
                if (notRemoved.Contains(addInName)) {
                    LoggingService.Info("Skipping installation of " + addInName + " because deinstallation failed.");
                    continue;
                }
                if (UninstallAddIn(disabled, addInName, targetDir)) {
                    LoggingService.Info("Installing " + addInName + "...");
                    Directory.Move(sourceDir, targetDir);
                } else {
                    allOK = false;
                }
            }
            if (allOK) {
                try {
                    Directory.Delete(addInInstallTemp, false);
                } catch (Exception ex) {
                    LoggingService.Warn("Error removing install temp", ex);
                }
            }
            LoggingService.Info("AddInManager.InstallAddIns finished");
        }

Usage Example

Пример #1
0
 public void ConfigureUserAddIns(string addInInstallTemp, string userAddInPath)
 {
     AddInManager.AddInInstallTemp = addInInstallTemp;
     AddInManager.UserAddInPath    = userAddInPath;
     if (Directory.Exists(addInInstallTemp))
     {
         AddInManager.InstallAddIns(disabledAddIns);
     }
     if (Directory.Exists(userAddInPath))
     {
         AddAddInsFromDirectory(userAddInPath);
     }
 }
All Usage Examples Of ICSharpCode.Core.AddInManager::InstallAddIns