-
Notifications
You must be signed in to change notification settings - Fork 649
Improve service collection and dependency injection access #7571
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
Improve service collection and dependency injection access #7571
Conversation
8bd37c7 to
e2998d4
Compare
| /// Transport implementations can use this property to determine whether they can resolve dependencies from the service provider during initialization. | ||
| /// </remarks> | ||
| [MemberNotNullWhen(true, nameof(ServiceProvider))] | ||
| public bool SupportsDependencyInjection => ServiceProvider is not null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realized now we have effectively more modes we are supporting and I decided to split the property. During hosted scenarios that transport supports DI because Core will take care of calling ConfigureServices and set the provider on the host settings. During raw modes you might still have a need to access DI and then you don't necessarily have to set the CoreSettings. You might only call ConfigureServices and provide the service provider.
One thing that I don't particularly like is that a transport might not use the services but still the SupportsDependencyInjection is set to true which is slightly awkward, but I guess there is really no clean way to express that without breaking a lot of things.
|
|
||
| public override Task<TransportInfrastructure> Initialize(HostSettings hostSettings, ReceiveSettings[] receivers, string[] sendingAddresses, CancellationToken cancellationToken = default) | ||
| { | ||
| if (hostSettings.SupportsDependencyInjection) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we also need a test that verifies IsHosted?
Plus technically do we need a raw transport seam test too? If yes where would we put it?
* Expose the service provider on the transport seam * Move up and improve documentation * Remove using * Improve service collection and dependency injection access (#7571) * Improve service collection and dependency injection access * IsRawMode --------- Co-authored-by: Daniel Marbach <danielmarbach@users.noreply.github.com> * Remove no longer needed assert --------- Co-authored-by: Daniel Marbach <danielmarbach@users.noreply.github.com> Co-authored-by: Daniel Marbach <daniel.marbach@openplace.net>
No description provided.