DependencyInjection.Attributed icon indicating copy to clipboard operation
DependencyInjection.Attributed copied to clipboard

Add support for keyed service with multiple attributes

Open nuzolx opened this issue 1 year ago • 0 comments

Hi,

I'd like to be able to specify the attribute several times in the case of keyed service. Is this possible? At the moment, error ‘CS0579’ is being thrown.

public interface INotificationService
{
    string Notify(string message);
}

[Service<string>("sms")]
public class SmsNotificationService : INotificationService
{
    public string Notify(string message) => $"[SMS] {message}";
}

[Service<string>("email")]
[Service<string>("default")]
public class EmailNotificationService : INotificationService
{
    public string Notify(string message) => $"[Email] {message}";
}

Back this issue Back this issue

nuzolx avatar Apr 30 '24 14:04 nuzolx