2023-02-08 23:53:42 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace SharpChat.Config {
|
|
|
|
|
public interface IConfig : IDisposable {
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Creates a proxy object that forces all names to start with the given prefix.
|
|
|
|
|
/// </summary>
|
|
|
|
|
IConfig ScopeTo(string prefix);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Reads a raw (string) value from the config.
|
|
|
|
|
/// </summary>
|
2024-05-10 19:18:55 +00:00
|
|
|
|
string? ReadValue(string name, string? fallback = null);
|
2023-02-08 23:53:42 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Reads and casts value from the config.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <exception cref="ConfigTypeException">Type conversion failed.</exception>
|
2024-05-10 19:18:55 +00:00
|
|
|
|
T? ReadValue<T>(string name, T? fallback = default);
|
2023-02-08 23:53:42 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Reads and casts a value from the config. Returns fallback when type conversion fails.
|
|
|
|
|
/// </summary>
|
2024-05-10 19:18:55 +00:00
|
|
|
|
T? SafeReadValue<T>(string name, T fallback);
|
2023-02-08 23:53:42 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Creates an object that caches the read value for a certain amount of time, avoiding disk reads for frequently used non-static values.
|
|
|
|
|
/// </summary>
|
2024-05-10 19:18:55 +00:00
|
|
|
|
CachedValue<T> ReadCached<T>(string name, T? fallback = default, TimeSpan? lifetime = null);
|
2023-02-08 23:53:42 +00:00
|
|
|
|
}
|
|
|
|
|
}
|