Add ISaveContext

This commit is contained in:
miku-666
2025-02-01 11:46:52 +01:00
parent 9fcd7f802b
commit 27216f1410
2 changed files with 26 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
using System;
namespace PckStudio.Interfaces
{
public interface ISaveContext<T>
{
public bool AutoSave { get; }
public void Save(T value);
}
public sealed class DelegatedSaveContext<T> : ISaveContext<T>
{
private readonly Action<T> _saveAction;
public bool AutoSave { get; }
public void Save(T value) => _saveAction(value);
public DelegatedSaveContext(bool autoSave, Action<T> saveAction)
{
AutoSave = autoSave;
_saveAction = saveAction;
}
}
}

View File

@@ -154,6 +154,7 @@
<DependentUpon>ContributorsForm.cs</DependentUpon>
</Compile>
<Compile Include="Extensions\OpenTKExtensions.cs" />
<Compile Include="Interfaces\ISaveContext.cs" />
<Compile Include="Interfaces\ITryGetSet.cs" />
<Compile Include="Forms\Editor\ModelEditor.cs">
<SubType>Form</SubType>