How to change configs in Spring.Net

后端 未结 2 1808
野的像风
野的像风 2021-01-20 05:02

An advantage of an IoC container is that you can swap in a mock service at the bottom of your object graph. However this seems much harder to do in Spring.Net than in other

2条回答
  •  孤城傲影
    2021-01-20 05:41

    That's a bit apples and oranges comparison as the unit test uses code configuration for Unity and XML (app.config) configuration for Spring.NET.

    If you go the XML route, then you can either comment out old implementation A and define the B implementation as the one to use - that what's configuration is all about right? Other option is to have dedicated XML files for each scenario (configuration setup) and include them via context's resource definitions (you have inline resource now). Other options include file system and assembly, see the web configuration section in Spring.NET's manual for a nice example.

    If you go the code configuration route I would suggest to check Spring.NET Recoil and upcoming CodeConfig.

提交回复
热议问题