.net - 在 Windsor 配置文件中使用枚举作为参数

标签 .net castle-windsor

如何使用 Enum 指定的条目(例如下面的“EntryType”)预设 Windsor 配置文件参数?

我目前有这个:

<component
      id="test.service" service=".." type=".." lifestyle="transient">
      <parameters>
        <entryType>EntryType.Test</entryType>
      </parameters>
    </component>

其中 .. 显然代表了完整的命名空间和程序集。

但是收到这个错误:

Could not convert from 'EntryType.Test' to 
   Business.Common.Services.Core.TestService+EntryType.

最佳答案

这样写的,对我有用:

<component
  id="test.service" service=".." type=".." lifestyle="transient">
  <parameters>
    <entryType>Test</entryType><!-- NOT EntryType.Test -->
  </parameters>
</component>

关于.net - 在 Windsor 配置文件中使用枚举作为参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1629353/

相关文章:

inversion-of-control - 温莎容器 : How to specify a public property should not be filled by the container?

c# - CaSTLe Windsor 注册的类型不同于类型发现中使用的类型

c# - 具有流畅界面的 CaSTLe 拦截器

c# - 如何删除当前绑定(bind)到控件的工具提示?

c# - 扩展方法与助手类

c# - 为什么在传递 "null"常量时会出现异常,而在传递 "null"字符串引用时却不会?

.net - 运行面向 .NET 的 VC++ 应用程序是否需要 .NET 框架?

caSTLe-windsor - 基于基类注册类型

caSTLe-windsor - 类型 CaSTLe.Facilities.FactorySupport.FactorySupportFacility 未实现接口(interface) CaSTLe.MicroKernel.IFacility

c# - 有没有办法暂停所有 Threading.Timer 计时器?