Skip to content

Commit

Permalink
BROKERS: Add DependencyInjectionBroker
Browse files Browse the repository at this point in the history
  • Loading branch information
LBoullosa committed Jun 1, 2024
1 parent be2e998 commit bd49f12
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 0 deletions.
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);
}
}
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);
}
}
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();
}
}
}
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);
}
}
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);
}
}
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
{
}
}
1 change: 1 addition & 0 deletions STX.SPAL.Core/STX.SPAL.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Xeption" Version="2.6.0" />
</ItemGroup>

Expand Down

0 comments on commit bd49f12

Please sign in to comment.