using Autofac.Features.AttributeFilters;
string Greetings { get; }
public class Hello : IHello
public class HelloConsumer
public HelloConsumer([KeyFilter("EN")] IHello hello)
Console.WriteLine(hello.Greetings);
public static void Main()
ContainerBuilder cb = new ContainerBuilder();
cb.RegisterType<HelloConsumer>().AsSelf().WithAttributeFiltering();
var helloEn = new Hello { Greetings = "Hi" };
var helloFr = new Hello { Greetings = "Bonjour" };
cb.Register<Hello>(x => helloEn).Keyed<IHello>("EN");
cb.Register<Hello>(x => helloFr).Keyed<IHello>("FR");
var container = cb.Build();
container.Resolve<HelloConsumer>();