Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Setting up the ServiceLocator using configuration

The ServiceLocator in Catel can be set up from configuration file.

Importing IoC configuration section

...

Code Block
languagehtml/xml
<configuration>
  <configSections>
       <sectionGroup name="catel">
           <section name="ioc" type="Catel.IoC.IoCConfigurationSection, Catel.Core" />
       </sectionGroup>
   </configSections>
   ...
</configuration>

...

Note

In the example above we also create a section group named catel to group all Catel related configuration sections.

Configuring a service locator from the default configuration

It's possible add more than one service locator configuration to the configuration file but you must specify an unique name. If a name of a service locator configuration is not specified then the name default is assigned. By default such configuration supports dependency injection.

...