I have an interface with multiple classes implementation. I have registered them in Autofac Container. My question how I can resolve for a specific class?
Interface
public interface IAccountDataStorage
{
Account GetAccount(string accountNumber);
void UpdateAccount(Account account);
}
Implemented classes
public class BackupAccountDataStore : IAccountDataStorage
{
...
}
public class AccountDataStore : IAccountDataStorage
{
...
}
Register in container
THIS DOES NOT WORK!
builder.RegisterType<AccountDataStore>().As<IAccountDataStorage>().InstancePerRequest();
builder.RegisterType<BackupAccountDataStore>().As<IAccountDataStorage>().InstancePerRequest();
Now I want to resolve to a specific class
// this does not work for me as it will pick itself one of the
// above class.. need help here
var paymentService = buildContainer.Resolve<IPaymentService>();