Skip to content

Add InvocationContext.GetHost extension method - #1221

Merged
jonsequitur merged 3 commits into
dotnet:mainfrom
fredrikhr:invocationcontext-gethost
Mar 27, 2021
Merged

Add InvocationContext.GetHost extension method#1221
jonsequitur merged 3 commits into
dotnet:mainfrom
fredrikhr:invocationcontext-gethost

Conversation

@fredrikhr

@fredrikhr fredrikhr commented Mar 11, 2021

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor

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

@fredrikhr

Copy link
Copy Markdown
Contributor Author

@jonsequitur Test added

@jonsequitur

Copy link
Copy Markdown
Contributor

@fredrikhr Could you rebase this onto main?

@fredrikhr

Copy link
Copy Markdown
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