Suppose I have an interface for data extraction and its implementation:
interface IResourceProvider { string Get( Uri uri ); } class HttpResourceProvider : IResourceProvider { public string Get( Uri uri ) {
I can register this with Castle Windsor as follows:
container.Register ( Component.For<IResourceProvider>().ImplementedBy<HttpResourceProvider>() );
(Everything is fine).
If I then decided that I needed a caching implementation as follows:
class CachingResourceProvider : IResourceProvider { public CachingResourceProvider( IResourceProvider resourceProvider ) { _resourceProvider = resourceProvider; } public string Get( Uri uri ) {
How can I register these nested dependencies? , i.e. I want to say that IResourceProvider is implemented by CachingResourceProvider , except where in the constructor, where is it HttpResourceProvider .
source share