【发布时间】:2011-10-03 08:52:05
【问题描述】:
我想使用 spring .net 为静态类中的属性注入值。 代码sn-p:
Public static Abc
{
Public static IInterface IInterface{get;set;}
}
这里我想通过 spring .net 配置在 Abc staic 类中注入 IInterface 值。
【问题讨论】:
标签: c#-4.0 spring.net static-class
我想使用 spring .net 为静态类中的属性注入值。 代码sn-p:
Public static Abc
{
Public static IInterface IInterface{get;set;}
}
这里我想通过 spring .net 配置在 Abc staic 类中注入 IInterface 值。
【问题讨论】:
标签: c#-4.0 spring.net static-class
我怀疑你是否能做到。
静态类不能很好地与依赖注入一起工作。
最好将类创建为普通类并将其设置为容器中的单例。我很确定 spring.net 会允许这样做..
【讨论】: