-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #250 from MarioAndron/master
Enhanced to allow scoped dependencies to be injected into steps
- Loading branch information
Showing
8 changed files
with
354 additions
and
44 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace WorkflowCore.Interface | ||
{ | ||
/// <remarks> | ||
/// The implemention of this interface will be responsible for | ||
/// providing a new service scope for a DI container | ||
/// </remarks> | ||
public interface IScopeProvider | ||
{ | ||
/// <summary> | ||
/// Create a new service scope | ||
/// </summary> | ||
/// <returns></returns> | ||
IServiceScope CreateScope(); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using Microsoft.Extensions.DependencyInjection; | ||
using System; | ||
using WorkflowCore.Interface; | ||
|
||
namespace WorkflowCore.Services | ||
{ | ||
/// <summary> | ||
/// A concrete implementation for the IScopeProvider interface | ||
/// Largely to get around the problems of unit testing an extension method (CreateScope()) | ||
/// </summary> | ||
public class ScopeProvider : IScopeProvider | ||
{ | ||
private readonly IServiceProvider provider; | ||
|
||
public ScopeProvider(IServiceProvider provider) | ||
{ | ||
this.provider = provider; | ||
} | ||
|
||
public IServiceScope CreateScope() | ||
{ | ||
return provider.CreateScope(); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.