The System.Configuration namespace in the .Net framework provides a lot of functionality for caching and encrypting configuration. To take advantage of this functionality StructureMap offers an option to embed configuration directly into the App.config file (web.config for web development). Just add a section for StructureMap like this:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="StructureMap" type="StructureMap.Configuration.StructureMapConfigurationSection,StructureMap"/>
</configSections>
<StructureMap>
<!-- Put StructureMap configuration here -->
</StructureMap>
</configuration>
Then you need to explicitly tell ObjectFactory to use this configuration:
ObjectFactory.Initialize(x =>
{
// Tell StructureMap to look for configuration
// from the App.config file
// The default is false
x.PullConfigurationFromAppConfig = true;
& });
Posted
Sat, Oct 25 2008 9:13 PM
by
Jeremy D. Miller