1 files changed, 26 insertions, 0 deletions
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<IPatch> Patches { get; } = sp.GetServices<IPatch>().OrderBy(x => x.GetOrder()).ToList();
+
+ public async Task<byte[]> 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
|