Exemple #1
0
        private void UninstallPackage(IPackageInfo packageInfo, string uninstallPackagePath)
        {
            PackageFileList fileList = null;

            string tempFolder = uninstallPackagePath + ".extracted/";

            if (Directory.Exists(tempFolder))
            {
                Directory.Delete(tempFolder, true);
            }
            using (ZipFile zip = new ZipFile(uninstallPackagePath)) {
                foreach (ZipEntry entry in zip)
                {
                    entry.Extract(tempFolder, ExtractExistingFileAction.OverwriteSilently);
                }
            }

            using (FileStream stream = new FileStream(tempFolder + "FileList.xml", FileMode.Open, FileAccess.Read, FileShare.None)) {
                fileList = LoadPackageFileList(stream);
            }

            ExecuteUninstallation(tempFolder + packageInfo.FullID + ".dll", packageInfo, fileList);

            if (Directory.Exists(tempFolder))
            {
                Directory.Delete(tempFolder, true);
            }
        }
Exemple #2
0
        private PackageFileList LoadPackageFileList(Stream fileListStream)
        {
            PackageFileList fileList = new PackageFileList();

            using (XmlReader reader = XmlReader.Create(fileListStream)) {
                while (reader.Read())
                {
                    if (reader.IsStartElement())
                    {
                        switch (reader.Name)
                        {
                        case "File": {
                            PackageFileListItem item = new PackageFileListItem(this.packageListDirectory, reader.ReadString().TrimStart('\\'));
                            fileList.Add(item);
                        }
                        break;
                        }
                    }
                }
            }
            return(fileList);
        }
Exemple #3
0
        private void ExecuteUninstallation(string packagePath, IPackageInfo packageInfo, PackageFileList fileList)
        {
            PackageLoader loader = new PackageLoader();

            loader.LoadPackage(packagePath);
            loader.Package.Initialize(this);
            PackageUninstaller uninstaller = new PackageUninstaller(packageInfo, fileList);

            // Start installing the package
            loader.Package.Uninstall(uninstaller);
            // Uninstallation complete! Add this package to the installed packages list
            int removalCount = MarkPackageUninstalled(uninstaller.Package.FullID);

            if (removalCount > 0)
            {
                SaveInstalledPackageList();
            }
            loader.Unload();
        }