C#, DI, IOC using Castle Windsor
- by humblecoder
Hi! Am working on a design of a project. I would like to move the implementation away hence to decouple am using interfaces.
interface IFoo {
void Bar();
void Baz();
}
The assemblies which implemented the above interface would be drop in some predefined location say "C:\Plugins" for eg:
project: A
class A : IFoo {
}
when compiled produces A.dll
project: B
class A : IFoo {
}
when compiled produced B.dll
Now I would like to provide a feature in my application to enable end use to configure the assembly to be loaded in the database.say C:\Plugins\A.dll or C:\Plugins\B.dll
How it can be achieved using Castle Windsor.
container.AddComponent("identifier",load assembly from specified location as configured in DB);
I would like to do something like this:
IFoo foo =container.Resolve("identifier");
foo.Bar(); //invoke method.
Any hint would be highly appreciated.
Thanks,
Hamed.