diff options
| author | JP Dillingham <jpdillingham@gmail.com> | 2021-07-16 08:06:36 -0500 |
|---|---|---|
| committer | JP Dillingham <jpdillingham@gmail.com> | 2021-07-16 08:06:36 -0500 |
| commit | 975c74f41a9af878220e962bb4216598186cdf52 (patch) | |
| tree | f01108216871eb0a9f616a59bc6531889c49b44e /src | |
| parent | 104200c46fe8ee66cc48cf61aead4dad2813e8b3 (diff) | |
| download | slskd-975c74f41a9af878220e962bb4216598186cdf52.tar.gz | |
add OptionsAtStartup
Diffstat (limited to 'src')
| -rw-r--r-- | src/slskd/Options.cs | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/slskd/Options.cs b/src/slskd/Options.cs index ca979dc9..f93e5d4a 100644 --- a/src/slskd/Options.cs +++ b/src/slskd/Options.cs @@ -15,6 +15,8 @@ // along with this program. If not, see https://www.gnu.org/licenses/. // </copyright> +using Microsoft.Extensions.Options; + namespace slskd { using System; @@ -30,6 +32,18 @@ namespace slskd using Utility.EnvironmentVariables; /// <summary> + /// Disambiguates options derived at startup from options that may update at run time. + /// </summary> + /// <remarks> + /// This class is added directly to dependency injection, but <see cref="Options"/> is not, so consumers must inject <see cref="OptionsAtStartup"/> + /// instead of <see cref="Options"/> to make it clear that these options will not change. Options that may change should be accessed by injecting + /// <see cref="IOptionsMonitor{T}"/> or <see cref="IOptionsSnapshot{T}"/>, depending on the lifetime of the component. + /// </remarks> + public class OptionsAtStartup : Options + { + } + + /// <summary> /// Application options. /// </summary> /// <remarks> @@ -56,10 +70,10 @@ namespace slskd /// </para> /// <para> /// Only the YAML configuration source can change at runtime and consumers of this class must be aware of this, either injecting - /// <see cref="IOptionsMonitor"/> in components with a singleton lifetime, or <see cref="IOptionsSnapshot"/> for transient or scoped lifetimes. + /// <see cref="IOptionsMonitor{T}"/> in components with a singleton lifetime, or <see cref="IOptionsSnapshot{T}"/> for transient or scoped lifetimes. /// </para> /// <para> - /// To obtain the Options specified at startup (discarding any updates that may have been applied since), inject <see cref="Options"/>. + /// To obtain the Options specified at startup (discarding any updates that may have been applied since), inject <see cref="OptionsAtStartup"/>. /// </para> /// <para> /// Options specified via the command line can not be overwritten by changes to the YAML file. This is by design due to the immutable |
