Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure Autofac so that it's ExternallyOwned for default, and "InternallyOwned" for separate services #1407

Closed
WindingWinter opened this issue Jan 22, 2024 · 1 comment

Comments

@WindingWinter
Copy link

Currently how Autofac works is that for the IDisposable type service, Autofac container will manage the disposing, unless it is being set as ExternallyOwned. Autofac does this by placing it on the Disposal queue and call the service when the container is being disposed. This will create a strong reference to the service until the container is disposed.

While I can see the merit of this design, for my use case I would prefer the inversion of it, namely, I want to configure that for default, the IDisposable services that are owned by Autofac are ExternallyOwned ( I'm responsible for calling the Dispose method), and only for a handful of services are "InternallyOwned" ( and I would have to mark them explicitly as such), meaning that for these services, Autofac will be responsible for calling the Dispose method.

Is it possible to do have this API? Or this is already doable in the current Autofac engine?

@tillig
Copy link
Member

tillig commented Jan 22, 2024

Duplicate #481, #998. This isn't something the Autofac team is going to add. See the referenced issues for more info.

@tillig tillig closed this as completed Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants