FromKeyedServicesAttribute
Indicates that the parameter should be bound using the keyed service registered with the specified key.
using System;
using System.Runtime.CompilerServices;
namespace Microsoft.Extensions.DependencyInjection
{
[System.Runtime.CompilerServices.NullableContext(2)]
[System.Runtime.CompilerServices.Nullable(0)]
[AttributeUsage(AttributeTargets.Parameter)]
public class FromKeyedServicesAttribute : Attribute
{
public object Key { get; }
public ServiceKeyLookupMode LookupMode { get; }
public FromKeyedServicesAttribute(object key)
{
Key = key;
LookupMode = ((key == null) ? ServiceKeyLookupMode.NullKey : ServiceKeyLookupMode.ExplicitKey);
}
public FromKeyedServicesAttribute()
{
Key = null;
LookupMode = ServiceKeyLookupMode.InheritKey;
}
}
}