From c6e0b7cbdc837ba7dfbc8dac939ba6423d3c0099 Mon Sep 17 00:00:00 2001 From: miku-666 <74728189+NessieHax@users.noreply.github.com> Date: Sat, 30 Jul 2022 21:45:28 +0200 Subject: [PATCH] Add convenient functions to PCKProperties --- .../Classes/FileTypes/PCKProperties.cs | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/MinecraftUSkinEditor/Classes/FileTypes/PCKProperties.cs b/MinecraftUSkinEditor/Classes/FileTypes/PCKProperties.cs index d76af14d..7f8aa1b8 100644 --- a/MinecraftUSkinEditor/Classes/FileTypes/PCKProperties.cs +++ b/MinecraftUSkinEditor/Classes/FileTypes/PCKProperties.cs @@ -8,5 +8,25 @@ namespace PckStudio.Classes.FileTypes { public class PCKProperties : List> // class because `using` is file scoped :| { + public bool HasProperty(string property) + { + return GetProperty(property) != default; + } + + public ValueTuple GetProperty(string property) + { + return this.FirstOrDefault(p => p.Item1.Equals(property)); + } + + public void SetProperty(string property, string value) + { + if (HasProperty(property)) + { + this[IndexOf(GetProperty(property))] = (property, value); + return; + } + Add((property, value)); + } + } }