You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
95 lines
3.0 KiB
95 lines
3.0 KiB
using StabilityMatrix.Core.Models.FileInterfaces; |
|
using StabilityMatrix.Core.Models.Progress; |
|
|
|
namespace StabilityMatrix.Core.Models.Packages.Extensions; |
|
|
|
/// <summary> |
|
/// Interface for a package extension manager. |
|
/// </summary> |
|
public interface IPackageExtensionManager |
|
{ |
|
/// <summary> |
|
/// Default manifests for this extension manager. |
|
/// </summary> |
|
IEnumerable<ExtensionManifest> DefaultManifests { get; } |
|
|
|
/// <summary> |
|
/// Get manifests given an installed package. |
|
/// By default returns <see cref="DefaultManifests"/>. |
|
/// </summary> |
|
IEnumerable<ExtensionManifest> GetManifests(InstalledPackage installedPackage) |
|
{ |
|
return DefaultManifests; |
|
} |
|
|
|
/// <summary> |
|
/// Get extensions from the provided manifest. |
|
/// </summary> |
|
Task<IEnumerable<PackageExtension>> GetManifestExtensionsAsync( |
|
ExtensionManifest manifest, |
|
CancellationToken cancellationToken = default |
|
); |
|
|
|
/// <summary> |
|
/// Get extensions from all provided manifests. |
|
/// </summary> |
|
async Task<IEnumerable<PackageExtension>> GetManifestExtensionsAsync( |
|
IEnumerable<ExtensionManifest> manifests, |
|
CancellationToken cancellationToken = default |
|
) |
|
{ |
|
var extensions = Enumerable.Empty<PackageExtension>(); |
|
|
|
foreach (var manifest in manifests) |
|
{ |
|
cancellationToken.ThrowIfCancellationRequested(); |
|
|
|
extensions = extensions.Concat( |
|
await GetManifestExtensionsAsync(manifest, cancellationToken).ConfigureAwait(false) |
|
); |
|
} |
|
|
|
return extensions; |
|
} |
|
|
|
/// <summary> |
|
/// Get all installed extensions for the provided package. |
|
/// </summary> |
|
Task<IEnumerable<InstalledPackageExtension>> GetInstalledExtensionsAsync( |
|
InstalledPackage installedPackage, |
|
CancellationToken cancellationToken = default |
|
); |
|
|
|
/// <summary> |
|
/// Install an extension to the provided package. |
|
/// </summary> |
|
Task InstallExtensionAsync( |
|
PackageExtension extension, |
|
InstalledPackage installedPackage, |
|
PackageExtensionVersion? version = null, |
|
IProgress<ProgressReport>? progress = null, |
|
CancellationToken cancellationToken = default |
|
); |
|
|
|
/// <summary> |
|
/// Update an installed extension to the provided version. |
|
/// If no version is provided, the latest version will be used. |
|
/// </summary> |
|
Task UpdateExtensionAsync( |
|
InstalledPackageExtension installedExtension, |
|
InstalledPackage installedPackage, |
|
PackageExtensionVersion? version = null, |
|
IProgress<ProgressReport>? progress = null, |
|
CancellationToken cancellationToken = default |
|
); |
|
|
|
/// <summary> |
|
/// Uninstall an installed extension. |
|
/// </summary> |
|
Task UninstallExtensionAsync( |
|
InstalledPackageExtension installedExtension, |
|
InstalledPackage installedPackage, |
|
IProgress<ProgressReport>? progress = null, |
|
CancellationToken cancellationToken = default |
|
); |
|
}
|
|
|