public class ServiceLocatorImplementer : IMethodReplacer
{
private readonly Type _forType;
public ServiceLocatorImplementer(Type forType)
{
this._forType = forType;
}
protected IEnumerable GetAllImplementers()
{
var idObjects = Spring.Context.Support.ContextRegistry.GetContext()
.GetObjectsOfType(_forType);
return idObjects.Values;
}
public object Implement(object target, MethodInfo method, object[] arguments)
{
return GetAllImplementers();
}
}
declare it with this configuration sample
and finally inject to the required target
What is trully great with this methodology is that the underlying GetObjectsOfType is not going to be called until you actually execute GetAllICheImplentations() (unless you try to execute it during spring init which is not going to bode well)