-
Notifications
You must be signed in to change notification settings - Fork 1
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 #17 from The-Standard-Organization/users/lboullosa…
…/brokers-dependency-injection BROKERS: Add DependencyInjectionBroker #9
- Loading branch information
Showing
7 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
STX.SPAL.Core/Brokers/DependenciesInjection/DependencyInjectionBroker.ServiceCollection.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,15 @@ | ||
// ---------------------------------------------------------------------------------- | ||
// Copyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers | ||
// ---------------------------------------------------------------------------------- | ||
|
||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.DependencyInjection.Extensions; | ||
|
||
namespace STX.SPAL.Core.Brokers.DependenciesInjection | ||
{ | ||
internal partial class DependencyInjectionBroker | ||
{ | ||
public void RegisterServiceDescriptor(ServiceDescriptor serviceDescriptor) => | ||
serviceColllection.Add(serviceDescriptor); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
STX.SPAL.Core/Brokers/DependenciesInjection/DependencyInjectionBroker.ServiceProvider.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,21 @@ | ||
// ---------------------------------------------------------------------------------- | ||
// Copyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers | ||
// ---------------------------------------------------------------------------------- | ||
|
||
using System; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace STX.SPAL.Core.Brokers.DependenciesInjection | ||
{ | ||
internal partial class DependencyInjectionBroker | ||
{ | ||
public IServiceProvider BuildServiceProvider() => | ||
serviceColllection.BuildServiceProvider(); | ||
|
||
public T ResolveImplementation<T>(ServiceProvider serviceProvider) => | ||
serviceProvider.GetRequiredService<T>(); | ||
|
||
T ResolveImplementation<T>(ServiceProvider serviceProvider, string spalId) => | ||
serviceProvider.GetRequiredKeyedService<T>(spalId); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
STX.SPAL.Core/Brokers/DependenciesInjection/DependencyInjectionBroker.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 @@ | ||
// ---------------------------------------------------------------------------------- | ||
// Copyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers | ||
// ---------------------------------------------------------------------------------- | ||
|
||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace STX.SPAL.Core.Brokers.DependenciesInjection | ||
{ | ||
internal partial class DependencyInjectionBroker : IDependencyInjectionBroker | ||
{ | ||
private readonly ServiceCollection serviceColllection; | ||
|
||
public DependencyInjectionBroker() | ||
{ | ||
serviceColllection = new ServiceCollection(); | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
STX.SPAL.Core/Brokers/DependenciesInjection/IDependencyInjectionBroker.ServiceCollection.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,13 @@ | ||
// ---------------------------------------------------------------------------------- | ||
// Copyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers | ||
// ---------------------------------------------------------------------------------- | ||
|
||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace STX.SPAL.Core.Brokers.DependenciesInjection | ||
{ | ||
internal partial interface IDependencyInjection | ||
{ | ||
void RegisterServiceDescriptor(ServiceDescriptor serviceDescriptor); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
STX.SPAL.Core/Brokers/DependenciesInjection/IDependencyInjectionBroker.ServiceProvider.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,16 @@ | ||
// ---------------------------------------------------------------------------------- | ||
// Copyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers | ||
// ---------------------------------------------------------------------------------- | ||
|
||
using System; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace STX.SPAL.Core.Brokers.DependenciesInjection | ||
{ | ||
internal partial interface IDependencyInjection | ||
{ | ||
IServiceProvider BuildServiceProvider(); | ||
T ResolveImplementation<T>(ServiceProvider serviceProvider); | ||
T ResolveImplementation<T>(ServiceProvider serviceProvider, string spalId); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
STX.SPAL.Core/Brokers/DependenciesInjection/IDependencyInjectionBroker.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,10 @@ | ||
// ---------------------------------------------------------------------------------- | ||
// Copyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers | ||
// ---------------------------------------------------------------------------------- | ||
|
||
namespace STX.SPAL.Core.Brokers.DependenciesInjection | ||
{ | ||
internal partial interface IDependencyInjectionBroker | ||
{ | ||
} | ||
} |
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