How do I configure a NULL object in Spring.Net

有些话、适合烂在心里 提交于 2019-12-07 20:19:25

问题


In the particular project in which I'm working it is appropriate to to have a null log service object. Since this is configured in Spring.Net How do I configure my spring.net object to be null. This is what I'd like to do. Is it possible?

<objects xmlns="http://www.springframework.net">
  <!-- Messages -->

  <object id ="LogService">
    <null />
  </object>

回答1:


You can inject a null object :

<object id="MyObject">
  <property name="LogServer">
    <null/>
  </property>
</object>

To create a null object, you have to implement IFactoryObject and return null. http://www.springframework.net/doc-latest/reference/html/objects.html#objects-factory-extension

  • Bruno


来源:https://stackoverflow.com/questions/5990325/how-do-i-configure-a-null-object-in-spring-net

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!