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

How to register an IDisposable instance that should outlive the container? #595

Open
roy-t opened this issue Jun 15, 2024 · 0 comments
Open

Comments

@roy-t
Copy link

roy-t commented Jun 15, 2024

Short question that I couldn't find in the docs.

I have an instance of an object that implements IDisposable. Let's name it foo. When I use container.RegisterInstance<T>(foo) foo will, from then on, be owned by the container. When I call container.Dispose() foo will be disposed as well.

Is there a way to make sure foo outlives the container? Since it wasn't created by LightInject I also don't want LightInject to clean it up.

@roy-t roy-t changed the title How to register a IDisposable instance that should outlive the container? How to register an IDisposable instance that should outlive the container? Jun 15, 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

1 participant