58 references to IOptionsContext
Microsoft.Extensions.Options.Contextual (20)
ContextualOptionsServiceCollectionExtensions.cs (6)
45Func<IOptionsContext, CancellationToken, ValueTask<IConfigureContextualOptions<TOptions>>> loadOptions) 60Func<IOptionsContext, CancellationToken, ValueTask<IConfigureContextualOptions<TOptions>>> loadOptions) 77public static IServiceCollection Configure<TOptions>(this IServiceCollection services, Action<IOptionsContext, TOptions> configure) 91public static IServiceCollection Configure<TOptions>(this IServiceCollection services, string? name, Action<IOptionsContext, TOptions> configure) 112Func<IOptionsContext, CancellationToken, ValueTask<IConfigureContextualOptions<TOptions>>> loadOptions) 123public static IServiceCollection ConfigureAll<TOptions>(this IServiceCollection services, Action<IOptionsContext, TOptions> configure)
IContextualOptions.cs (1)
16where TContext : IOptionsContext
INamedContextualOptions.cs (1)
16where TContext : IOptionsContext
Internal\ConfigureContextualOptions.cs (4)
17private readonly IOptionsContext _context; 24public ConfigureContextualOptions(Action<IOptionsContext, TOptions> configureOptions, IOptionsContext context) 33public Action<IOptionsContext, TOptions> ConfigureOptions { get; }
Internal\ContextualOptions.cs (1)
17where TContext : notnull, IOptionsContext
Internal\ContextualOptionsFactory.cs (1)
53where TContext : notnull, IOptionsContext
Internal\IContextualOptionsFactory.cs (1)
25where TContext : IOptionsContext;
Internal\LoadContextualOptions.cs (3)
24public LoadContextualOptions(string? name, Func<IOptionsContext, CancellationToken, ValueTask<IConfigureContextualOptions<TOptions>>> load) 38public Func<IOptionsContext, CancellationToken, ValueTask<IConfigureContextualOptions<TOptions>>> LoadAction { get; } 42where TContext : notnull, IOptionsContext
OptionsContextAttribute.cs (1)
10/// Generates an implementation of <see cref="IOptionsContext"/> for the annotated type.
Provider\ILoadContextualOptions.cs (1)
25where TContext : IOptionsContext;
Microsoft.Extensions.Options.Contextual.Tests (29)
AcceptanceTests.cs (1)
99static void ConfigureTemperatureScaleBasedOnCountry(IOptionsContext context, WeatherForecastOptions options)
ContextualOptionsFactoryTests.cs (22)
29var result = await new ContextualOptions<List<string>, IOptionsContext>(sut).GetAsync(Mock.Of<IOptionsContext>(), default); 43await Assert.ThrowsAsync<OptionsValidationException>(async () => await sut.CreateAsync(string.Empty, Mock.Of<IOptionsContext>(), default)); 44await Assert.ThrowsAsync<OptionsValidationException>(async () => await sut.CreateAsync("A Name", Mock.Of<IOptionsContext>(), default)); 56await Assert.ThrowsAsync<OptionsValidationException>(async () => await sut.CreateAsync("Foo", Mock.Of<IOptionsContext>(), default)); 57Assert.Empty(await sut.CreateAsync("Bar", Mock.Of<IOptionsContext>(), default)); 76var result = await sut.CreateAsync(string.Empty, Mock.Of<IOptionsContext>(), default); 91var sut = new ContextualOptions<List<string>, IOptionsContext>(new ContextualOptionsFactory<List<string>>( 97Assert.Equal(new[] { "configure" }, await sut.GetAsync("Foo", Mock.Of<IOptionsContext>(), default)); 98Assert.Empty(await sut.GetAsync("Bar", Mock.Of<IOptionsContext>(), default)); 117Assert.Equal(new[] { "configure" }, await sut.CreateAsync("Foo", Mock.Of<IOptionsContext>(), default)); 118Assert.Equal(new[] { "configure" }, await sut.CreateAsync("Bar", Mock.Of<IOptionsContext>(), default)); 130Assert.Equal(new[] { "post configure" }, await sut.CreateAsync("Foo", Mock.Of<IOptionsContext>(), default)); 131Assert.Equal(new[] { "post configure" }, await sut.CreateAsync("Bar", Mock.Of<IOptionsContext>(), default)); 143Assert.Equal(new[] { "post configure" }, await sut.CreateAsync("Foo", Mock.Of<IOptionsContext>(), default)); 144Assert.Empty(await sut.CreateAsync("Bar", Mock.Of<IOptionsContext>(), default)); 156Assert.Empty(await sut.CreateAsync("Foo", Mock.Of<IOptionsContext>(), default)); 157Assert.Equal(new[] { "pre configure" }, await sut.CreateAsync(Options.DefaultName, Mock.Of<IOptionsContext>(), default)); 158Assert.Empty(await sut.CreateAsync("Bar", Mock.Of<IOptionsContext>(), default)); 200Assert.Equal(new[] { "1", "2", "3", "4" }, await sut.CreateAsync(string.Empty, Mock.Of<IOptionsContext>(), default)); 222var exception = await Assert.ThrowsAsync<AggregateException>(async () => await sut.CreateAsync(string.Empty, Mock.Of<IOptionsContext>(), default)); 247var exception = await Assert.ThrowsAsync<AggregateException>(async () => await sut.CreateAsync(string.Empty, Mock.Of<IOptionsContext>(), default));
ContextualOptionsServiceCollectionExtensionsTests.cs (6)
32Func<IOptionsContext, CancellationToken, ValueTask<IConfigureContextualOptions<string>>> loadOptions = 44Action<IOptionsContext, string> configureOptions = (_, _) => { }; 47Assert.Equal(configureOptions, ((ConfigureContextualOptions<string>)await loader.LoadAction(Mock.Of<IOptionsContext>(), default)).ConfigureOptions); 54Func<IOptionsContext, CancellationToken, ValueTask<IConfigureContextualOptions<string>>> loadOptions = 66Action<IOptionsContext, string> configureOptions = (_, _) => { }; 69Assert.Equal(configureOptions, ((ConfigureContextualOptions<string>)await loader.LoadAction(Mock.Of<IOptionsContext>(), default)).ConfigureOptions);
Microsoft.Gen.ContextualOptions.Generated.Tests (5)
ContextualOptionsTests.cs (5)
27((IOptionsContext)new Class1()).PopulateReceiver(receiver); 35((IOptionsContext)new Class2()).PopulateReceiver(receiver); 45((IOptionsContext)new Record1("PropertyValue")).PopulateReceiver(receiver); 53((IOptionsContext)default(Struct1)).PopulateReceiver(receiver); 61Assert.IsAssignableFrom<IOptionsContext>(default(NonPublicStruct));
Microsoft.Gen.ContextualOptions.Unit.Tests (4)
ContextualOptionsTests.cs (4)
27((IOptionsContext)new Class1()).PopulateReceiver(receiver); 35((IOptionsContext)new Class2()).PopulateReceiver(receiver); 45((IOptionsContext)new Record1("PropertyValue")).PopulateReceiver(receiver); 53((IOptionsContext)default(Struct1)).PopulateReceiver(receiver);