다른 lifetimes (Transient, Singleton) 에도 Keyed services 를 등록할 수 있습니다.
이제 [FromKeyedServices] 속성을 사용하여 키별로 특정 구현을 확인할 수 있습니다.
생성자에서 구현하는 방법은 아래와 같습니다.
// Note:// I am using Primary Constructor which is new with .NET 8.0// You can use the other constructor as wellpublicclassMyClass([FromKeyedServices("service1")] IMyService myService)
{
publicstringGetValue() => myService.GetValue();
}