Skip to content

Commit

Permalink
DESIGN: POC Implementation v2.
Browse files Browse the repository at this point in the history
ServiceProvider instantiation when registering with no DI.
Adds AbstractionProvider.
#10
  • Loading branch information
LBoullosa committed Feb 21, 2024
1 parent 45eef17 commit 04b5c00
Show file tree
Hide file tree
Showing 29 changed files with 615 additions and 469 deletions.
272 changes: 0 additions & 272 deletions .editorconfig

This file was deleted.

44 changes: 0 additions & 44 deletions STX.SPAL.Core/SPALOrchestrationService.Registerings.cs

This file was deleted.

27 changes: 27 additions & 0 deletions STX.SPAL.Providers.Abstractions/IAbstractionProvider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// ----------------------------------------------------------------------------------
// Copyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers
// ----------------------------------------------------------------------------------

using STX.SPAL.Abstractions;
using System;
using System.Threading.Tasks;

namespace STX.SPAL.Providers.Abstractions
{
public interface IAbstractionProvider<T> where T : ISPALProvider
{
T GetProvider();

void UseProvider(string spalId = null);
void UseProvider(Type concreteProviderType = null, string spalId = null);
void UseProvider<TConcreteProviderType>(string spalId = null) where TConcreteProviderType : T;

void Invoke<TResult>(Action<T> spalFunction);
void InvokeWithProvider<TConcreteProviderType, TResult>(Action<T> spalFunction) where TConcreteProviderType : T;

TResult Invoke<TResult>(Func<T, TResult> spalFunction);
ValueTask InvokeAsync<TResult>(Func<T, ValueTask> spalFunction);
ValueTask<TResult> InvokeAsync<TResult>(Func<T, ValueTask<TResult>> spalFunction);

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>disable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\STX.SPAL.Abstractions\STX.SPAL.Abstractions.csproj" />
</ItemGroup>

</Project>
29 changes: 29 additions & 0 deletions STX.SPAL.Providers/AbstractionProvider.Exceptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// ----------------------------------------------------------------------------------
// Copyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers
// ----------------------------------------------------------------------------------

using System;

namespace STX.SPAL.Providers
{
internal partial class AbstractionProvider<T>
{
private static TResult TryCatch<TResult>(
Func<TResult> function)
{
try
{
return function();
}

catch (InvalidOperationException invalidOperationException)
{
throw;
}
catch (Exception exception)
{
throw;
}
}
}
}
Loading

0 comments on commit 04b5c00

Please sign in to comment.