• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

loresoft / HashGate / 29701161024

19 Jul 2026 05:55PM UTC coverage: 65.982%. First build
29701161024

push

github

pwelter34
Add AddHmacClient and runtime options updates

235 of 472 branches covered (49.79%)

Branch coverage included in aggregate %.

146 of 173 new or added lines in 11 files covered. (84.39%)

696 of 939 relevant lines covered (74.12%)

26.54 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

81.82
/src/HashGate.HttpClient/OptionsServiceCollectionExtensions.cs
1
using HashGate.HttpClient.Options;
2

3
using Microsoft.Extensions.DependencyInjection;
4
using Microsoft.Extensions.DependencyInjection.Extensions;
5
using Microsoft.Extensions.Options;
6

7
namespace HashGate.HttpClient;
8

9
/// <summary>
10
/// Provides extension methods for registering the <see cref="OptionsUpdater{TOptions}"/> infrastructure
11
/// that enables imperative, in-process updates to named options instances.
12
/// </summary>
13
internal static class OptionsServiceCollectionExtensions
14
{
15
    /// <summary>
16
    /// Registers the services required to apply runtime updates to the specified named
17
    /// <typeparamref name="TOptions"/> instance via <see cref="OptionsUpdater{TOptions}"/>.
18
    /// </summary>
19
    /// <typeparam name="TOptions">The type of options to enable runtime updates for.</typeparam>
20
    /// <param name="services">The <see cref="IServiceCollection"/> to add the services to.</param>
21
    /// <param name="name">
22
    /// The name of the options instance to enable updates for, or <see cref="Microsoft.Extensions.Options.Options.DefaultName"/> for the default instance.
23
    /// </param>
24
    /// <returns>The <see cref="IServiceCollection"/> so that additional calls can be chained.</returns>
25
    /// <exception cref="ArgumentNullException">Thrown when <paramref name="services"/> is <c>null</c>.</exception>
26
    /// <remarks>
27
    /// <para>
28
    /// This method wires up three cooperating pieces of the options system:
29
    /// </para>
30
    /// <list type="bullet">
31
    ///   <item><description>A singleton <see cref="OptionsUpdater{TOptions}"/> that stores runtime mutations and invalidates the cache.</description></item>
32
    ///   <item><description>An <see cref="IPostConfigureOptions{TOptions}"/> (<see cref="OptionsUpdaterConfigure{TOptions}"/>) that reapplies stored mutations when instances are rebuilt, running after all configure and user post-configure delegates.</description></item>
33
    ///   <item><description>An <see cref="IOptionsChangeTokenSource{TOptions}"/> for <paramref name="name"/>, resolved from the same updater instance, so <see cref="IOptionsMonitor{TOptions}"/> subscribers are notified of changes.</description></item>
34
    /// </list>
35
    /// <para>
36
    /// The singleton and configure registrations are idempotent, so this method can be called multiple times safely.
37
    /// A distinct change token source is registered per named options instance.
38
    /// </para>
39
    /// </remarks>
40
    public static IServiceCollection AddOptionsUpdater<TOptions>(this IServiceCollection services, string name)
41
        where TOptions : class
42
    {
43
        if (services is null)
26!
NEW
44
            throw new ArgumentNullException(nameof(services));
×
45

46
        services.TryAddSingleton<OptionsUpdater<TOptions>>();
26✔
47

48
        var descriptor = ServiceDescriptor.Singleton<IPostConfigureOptions<TOptions>, OptionsUpdaterConfigure<TOptions>>();
26✔
49
        services.TryAddEnumerable(descriptor);
26✔
50

51
        services.AddSingleton<IOptionsChangeTokenSource<TOptions>>(sp =>
26✔
52
            sp.GetRequiredService<OptionsUpdater<TOptions>>().Source(name)
15✔
53
        );
26✔
54

55
        return services;
26✔
56
    }
57
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc