I have an open generic interface, which i implement with a non generic class, and i want to inject this class using castle windsor, but am struggling.....
Lets say i have the following interface
public interface IMyInterface<T>
{
bool DoSomething(T param);
}
And then i have the following class that implements this interface like so
public class MyClass : IMyInterface<string>
{
public bool DoSomething(string param)
{
// Do Something
return true;
}
}
I want to be able to resolve the interface using castle like this, so that the injectedObject becomes an instance of MyClass.
WindsorContainer container = new WindsorContainer(new XmlInterpreter(newConfigResource("castle")));
IMyInterface<string> injectedObject = container.Resolve<IMyInterface<string>>();
Is this possible, or have i gone off track slightly? If its possible, how do i set up the castle config section? I have tried using the '1 notation to indicate that the interface is an open generic type, but you get an error if the implementation is not also generic, which in this case it is not.
Any help appreciated
container.Register(Component.For<IMyInterface<string>>().ImplementedBy<MyClass>())