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

Add InvocationContext.GetHost extension method #1221

Merged
merged 3 commits into from
Mar 27, 2021

Conversation

fredrikhr
Copy link
Contributor

@fredrikhr fredrikhr commented Mar 11, 2021

Adds an extension method GetHost to InvocationContext, so that Command-line Middleware that runs after a call to UseHost() can access the created IHost instance easily.

It does technically not depend on using UseHost() since it simply news up a ModelBinder<IHost> and passes the Invocation BindingContext to it. Therefore, anyone adding IHost to the BindingContext service provider will be able to use this extension to access their IHost.

fixes #974

ref.: #974 (comment)

@jonsequitur
Copy link
Contributor

Could you add a test that illustrates and verifies the use case?

@fredrikhr
Copy link
Contributor Author

@jonsequitur Test added

@jonsequitur
Copy link
Contributor

@fredrikhr Could you rebase this onto main?

@fredrikhr
Copy link
Contributor Author

@jonsequitur done, ready for merge

@jonsequitur jonsequitur merged commit c76213f into dotnet:main Mar 27, 2021
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.

Provide access to IHost.Services inside 'UseMiddleware' method.
2 participants