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

use TryAddSigleton to prevent service override in clients #18

Conversation

followynne
Copy link
Member

Hi 😄
This PR would like to review the IMongoClient Singleton Registration.

When a client uses the MongoDB provider, probably the IMongoClient it's already registered as a singleton (as recommended by the official SDK docs).
By using TryAddSingleton, serilog-ui will register the class only if the client didn't already do it.
It won't override anymore a custom IMongoClient singleton implementation added before AddSerilogUi(...) in ConfigureServices.

Let me know if there's anything unclear or wrong with this change!

@followynne followynne marked this pull request as ready for review January 1, 2022 23:05
@mo-esmp mo-esmp merged commit 8ade21e into serilog-contrib:master Jan 2, 2022
@followynne followynne deleted the hotfix/mongodb-client-registration branch January 7, 2022 18:01
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

Successfully merging this pull request may close these issues.

None yet

2 participants