我熟悉尼尼姆,但不熟悉Spring.Net。我正在试图确定在Spring.net中是否存在与“Spring.net”相当的“”。允许基于约定的映射的东西。例如,一些允许我定义如下规则的东西:
谢谢
发布于 2011-04-20 15:43:24
不,Spring.NET几乎没有代码作为配置,所以自动注册是完全不可用的.
发布于 2011-06-28 00:13:45
Spring.net使用一种不同的方法,它们有依赖于属性的CodeConfig,基本上您可以在类中设置一些属性,以便DI容器知道需要注入哪些类。您可以找到更多的信息,这里
对我来说,配置IOC的最好方法是使用xml文件,因为您可以控制应用程序的行为,而无需编译任何东西,即使在生产环境中也是如此。
发布于 2012-12-31 00:58:09
还有一个使用Spring.AutoRegistration的选项。统一AutoRegistration中使用的相同概念。
http://rafaelnaskar.blogspot.com.br/2012/12/springautoregistration-fluent.html
https://www.nuget.org/packages/Spring.AutoRegistration
var context = new GenericApplicationContext();
context.Configure()
.IncludeAssembly(x => x.FullName.StartsWith("Company.ApplicationXPTO"))
.Include(x => x.ImplementsITypeName(), Then.Register().UsingSingleton()
.InjectByProperty(If.DecoratedWith<InjectAttribute>))
.ApplyAutoRegistration();
var context = new GenericApplicationContext();
context.Configure()
.Include(If.DecoratedWith<NamedAttribute>,Then.Register().UsingSingleton().InjectByProperty(If.DecoratedWith<InjectAttribute>))
.Include(If.Implements<IController>,
Then.Register().UsingPrototype().InjectByProperty(If.DecoratedWith<InjectAttribute>))
.ApplyAutoRegistration();
var context = new GenericApplicationContext();
context.Configure()
.IncludeAssembly(x => x.FullName.StartsWith("Spring.AutoRegistration.Test"))
.Include(x => x.GetInterfaces().Length > 0,
Then.Register().WithNamedAttributeIfExists().UsingPrototype()
.InjectByProperty(If.DecoratedWith<InjectAttribute>))
.ApplyAutoRegistration();https://stackoverflow.com/questions/5732742
复制相似问题