31 lines
964 B
C#
31 lines
964 B
C#
using ModpackUpdater.Apps.Manager.Api.Model;
|
|
using Pilz.Features;
|
|
|
|
namespace ModpackUpdater.Apps.Manager.Api.Plugins.Features;
|
|
|
|
public abstract class WorkspaceFeature(string identifier, string name) : PluginFeature(FeatureTypes.Workspace, identifier, name)
|
|
{
|
|
public virtual bool CanConfigure(IWorkspace workspace)
|
|
{
|
|
return workspace?.Config == null || workspace.Config.ProviderId == Identifier;
|
|
}
|
|
|
|
public virtual async Task Configure(WorkspaceContext context)
|
|
{
|
|
await OnConfigure(context);
|
|
|
|
if (context?.Workspace?.Config is not null)
|
|
context.Workspace.Config.ProviderId = Identifier;
|
|
}
|
|
|
|
public virtual IWorkspace CreateFromConfig(WorkspaceConfig config)
|
|
{
|
|
OnCreate(out var workspace, config);
|
|
return workspace;
|
|
}
|
|
|
|
protected abstract void OnCreate(out IWorkspace workspace, WorkspaceConfig config);
|
|
|
|
protected abstract Task OnConfigure(WorkspaceContext context);
|
|
}
|