container.GetAllInstances?, :
var address = new List<string>();
foreach (var provider in container.GetAllInstances<IAddressProvider>())
{
address.add(provider.GetAddress(lat, long));
}
Edit:
I understand what you mean now. If you are using StructureMap 2.x, I would recommend looking at the offer Conditionally. However, this was removed in version 3 in favor of creating our own builder class, which should be responsible for returning the correct instance.
For instance:
public class AddressProviderBuilder : IInstanceBuilder
{
private readonly IContainer container;
public AddressProviderBuilder(IContainer container)
{
this.container = container;
}
public IAddressProvider Build()
{
foreach (var provider in this.container.GetAllInstances<IAddressProvider>())
{
if (provider.GetAddress(lat, long) != null)
{
return provider;
}
}
return null;
}
}
source
share