concept name component in category .net

appears as: named components, named components, A named component, named component
Dependency Injection in .NET

This is an excerpt from Manning's book Dependency Injection in .NET.

Given the named components in listing 10.5, you can resolve both Steak and SauceBéarnaise like this:

Steak remains the default IIngredient, but now you can also resolve IIngredient to SauceBéarnaise by requesting the named sauce IIngredient. You can use named components to fine-tune how DEPENDENCIES are wired; we’ll return to this subject in section 14.3.1.

Listing 14.11. Injecting named components into a sequence
container.RegisterType<IMeal, Meal>( new InjectionConstructor( new ResolvedArrayParameter<ICourse>( new ResolvedParameter<ICourse>("entrée"), new ResolvedParameter<ICourse>("mainCourse"), new ResolvedParameter<ICourse>("dessert"))));

To make a Cotoletta, you’d like to decorate a VealCutlet (another IIngredient) with the Breading class. Because you already know how to connect named components with constructor arguments, it should feel natural to do something similar with the following listing.