如何设置需要依赖动态字符串的Windsor组件? [英] How to setup Windsor component that needs to depend on a dynamic string?

查看:74
本文介绍了如何设置需要依赖动态字符串的Windsor组件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Castle Windsor组件,该组件取决于字符串。需要在运行时基于另一个字符串确定该字符串,该字符串是常量,可以在组件配置中设置。如何使用温莎城堡将其连接起来?

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 ?

问题很普遍,但我需要的特定情况是一个类,该类在构造函数中具有文件的完整路径,但是由于我正在运行ASP。 NET应用程序,在写入配置文件时,我只知道文件的虚拟(相对)路径。

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.

推荐答案

此处无其他答案有一会儿。作为参考,我创建了温莎城堡设施来处理相对路径。它通过注册ISubDependencyResolver来工作,该ISubDependencyResolver会检查配置中依赖项上的特殊属性,如果找到,则调用自定义路径逻辑。 我在这里写了有关详细信息的博客

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.

这篇关于如何设置需要依赖动态字符串的Windsor组件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆