1

My Spring.NET configuration is using the following type syntax and is working ok.

<object id="JohnUsingVariableSource"
    type="XmlConfig.StringInjection.Person, XmlConfig">
  <property name="Name" value="${JohnsFullName}" />
</object>  

Values for the ${JohnsFullName} placeholder are configured in the app.config file. My requirements have changed and I know need to get the name from the database at startup. How is it possible to overwrite the value in the app.config file ? Can I do it in code without opening the app.config (as here App.Config change value), does spring.NET have a way of doing this ?

Community
  • 1
  • 1
user815809
  • 351
  • 5
  • 24

1 Answers1

2

Yes, you can do that without modifying the app.config file. Simply implement a custom IVariableSource:

public interface IVariableSource
{
  string ResolveVariable(string name);
}

In the ResolveVariable method you read from the db.

The first variable source configured in your config will be the one used by the spring config, if I recall correctly.

Marijn
  • 10,367
  • 5
  • 59
  • 80