I just had a fun emergency - the crew decided to redirect all configuration sources using environment variables, and while Log4Net supports this quite easily, the spring.net context resource-from-a-URI abstraction does not. E.g., this will not work:
<spring>
<context>
<resource uri="file://%PROGRAMFILES%/myapp/ioc.config" />
</context>
...
Knowing that spring.net can leverage custom resource implementations, I set out to extend the file system resource to expand environment variables. Turns out to be easy-peasy-lemon-squeezie:
public class ExpandableFileSystemResource : Spring.Core.IO.FileSystemResource
{
public ExpandableFileSystemResource()
: base()
{
}
public ExpandableFileSystemResource( string resourceName )
: base( Environment.ExpandEnvironmentVariables( resourceName ?? String.Empty ) )
{
}
public ExpandableFileSystemResource( string resourceName, bool suppressInitialize )
: base( Environment.ExpandEnvironmentVariables( resourceName ?? String.Empty ), suppressInitialize )
{
}
}
Register the resource implementation via config:
<spring>
<resourceHandlers>
<handler protocol="filex" type="MyApp.ExpandableFileSystemResource, MyApp"/>
</resourceHandlers>
<context>
<resource uri="filex://%PROGRAMFILES%/myapp/ioc.config" />
</context>
...
And it just works. Enjoy!