This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies.
ObjectBuilder is a framework for creating dependency injection systems It is largely used in the Web Client Software Factory and in related projects, such as Enterprise Library.
A Composite Web Application Block application consists of loosely coupled components. The components, though independent, collaborate during the execution of a Web client solution. To support component independence, a component must be able to use another component without requiring a change to the source code of the component to be used. To support this, the Composite Web Application Block uses dependency injection to create component object instances. When you examine the source code for a Composite Web Application Block application, you will notice that the application does not create instances of another component by directly constructing an object (using new). Instead, the source code for a Composite Web Application Block application contains attributes such as CreateNew and ServiceDependency.
These attributes support the injection of objects at run time. The Composite Web Application Block uses ObjectBuilder to create and inject instances of objects of the appropriate type into the application at run time. ObjectBuilder uses the factory pattern to create object instances. It supports a general purpose, attribute-based dependency injection. The attributes determine the type of object that the ObjectBuilder factory creates.
|Note: ObjectBuilder itself is not a dependency injection system. It is a more general purpose and extensible pipeline that allows you to customize how an object is created.|
ObjectBuilder is a low-level utility that, in most cases, you will not directly interact with in your applications. The classes in the application blocks use it to generate object instances when your code creates the classes declared in the application blocks. However, you can use the features of ObjectBuilder directly in your applications and your own frameworks if you want. You can also influence the behavior of ObjectBuilder by creating your own strategies or modifying the existing strategies. The Web Client Software Factory includes a customized version of ObjectBuilder that helps implement the Composite Web Application Block requirements. Figure 1 shows the ObjectBuilder extensions included in the Composite Web Application Block.
|Note: ObjectBuilder is a patterns & practices application block, but because of its highly specific audience and its recent inception, it is not yet fully documented as a stand-alone asset like the Enterprise Library application blocks are. The following sections do not completely describe ObjectBuilder. Instead, they describe the aspects of ObjectBuilder that affect the Web Client Software Factory.|