Split out the Flashii interaction code into a separate library.

This commit is contained in:
flash 2025-04-26 19:42:23 +00:00
commit 2eba089a21
Signed by: flash
GPG key ID: 2C9C2C574D47FE3E
55 changed files with 769 additions and 552 deletions

View file

@ -0,0 +1,34 @@
namespace SharpChat.Configuration {
public class ScopedConfig(Config config, string prefix) : Config {
private Config Config { get; } = config ?? throw new ArgumentNullException(nameof(config));
private string Prefix { get; } = prefix ?? throw new ArgumentNullException(nameof(prefix));
private string GetName(string name) {
return Prefix + name;
}
public string? ReadValue(string name, string? fallback = null) {
return Config.ReadValue(GetName(name), fallback);
}
public T? ReadValue<T>(string name, T? fallback = default) {
return Config.ReadValue(GetName(name), fallback);
}
public T? SafeReadValue<T>(string name, T? fallback) {
return Config.SafeReadValue(GetName(name), fallback);
}
public Config ScopeTo(string prefix) {
return Config.ScopeTo(GetName(prefix));
}
public CachedValue<T> ReadCached<T>(string name, T? fallback = default, TimeSpan? lifetime = null) {
return Config.ReadCached(GetName(name), fallback, lifetime);
}
public void Dispose() {
GC.SuppressFinalize(this);
}
}
}