-
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.
ServiceProvider instantiation when registering with no DI. Adds AbstractionProvider. #10
- Loading branch information
Showing
29 changed files
with
615 additions
and
469 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,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); | ||
|
||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
STX.SPAL.Providers.Abstractions/STX.SPAL.Providers.Abstractions.csproj
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 @@ | ||
<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> |
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,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; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.