问题
I have a Castle Windsor component, that depends on a string. The string needs to be determined at runtime, based on another string, which is constant and can be set in the component configuration. How do I wire this up using Castle Windsor ?
The problem is general, but the specific scenario I need it for is a class that takes the full path to file in a constructor, but since I am running a ASP .NET app, I only know the virtual (relative) path of the file when writing the configuration file.
回答1:
No other answers here for quite a while. For reference, I created a Castle Windsor Facility to handle relative paths. It works by registering an ISubDependencyResolver, that examines the configuration for a special attribute on the dependency, and if found, invokes the custom path logic. I blogged about the details here.
来源:https://stackoverflow.com/questions/1520849/how-to-setup-windsor-component-that-needs-to-depend-on-a-dynamic-string