From 27216f141052a2d2a567f9e2f9586f7872b7b943 Mon Sep 17 00:00:00 2001 From: miku-666 <74728189+NessieHax@users.noreply.github.com> Date: Sat, 1 Feb 2025 11:46:52 +0100 Subject: [PATCH] Add ISaveContext --- PCK-Studio/Interfaces/ISaveContext.cs | 25 +++++++++++++++++++++++++ PCK-Studio/PckStudio.csproj | 1 + 2 files changed, 26 insertions(+) create mode 100644 PCK-Studio/Interfaces/ISaveContext.cs diff --git a/PCK-Studio/Interfaces/ISaveContext.cs b/PCK-Studio/Interfaces/ISaveContext.cs new file mode 100644 index 00000000..3abbddba --- /dev/null +++ b/PCK-Studio/Interfaces/ISaveContext.cs @@ -0,0 +1,25 @@ +using System; + +namespace PckStudio.Interfaces +{ + public interface ISaveContext + { + public bool AutoSave { get; } + + public void Save(T value); + } + + public sealed class DelegatedSaveContext : ISaveContext + { + private readonly Action _saveAction; + public bool AutoSave { get; } + + public void Save(T value) => _saveAction(value); + + public DelegatedSaveContext(bool autoSave, Action saveAction) + { + AutoSave = autoSave; + _saveAction = saveAction; + } + } +} \ No newline at end of file diff --git a/PCK-Studio/PckStudio.csproj b/PCK-Studio/PckStudio.csproj index 0aa9ac3a..fdd1122d 100644 --- a/PCK-Studio/PckStudio.csproj +++ b/PCK-Studio/PckStudio.csproj @@ -154,6 +154,7 @@ ContributorsForm.cs + Form