Hello,
Situation: I have an interface, such as
public interface ITestClass
{
string StringElement { get; }
}
There is an implementation for it:
public class TestClassImplementor :
ITestClass
{
public string StringElement
{
get { return "AAA"; }
}
}
I do have a factory that creates an implementation instance:
public class TestClassFactory
{
public ITestClass Create()
{
return new TestClassImplementor();
}
}
I want to be able to resolve the implementation using Castle Windsor configuration file (XML), but at the same time not configuring the implementation for the interface.
Why is this needed: resolving (web) services. I do have a (web) service interface, but I don't access the implementation, as it is on another component. I want to be able to simply type MyCastleUtility.Resolve<ITestClass>()
and get a prepared web service. I want to use Castle Windsor configuration file (XML) to configure the service I'm trying to access.
The problem: if I can't access the implementation, I can't configure it in the configuration file.
What I've tried so far: 1) Factories.
<component id="mycompfactory"
type="MyTestProject.TestClassFactory, MyTestProject"/>
<component id="mycomp"
type="MyTestProject.ITestClass, MyTestProject"
factoryId="mycompfactory" factoryCreate="Create" />
I do get the: Castle.MicroKernel.ComponentRegistrationException : Type MyTestProject.INewTestClass is abstract. As such, it is not possible to instansiate it as implementation of MyTestProject.INewTestClass service
2) Proxies. Hit the wall when tried to find a way to configure that "proxy must be created for 'ITestClass' interface".
Target: configure Castle Windsor to create interface implementation without directly accessing the class, that implements the interface.
Help is much appreciated, Mindaugas