From 6dea261a77ecdc8cac201b1dd81ad4308525e6fa Mon Sep 17 00:00:00 2001 From: Octal Date: Wed, 6 Dec 2023 20:18:14 -0600 Subject: [PATCH] Add SaveSerializable class - to be expanded upon later --- Common/Serialization/SaveSerializable.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Common/Serialization/SaveSerializable.cs diff --git a/Common/Serialization/SaveSerializable.cs b/Common/Serialization/SaveSerializable.cs new file mode 100644 index 0000000..92cda13 --- /dev/null +++ b/Common/Serialization/SaveSerializable.cs @@ -0,0 +1,13 @@ +using PeterO.Cbor; + +namespace Common.Serialization; + +public abstract class SaveSerializable { + public abstract void Load(T data); + public abstract T Save(); + + public CBORObject SaveToCbor() + => CBORObject.FromObject(Save()); + public void LoadFromCbor(CBORObject data) + => Load(data.ToObject()); +}