35 lines
1000 B
C#
35 lines
1000 B
C#
using ModpackUpdater.Apps.Manager.Api.Model;
|
|
using Pilz.Plugins.Advanced;
|
|
|
|
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 bool Configure(ref IWorkspace? workspace)
|
|
{
|
|
OnConfigure(ref workspace);
|
|
|
|
if (workspace?.Config is null)
|
|
return false;
|
|
|
|
workspace.Config.ProviderId = Identifier;
|
|
|
|
return true;
|
|
}
|
|
|
|
public virtual IWorkspace CreateFromConfig(WorkspaceConfig config)
|
|
{
|
|
OnCreate(out var workspace, config);
|
|
return workspace;
|
|
}
|
|
|
|
protected abstract void OnCreate(out IWorkspace workspace, WorkspaceConfig config);
|
|
|
|
protected abstract bool OnConfigure(ref IWorkspace? workspace);
|
|
}
|