From 894458eaa695a44eed02e5c50190326428337cda Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Thu, 29 Jan 2026 08:03:27 -0600 Subject: docs and stuff --- .../VolatileOverlayConfigurationSource.cs | 56 ++++++++++++++++++++-- 1 file changed, 51 insertions(+), 5 deletions(-) (limited to 'src/slskd/Common/Configuration/VolatileOverlayConfigurationSource.cs') diff --git a/src/slskd/Common/Configuration/VolatileOverlayConfigurationSource.cs b/src/slskd/Common/Configuration/VolatileOverlayConfigurationSource.cs index 9ae9c9ef..8707fe69 100644 --- a/src/slskd/Common/Configuration/VolatileOverlayConfigurationSource.cs +++ b/src/slskd/Common/Configuration/VolatileOverlayConfigurationSource.cs @@ -24,27 +24,44 @@ namespace slskd.Configuration using Microsoft.Extensions.Configuration; /// - /// A runtime patch . + /// A that provides a volatile, run-time overlay that supersedes other configuration + /// sources. /// + /// + /// To use this provider as intended, the application must instantiate and store an instance of either + /// or , and then invoke with the desired overlay object. + /// + /// The Type of the overlay. public class VolatileOverlayConfigurationProvider : ConfigurationProvider { + /// + /// Initializes a new instance of the class. + /// public VolatileOverlayConfigurationProvider() { TargetType = typeof(T); Namespace = TargetType.Namespace.Split('.').First(); } - private T Current { get; set; } + /// + /// Gets the current overlay value. + /// + public T CurrentValue { get; private set; } + private string Namespace { get; set; } private Type TargetType { get; set; } + /// + /// Loads values from the overlay. + /// public override void Load() { - if (Current is null) + if (CurrentValue is null) { return; } + // note: pretty much the same as DefaultValueConfigurationProvider; the two should be updated in lockstep void Map(Type type, string path, object instance) { var props = type.GetProperties(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); @@ -82,28 +99,57 @@ namespace slskd.Configuration } } - Map(TargetType, Namespace, Current); + Map(TargetType, Namespace, CurrentValue); } + /// + /// Applies the goven . + /// + /// An object containing the values to overlay. public void Apply(T overlay) { - Current = overlay; + CurrentValue = overlay; Load(); OnReload(); } } + /// + /// Represents values that are provided at run-time as an . + /// + /// + /// To use this provider as intended, the application must instantiate and store an instance of either + /// or , and then invoke with the desired overlay object. + /// + /// The Type of the overlay. public class VolatileOverlayConfigurationSource : IConfigurationSource { + /// + /// Initializes a new instance of the class. + /// public VolatileOverlayConfigurationSource() { Provider = new VolatileOverlayConfigurationProvider(); } + /// + /// Gets the current overlay value. + /// + public T CurrentValue => Provider.CurrentValue; + private VolatileOverlayConfigurationProvider Provider { get; set; } + /// + /// Applies the given to the underlying . + /// + /// An object containing the values to overlay. public void Apply(T overlay) => Provider.Apply(overlay); + /// + /// Builds the for this source. + /// + /// The . + /// A . public IConfigurationProvider Build(IConfigurationBuilder builder) { return Provider; -- cgit v1.2.3