33 instantiations of FromKeyedServicesAttribute
BasicWebSite (7)
Controllers\CustomServiceApiController.cs (7)
13public ActionResult<string> GetOk([FromKeyedServices("ok_service")] ICustomService service) 19public ActionResult<string> GetNotOk([FromKeyedServices("not_ok_service")] ICustomService service) 26[FromKeyedServices("ok_service")] ICustomService s1, 27[FromKeyedServices("not_ok_service")] ICustomService s2) 33public ActionResult<string> GetKeyNull([FromKeyedServices(null)] ICustomService service) 41public ActionResult<string> GetOptionalNotRegistered([FromKeyedServices("no_existing_key")] ICustomService? service) 51public ActionResult<string> GetRequiredNotRegistered([FromKeyedServices("no_existing_key")] ICustomService service)
Microsoft.AspNetCore.Http.Abstractions.Tests (2)
UseMiddlewareTest.cs (2)
415public Task Invoke(HttpContext context, [FromKeyedServices("test")] IKeyedServiceProvider provider) => Task.CompletedTask; 420public MiddlewareKeyedConstructorInjectInvoke(RequestDelegate next, [FromKeyedServices("test")] IKeyedServiceProvider provider) { }
Microsoft.AspNetCore.Mvc.Abstractions.Test (2)
ModelBinding\BindingInfoTest.cs (2)
298new FromKeyedServicesAttribute(key), 319new FromKeyedServicesAttribute(new object()),
Microsoft.AspNetCore.Mvc.ApiExplorer.Test (2)
DefaultApiDescriptionProviderTest.cs (1)
2478private void AcceptsFormatters_Services([FromServices] ITestService tempDataProvider, [FromKeyedServices("foo")] ITestService keyedTempDataProvider)
EndpointMetadataApiDescriptionProviderTest.cs (1)
583Assert.Empty(GetApiDescription(([FromKeyedServices("foo")] InferredServiceClass foo) => { }).ParameterDescriptions);
Microsoft.AspNetCore.OpenApi.Tests (1)
Services\OpenApiGeneratorTests.cs (1)
417Assert.Empty(GetOpenApiOperation(([FromKeyedServices("foo")] int foo) => { }).Parameters);
Microsoft.AspNetCore.SignalR.Tests (8)
HubConnectionHandlerTestUtils\Hubs.cs (8)
1411public int MultipleSameKeyedServices([FromKeyedServices("service1")] Service1 service, [FromKeyedServices("service1")] Service1 service2) 1417public int KeyedService([FromKeyedServices("service1")] Service1 service) 1422public int KeyedServiceWithParam(int input, [FromKeyedServices("service1")] Service1 service) 1427public int KeyedServiceNonKeyedService(Service2 service2, [FromKeyedServices("service1")] Service1 service) 1432public int MultipleKeyedServices([FromKeyedServices("service1")] Service1 service, [FromKeyedServices("service2")] Service1 service2) 1441public void BadMethod([FromKeyedServices("service1")] [FromService] Service1 service)
ProxylessEndToEnd.ApiService (1)
Program.cs (1)
20app.MapGet("/redis", ([FromKeyedServices("redis")] IConnectionMultiplexer redis) =>
Redis.ApiService (6)
Program.cs (6)
31app.MapGet("/garnet/ping", async ([FromKeyedServices("garnet")] IConnectionMultiplexer connection) => 36app.MapGet("/garnet/set", async ([FromKeyedServices("garnet")] IConnectionMultiplexer connection) => 41app.MapGet("/garnet/get", async ([FromKeyedServices("garnet")] IConnectionMultiplexer connection) => 47app.MapGet("/valkey/ping", async ([FromKeyedServices("valkey")] IConnectionMultiplexer connection) => 52app.MapGet("/valkey/set", async ([FromKeyedServices("valkey")] IConnectionMultiplexer connection) => 57app.MapGet("/valkey/get", async ([FromKeyedServices("valkey")] IConnectionMultiplexer connection) =>
TestProject.IntegrationServiceA (1)
Redis\RedisExtensions.cs (1)
13private static async Task<IResult> VerifyRedisAsync([FromKeyedServices("redis")] IConnectionMultiplexer cm)
WebPubSubWeb (3)
Program.cs (3)
34app.MapGet("/negotiate/chat", ([FromKeyedServices(Constants.ChatHubName)] WebPubSubServiceClient service) => 43app.MapGet("/negotiate/notification", ([FromKeyedServices(Constants.NotificationHubName)] WebPubSubServiceClient service) => 53app.Map($"/eventhandler/{Constants.ChatHubName}", async ([FromKeyedServices(Constants.ChatHubName)] WebPubSubServiceClient service, HttpContext context, ILogger logger) => {
24 references to FromKeyedServicesAttribute
Microsoft.AspNetCore.Http.Abstractions (1)
Extensions\UseMiddlewareExtensions.cs (1)
241key = parameterInfo.GetCustomAttribute<FromKeyedServicesAttribute>(false)?.Key;
Microsoft.AspNetCore.Http.Extensions (4)
RequestDelegateFactory.cs (4)
798if (parameterCustomAttributes.OfType<FromKeyedServicesAttribute>().FirstOrDefault() is not null) 801$"The {nameof(FromKeyedServicesAttribute)} is not supported on parameters that are also annotated with {nameof(IFromServiceMetadata)}."); 806else if (parameterCustomAttributes.OfType<FromKeyedServicesAttribute>().FirstOrDefault() is { } keyedServicesAttribute) 810throw new InvalidOperationException($"Unable to resolve service referenced by {nameof(FromKeyedServicesAttribute)}. The service provider doesn't support keyed services.");
Microsoft.AspNetCore.Http.Extensions.Tests (1)
RequestDelegateGenerator\RequestDelegateCreationTests.KeyServices.cs (1)
51Assert.Equal($"The {nameof(FromKeyedServicesAttribute)} is not supported on parameters that are also annotated with {nameof(IFromServiceMetadata)}.", exception.Message);
Microsoft.AspNetCore.Mvc.Abstractions (2)
ModelBinding\BindingInfo.cs (2)
180if (attributes.OfType<FromKeyedServicesAttribute>().FirstOrDefault() is { } fromKeyedServicesAttribute) 185$"The {nameof(FromKeyedServicesAttribute)} is not supported on parameters that are also annotated with {nameof(IBindingSourceMetadata)}.");
Microsoft.AspNetCore.Mvc.ApiExplorer (1)
EndpointMetadataApiDescriptionProvider.cs (1)
277else if (parameter.ParameterInfo.CustomAttributes.Any(a => typeof(IFromServiceMetadata).IsAssignableFrom(a.AttributeType) || typeof(FromKeyedServicesAttribute) == a.AttributeType) ||
Microsoft.AspNetCore.OpenApi (1)
Services\OpenApiGenerator.cs (1)
429else if (parameter.CustomAttributes.Any(a => typeof(IFromServiceMetadata).IsAssignableFrom(a.AttributeType) || typeof(FromKeyedServicesAttribute) == a.AttributeType) ||
Microsoft.AspNetCore.SignalR.Core (3)
Internal\HubMethodDescriptor.cs (3)
91else if (attribute is FromKeyedServicesAttribute keyedServicesAttribute) 111throw new InvalidOperationException($"Unable to resolve service referenced by {nameof(FromKeyedServicesAttribute)}. The service provider doesn't support keyed services."); 120$"{methodExecutor.MethodInfo.DeclaringType?.Name}.{methodExecutor.MethodInfo.Name}: The {nameof(FromKeyedServicesAttribute)} is not supported on parameters that are also annotated with {nameof(IFromServiceMetadata)}.");
Microsoft.Extensions.DependencyInjection (1)
ServiceLookup\CallSiteFactory.cs (1)
591if (attribute is FromKeyedServicesAttribute keyed)
Microsoft.Extensions.DependencyInjection.Abstractions (10)
ActivatorUtilities.cs (9)
416var keyAttribute = (FromKeyedServicesAttribute?)Attribute.GetCustomAttribute(constructorParameter, typeof(FromKeyedServicesAttribute), inherit: false); 531FromKeyedServicesAttribute? attr = (FromKeyedServicesAttribute?) 532Attribute.GetCustomAttribute(constructorParameter, typeof(FromKeyedServicesAttribute), inherit: false); 748FromKeyedServicesAttribute? attr = (FromKeyedServicesAttribute?) 749Attribute.GetCustomAttribute(Parameters[i], typeof(FromKeyedServicesAttribute), inherit: false);
FromKeyedServicesAttribute.cs (1)
15/// Creates a new <see cref="FromKeyedServicesAttribute"/> instance.