concept IIngredient in category .net

This is an excerpt from Manning's book Dependency Injection in .NET.
This registers the SauceBéarnaise class with the container but provides no mapping. Even though SauceBéarnaise implements IIngredient, the container will throw an exception if you ask it to resolve IIngredient:
In this example, you map the IIngredient interface to the concrete Sauce-Béarnaise class, which allows you to successfully resolve IIngredient:
var container = new UnityContainer(); container.RegisterType<IIngredient, SauceBéarnaise>(); IIngredient ingredient = container.Resolve<IIngredient>();The generic RegisterType method is one of several extension methods that all invoke a weakly typed RegisterType method defined on IUnityContainer. In the previous example, you use an overload where you define the ABSTRACTION as well as the concrete type as two generic type arguments. Here you map from IIngredient to SauceBéarnaise so that when you subsequently resolve IIngredient, you get a Sauce-Béarnaise instance.
The generic RegisterType extension method helps prevent configuration mistakes because the destination type has a generic constraint that states that it must derive from the source type. The previous example code compiles because Sauce-Béarnaise implements IIngredient.
Unlike Castle Windsor or Autofac, mapping IIngredient to SauceBéarnaise like the previous example doesn’t preclude you from resolving SauceBéarnaise itself. Both sauce and ingredient will be appropriately resolved here:
container.RegisterType<IIngredient, SauceBéarnaise>(); var sauce = container.Resolve<SauceBéarnaise>(); var ingredient = container.Resolve<IIngredient>();As you may recall from the discussion in sections 10.1.2 and 13.1.2, mapping IIngredient to SauceBéarnaise with Castle Windsor or Autofac causes the concrete class (Sauce-Béarnaise) to “disappear,” unless you take extra steps. This isn’t necessary with Unity, where you can resolve both IIngredient and SauceBéarnaise. In both cases, the returned objects are SauceBéarnaise instances.