Exemplo n.º 1
0
        public void Uninstall(string packageName, string installedPath)
        {
            var lists = InstalledPackages.Deserialize(installedPath);

            if (lists.Packages.Keys.Contains(packageName))
            {
                //
                // Get the info of the package which will be uninstalled.
                //
                var info = PackageInfo.LoadInfo(packageName);

                LogTracer.Log("[INFO] Uninstall Started");

                //
                // Uninstall it.
                //
                var installedUri = new Uri(installedPath);
                DoUninstall(info, installedUri);

                LogTracer.Log("[INFO] Uninstall finished");

                //
                // Save changes.
                //
                lists.Packages.Remove(packageName);
                lists.Serialize(installedPath);
            }
            else
            {
                LogTracer.LogError($"[ERROR] The package, {packageName} is not installed there but tried to uninstall it.");
            }
        }
Exemplo n.º 2
0
        public void Install(string packageName, string installTo)
        {
            var lists = InstalledPackages.Deserialize(installTo);

            if (lists.Packages.Keys.Contains(packageName))
            {
                LogTracer.Log($"[WARNING] The package, {packageName} is already installed there.");
            }
            else
            {
                //
                // Get where the package are on.
                //
                var packagePath = Path.Combine(
                    Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData, Environment.SpecialFolderOption.DoNotVerify),
                    "PLPM",
                    $"{packageName}.plpmpkg"
                    );

                LogTracer.Log($"[INFO] Install started (Source: {packagePath})");

                if (File.Exists(packagePath))
                {
                    //
                    // Install files.
                    //
                    DoInstall(packagePath, installTo);

                    LogTracer.Log($"[INFO] Install Finished");

                    //
                    // Save changes.
                    //
                    var info = PackageInfo.LoadInfo(packageName);
                    lists.Packages.Add(packageName, info.Identification);
                    lists.Serialize(installTo);
                }
                else
                {
                    LogTracer.LogError($"[ERROR] a package ({packagePath}) is not found.");
                }
            }
        }
Exemplo n.º 3
0
        // ----- Static Contents -----

        public static InstalledPackages Deserialize(string dirPath)
        {
            var filePath = GetFileName(dirPath);

            if (File.Exists(filePath))
            {
                //
                // Deserialize from a json file.
                //
                var json = File.ReadAllText(filePath);
                var obj  = JsonConvert.DeserializeObject <InstalledPackages>(json);

                return(obj);
            }
            else
            {
                //
                // Create a new one.
                //
                var obj = new InstalledPackages();

                return(obj);
            }
        }