From ab1e43219279fa6d7f01aad39366a5d35ad44b5a Mon Sep 17 00:00:00 2001 From: Meivyn <793322+Meivyn@users.noreply.github.com> Date: Fri, 31 May 2024 21:01:30 -0400 Subject: [PATCH] Expose a helper to toggle config watchers --- IPA.Loader/Config/ConfigRuntime.cs | 5 +++++ IPA.Loader/Config/ConfigWatchersHelper.cs | 13 +++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 IPA.Loader/Config/ConfigWatchersHelper.cs diff --git a/IPA.Loader/Config/ConfigRuntime.cs b/IPA.Loader/Config/ConfigRuntime.cs index 40173293..323df7bf 100644 --- a/IPA.Loader/Config/ConfigRuntime.cs +++ b/IPA.Loader/Config/ConfigRuntime.cs @@ -145,6 +145,11 @@ namespace IPA.Config watcher.EnableRaisingEvents = true; } + internal static FileSystemWatcher[] GetWatchers() + { + return watcherTrackConfigs.Keys.ToArray(); + } + private static void EnsureWritesSane(Config config) { // compare exchange loop to be sane diff --git a/IPA.Loader/Config/ConfigWatchersHelper.cs b/IPA.Loader/Config/ConfigWatchersHelper.cs new file mode 100644 index 00000000..e55b1d2c --- /dev/null +++ b/IPA.Loader/Config/ConfigWatchersHelper.cs @@ -0,0 +1,13 @@ +namespace IPA.Config +{ + public static class ConfigWatchersHelper + { + public static void ToggleWatchers() + { + foreach (var watcher in ConfigRuntime.GetWatchers()) + { + watcher.EnableRaisingEvents = !watcher.EnableRaisingEvents; + } + } + } +}