mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/PCK-Studio.git
synced 2026-07-12 18:18:35 +00:00
Add ISaveContext
This commit is contained in:
25
PCK-Studio/Interfaces/ISaveContext.cs
Normal file
25
PCK-Studio/Interfaces/ISaveContext.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user