diff --git a/IPA.Loader/Config/Config.cs b/IPA.Loader/Config/Config.cs
index 81517381..858ab476 100644
--- a/IPA.Loader/Config/Config.cs
+++ b/IPA.Loader/Config/Config.cs
@@ -25,10 +25,11 @@ namespace IPA.Config
}
///
- /// Specifies that a particular parameter is preferred to be a specific type of . If it is not available, also specifies backups. If none are available, the default is used.
+ /// Specifies that a particular parameter is preferred to use a particular .
+ /// If it is not available, also specifies backups. If none are available, the default is used.
///
[AttributeUsage(AttributeTargets.Parameter)]
- public class PreferAttribute : Attribute
+ public sealed class PreferAttribute : Attribute
{
///
/// The order of preference for the config type.
@@ -52,7 +53,7 @@ namespace IPA.Config
/// Specifies a preferred config name, instead of using the plugin's name.
///
[AttributeUsage(AttributeTargets.Parameter)]
- public class NameAttribute : Attribute
+ public sealed class NameAttribute : Attribute
{
///
/// The name to use for the config.
@@ -96,8 +97,6 @@ namespace IPA.Config
registeredProviders.Add(inst.Extension, inst);
}
- private static Dictionary files = new Dictionary();
-
///
/// Gets a object using the specified list of preferred config types.
///
@@ -109,12 +108,10 @@ namespace IPA.Config
var chosenExt = extensions.FirstOrDefault(s => registeredProviders.ContainsKey(s)) ?? "json";
var provider = registeredProviders[chosenExt];
- var config = new Config(configName, provider);
-
var filename = Path.Combine(BeatSaber.UserDataPath, configName + "." + provider.Extension);
- files.Add(config, new FileInfo(filename));
+ var config = new Config(configName, provider, new FileInfo(filename));
- RegisterConfigObject(config);
+ ConfigRuntime.RegisterConfig(config);
return config;
}
@@ -130,11 +127,6 @@ namespace IPA.Config
return GetConfigFor(modName, prefs);
}
- private static void RegisterConfigObject(Config obj)
- {
- // TODO: implement
- }
-
///
/// Gets the name associated with this object.
///
@@ -145,6 +137,7 @@ namespace IPA.Config
public IConfigProvider Provider { get; private set; }
internal readonly HashSet Stores = new HashSet();
+ internal readonly FileInfo File;
///
/// Adds an to this object.
@@ -154,9 +147,9 @@ namespace IPA.Config
/// otherwise
public bool AddStore(IConfigStore store) => Stores.Add(store);
- private Config(string name, IConfigProvider provider)
+ private Config(string name, IConfigProvider provider, FileInfo file)
{
- Name = name; Provider = provider;
+ Name = name; Provider = provider; File = file;
}
}
}
diff --git a/IPA.Loader/Config/ConfigRuntime.cs b/IPA.Loader/Config/ConfigRuntime.cs
new file mode 100644
index 00000000..05b596c3
--- /dev/null
+++ b/IPA.Loader/Config/ConfigRuntime.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.Concurrent;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Threading;
+
+namespace IPA.Config
+{
+ internal static class ConfigRuntime
+ {
+ private static readonly ConcurrentBag configs = new ConcurrentBag();
+ private static readonly AutoResetEvent memoryChangedWatcher = new AutoResetEvent(false);
+
+ public static void RegisterConfig(Config cfg)
+ {
+ configs.Add(cfg);
+
+ // TODO: register file watcher, reset changed watcher
+ }
+
+ }
+}
diff --git a/IPA.Loader/IPA.Loader.csproj b/IPA.Loader/IPA.Loader.csproj
index cde1c398..a73ed13e 100644
--- a/IPA.Loader/IPA.Loader.csproj
+++ b/IPA.Loader/IPA.Loader.csproj
@@ -85,6 +85,7 @@
+
@@ -144,7 +145,7 @@
-
+
@@ -179,8 +180,6 @@
-
-
-
+
\ No newline at end of file
diff --git a/IPA.Loader/Utilities/Synchronization.cs b/IPA.Loader/Utilities/Async/Synchronization.cs
similarity index 100%
rename from IPA.Loader/Utilities/Synchronization.cs
rename to IPA.Loader/Utilities/Async/Synchronization.cs