From what I noticed, they do pretty much the same thing, provide services in form of IoC/DI. However, IAmbientServices has a member of type ICompositionContext. I don't really get the difference between the two of them and why are they aggregated this way?
What is the difference between AmbientServices and CompositionContext in Kephas?
45 views Asked by Auguste Leroi At
1
The concise answer is: the
ambient servicescontain services registered before the IoC/DI/composition container is built, while thecomposition contextis the root container for the IoC/DI, and itself is a service registered into theambient services.As a side note, all the services registered in the
ambient servicesare later registered automatically also in the DI container, includingIAmbientServices, so they are available for composition, too.Examples for ambient services:
As a general rule of thumb, prefer using services registered in the DI container, you will need very rarely ambient services.