This repository has been archived by the owner on Dec 19, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 311
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a scoped service provider for the call to Configure (#1106)
* Create a scoped service provider for the call to Configure - This allows scoped dependencies to be injected into the Configure method. It means you can resolve the DbContext or any other scoped service without the hassle of the CreateScope boiler plate. As a side effect, it also makes Startup.Configure a bit more testable.
- Loading branch information
Showing
5 changed files
with
82 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
test/Microsoft.AspNetCore.Hosting.Tests/Fakes/StartupWithScopedServices.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using Microsoft.AspNetCore.Builder; | ||
using static Microsoft.AspNetCore.Hosting.Tests.StartupManagerTests; | ||
|
||
namespace Microsoft.AspNetCore.Hosting.Fakes | ||
{ | ||
public class StartupWithScopedServices | ||
{ | ||
public DisposableService DisposableService { get; set; } | ||
|
||
public void Configure(IApplicationBuilder builder, DisposableService disposable) | ||
{ | ||
DisposableService = disposable; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters