I'd like to create several similar services which can be destinguished and accessed by their names (=keys).
For the service implementation I want to use classes with c'tor dependencies like this:
public interface IXYService
{
string Tag { get; set; }
}
public class _1stXYService : IXYService
{
public _1stXYService(string Tag)
{
this.Tag = Tag;
}
public string Tag { get; set; }
}
What I tried was to use 'AddComponentWithProperties' to have a concrete instance created which is accessible via a given key:
...
IDictionary l_xyServiceInitParameters = new Hashtable { { "Tag", "1" } };
l_container.AddComponentWithProperties
(
"1st XY service",
typeof(IXYService),
typeof(_1stXYService),
l_xyServiceInitParameters
);
l_xyServiceInitParameters["Tag"] = "2";
l_container.AddComponentWithProperties
(
"2nd XY service",
typeof(IXYService),
typeof(_1stXYService),
l_xyServiceInitParameters
);
...
var service = l_container[serviceName] as IXYService;
However, the dependencies were not resolved and hence the services are not available.
Using IWindsorContainer.Resolve(...) to populate the parameters is not desired.
Construction by XML works, but is not in all cases sufficient.
How could I achieve my goals?