Domanda

In my dependency injection configuration file - I don't know (and can't find an example) on how to set into a member some predefined environment variable file.

Can't tell how to do it in Spring.Net - your help will be appreciated.

È stato utile?

Soluzione

Take a look to the VariablePlaceholderConfigurer object. It should do the job: http://www.springframework.net/doc-latest/reference/html/objects.html#objects-variablesource

<object type="Spring.Objects.Factory.Config.VariablePlaceholderConfigurer, Spring.Core">
   <property name="VariableSources">
      <list>
         <object type="Spring.Objects.Factory.Config.EnvironmentVariableSource, Spring.Core"/>
      </list>
   </property>
</object>

<object type="MyObject">
  <property name="MyProperty" value="${MyEnvironmentVariableName}"/>
</object>

Altri suggerimenti

Use an EnvironmentVariableSource, the current docs are somewhat lacking at the moment: http://springframework.net/docs/1.3.2/reference/html/objects.html#objects-variablesource. I've written some additional docs, they'll probably be included in the next 2.0 release of the build. In the meantime you can also check this example code on Github https://github.com/serra/spring-net-examples/tree/master/Spring.IoCQuickStart.VariableSources.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top