From 77a609758bb80bac9497d2e3988550f8be578407 Mon Sep 17 00:00:00 2001 From: Rory& Date: Mon, 23 Feb 2026 02:03:20 +0100 Subject: Initial commit --- .../Patches/Implementations/PatchSet.cs | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 ReferenceClientProxyImplementation/Patches/Implementations/PatchSet.cs (limited to 'ReferenceClientProxyImplementation/Patches/Implementations/PatchSet.cs') diff --git a/ReferenceClientProxyImplementation/Patches/Implementations/PatchSet.cs b/ReferenceClientProxyImplementation/Patches/Implementations/PatchSet.cs new file mode 100644 index 0000000..c3dba59 --- /dev/null +++ b/ReferenceClientProxyImplementation/Patches/Implementations/PatchSet.cs @@ -0,0 +1,26 @@ +namespace ReferenceClientProxyImplementation.Patches.Implementations; + +public class PatchSet(IServiceProvider sp) { + public List Patches { get; } = sp.GetServices().OrderBy(x => x.GetOrder()).ToList(); + + public async Task ApplyPatches(string relativeName, byte[] content) { + var i = 0; + var patches = Patches + .Where(p => p.Applies(relativeName, content)) + .OrderBy(p => p.GetOrder()) + .ToList(); + foreach (var patch in patches) { + if (patch.Applies(relativeName, content)) { + var defaultColor = Console.ForegroundColor; + Console.ForegroundColor = ConsoleColor.DarkBlue; + Console.Write("==> "); + Console.ForegroundColor = ConsoleColor.DarkGray; + Console.WriteLine($"Running task {++i}/{patches.Count}: {patch.GetName()} (Type<{patch.GetType().Name}>)"); + Console.ForegroundColor = defaultColor; + content = await patch.Execute(relativeName, content); + } + } + + return content; + } +} \ No newline at end of file -- cgit 1.5.1