Reputation: 601
There is a typed factory:
public interface IDataProviderFactory
{
IDataProvider Create(ConfigurationItem configurationItem);
void Release(IDataProvider dataProvider);
}
There are several implementations of IDataProvider
There is a configuration class:
public class ConfigurationItem
{
public CalculatorsEnum CalculatorsEnum { get; set; }
public DataPriversEnum DataPriversEnum { get; set; }
}
When I am trying to call the factory's method Create, Windsor is trying to resolve the IDataProvider's dependencies, which is ICalculator.
Here I need the container to use the information from the original parameter so that to understand which version of the ICalculator to use.
Update
I would like to add some details:
Possible solutions:
Upvotes: 0
Views: 77
Reputation: 7274
Constructor parameters are only passed to the constructor of the top level service being resolved. This is by design.
The recommended solution would be to make a factory that resolves both ICalculator and IDataProvider. When resolving you would explicitly resolve ICalculator and then pass that into the factory function for IDataProvider.
See this question for further discussion.
Update
Yes every Resolve should have a matching Release, and this is true whether using factories or the container directly.
It would only be speculation to suggest what "the Windsor way" of addressing your particular scenario might be.
Windsor provides a number of different ways of specifying inline dependencies. See here for further details. Generally the methods outlined are preferable to using factories etc. because the resolving/releasing is managed by the container.
Upvotes: 1