How to setup Windsor component that needs to depend on a dynamic string?

无人久伴 提交于 2019-12-11 08:37:47

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!