Now dependencies can be packages

This commit is contained in:
The Doctor
2020-07-09 09:30:34 +01:00
parent ed9f4bcb43
commit 4703f6e078
4 changed files with 50 additions and 4 deletions

View File

@ -108,9 +108,35 @@ namespace PMF.Managers
// Maybe a library folder and check if is installed
foreach (var dependency in asset.Dependencies)
{
PMF.InvokePackageMessageEvent($"Extracting dependency with id: {dependency.ID}");
if (dependency.Type == DependencyType.Standalone)
{
PMF.InvokePackageMessageEvent($"Extracting dependency with id: {dependency.ID} of type standalone");
ZipFile.ExtractToDirectory(Path.Combine(zipPath, dependency.FileName), Path.Combine(Config.PackageInstallationFolder, remotePackage.ID, "Dependencies", dependency.ID));
}
else // DependencyType.Package
{
PMF.InvokePackageMessageEvent($"Downloading dependency with id: {dependency.ID} of type package");
var success = PackageManager.Install(dependency.ID, dependency.Version, out Package p);
if (success == PackageState.Installed)
{
PMF.InvokePackageMessageEvent($"Package dependency installed successfully");
}
else if (success == PackageState.VersionNotFound)
{
PMF.InvokePackageMessageEvent("Asset not found");
}
else if (success == PackageState.NotExisting)
{
PMF.InvokePackageMessageEvent("Package not found");
}
else
{
PMF.InvokePackageMessageEvent($"Something went wrong installing dependency with id: {dependency.ID}");
}
}
}
remotePackage.Assets.Clear();
remotePackage.Assets.Add(asset);

View File

@ -82,7 +82,7 @@ namespace PMF.Managers
/// <param name="id">The id of the package</param>
/// <param name="version">The version of the asset</param>
/// <param name="package">The package that was installed</param>
/// <returns>true Installation successful, false already installed</returns>
/// <returns>Final package state of installation</returns>
public static PackageState Install(string id, Version version, out Package package)
{
package = null;

View File

@ -1,4 +1,6 @@
namespace PMF
using System;
namespace PMF
{
/// <summary>
/// Files that an asset depends on
@ -15,6 +17,16 @@
/// </summary>
public string Checksum { get; set; }
/// <summary>
/// Type of dependency
/// </summary>
public DependencyType Type { get; set; }
/// <summary>
/// Version of the dependency if type is Package
/// </summary>
public Version Version { get; set; }
/// <summary>
/// The file name of the dependecy
/// </summary>

View File

@ -0,0 +1,8 @@
namespace PMF
{
public enum DependencyType
{
Package,
Standalone
}
}