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