Unity Child Container Lifetime with WCF

We use Unity to provide dependency injection at the WCF service level for our current project, and we ran the following examples to write the factory service host, service host, service behavior, and instance provider:

http://avingtonsolutions.com/blog/post/2008/08/02/Uisng-Unity-with-a-WCF-Service.aspx

The solution works very successfully, but we need to provide contextual resolution of objects on the basis of a request. So far, we have implemented this by creating a child container in the GetInstance method of the instance provider, adding contextual registrations to the child container and using the child container to perform the service type resolution. Some registrations in both containers use container-managed lifetimes.

Since I do not know the lifetime of the child container, I have concerns about this methodology: 1) Does the container-child container go out of scope at the end of the GetInstance method and, therefore, are deleted, which leads to some of our objects being deleted. allowed by the container are located in the middle of our request?

2). Alternatively, does the parent container support the child container for a period of time, meaning that it will quickly fill up with instances of child containers in a high-traffic environment?

Can someone point me in the right direction?

+3
source share

Source: https://habr.com/ru/post/1753329/


All Articles