Part I. Introduction

In this reference document, we’ll explore the newest addition to the configuration story for the Spring.NET Dependency Injection container: code-based configuration, or simply CodeConfig, intended to begin to address many of the shortcomings of the XML-based configuration approach.

At the core of Spring.NET is a powerful and flexible dependency injection container, offering object assembly and construction services atop which the remainder of the Spring.NET Framework is based. Historically, the primary manner of configuring this dependency injection container has been XML configuration files. Object definitions, essentially recipes to be used by the container when constructing objects of various types, are expressed in XML and then parsed and interpreted by the container as it is initialized at run-time.

While there are several positive aspects to expressing configuration metadata in XML files, there are also many problems with this approach including the verbosity of XML and its heavy dependence on string-literals which are both prone to typing errors and unusually resistant to most modern refactoring tools in use today. The CodeConfig approach removes these problems by providing a type safe, code-based, approach to dependency injection. It keeps the configuration metadatda external to your class so your class can be a POCO, free of any DI related annotations.