-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
136 changed files
with
3,003 additions
and
1,517 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,31 @@ | ||
name: Build test and package .Net Core library - MongODM | ||
|
||
on: | ||
push: | ||
branches: [ master, dev ] | ||
|
||
jobs: | ||
build-test-package: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@master | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Setup .NET Core SDK | ||
uses: actions/setup-dotnet@master | ||
with: | ||
dotnet-version: '3.1.x' | ||
|
||
- name: Build with dotnet | ||
run: dotnet build --configuration Release | ||
|
||
- name: Run unit tests | ||
run: dotnet test --configuration Release | ||
|
||
- name: Generate nuget package | ||
run: dotnet pack --configuration Release -o nupkg | ||
|
||
- name: Push packages | ||
run: dotnet nuget push './nupkg/*.nupkg' --api-key ${{secrets.MYGET_APIKEY}} --source https://www.myget.org/F/etherna/api/v3/index.json |
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,78 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 16 | ||
VisualStudioVersion = 16.0.28803.156 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{490DAED7-DAD8-459A-A20E-F57F2F6F619E}" | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{CF1ABDEA-794F-4474-858D-BCB61F367D72}" | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MongODM.Hangfire", "src\MongODM.Hangfire\MongODM.Hangfire.csproj", "{10897D0D-4898-4A4D-8D1E-B2435E93D9A1}" | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ExecutionContext", "src\ExecutionContext\ExecutionContext.csproj", "{DB6C020D-1C93-4456-8FB5-EF7CF505DF7B}" | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ExecutionContext.Tests", "test\ExecutionContext.Tests\ExecutionContext.Tests.csproj", "{BF4F963A-DBCE-4C53-A209-502F4CAF12C5}" | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MongODM.AspNetCore", "src\MongODM.AspNetCore\MongODM.AspNetCore.csproj", "{6374F645-5D17-494E-9529-7F83426900B3}" | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MongODM.Core", "src\MongODM.Core\MongODM.Core.csproj", "{4F2498A9-D60D-4D49-95B9-BC78EE2917B5}" | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MongODM.Core.Tests", "test\MongODM.Core.Tests\MongODM.Core.Tests.csproj", "{50D6BEE5-54B5-43F3-BA92-6107AB6E311E}" | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{03C64D98-FF9F-4760-AE82-203953FF4940}" | ||
ProjectSection(SolutionItems) = preProject | ||
.gitignore = .gitignore | ||
EndProjectSection | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{D4BB5972-5F7B-43ED-81C1-69ECF0E62D1E}" | ||
ProjectSection(SolutionItems) = preProject | ||
.github\workflows\build-test-package.yml = .github\workflows\build-test-package.yml | ||
EndProjectSection | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{10897D0D-4898-4A4D-8D1E-B2435E93D9A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{10897D0D-4898-4A4D-8D1E-B2435E93D9A1}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{10897D0D-4898-4A4D-8D1E-B2435E93D9A1}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{10897D0D-4898-4A4D-8D1E-B2435E93D9A1}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{DB6C020D-1C93-4456-8FB5-EF7CF505DF7B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{DB6C020D-1C93-4456-8FB5-EF7CF505DF7B}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{DB6C020D-1C93-4456-8FB5-EF7CF505DF7B}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{DB6C020D-1C93-4456-8FB5-EF7CF505DF7B}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{BF4F963A-DBCE-4C53-A209-502F4CAF12C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{BF4F963A-DBCE-4C53-A209-502F4CAF12C5}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{BF4F963A-DBCE-4C53-A209-502F4CAF12C5}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{BF4F963A-DBCE-4C53-A209-502F4CAF12C5}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{6374F645-5D17-494E-9529-7F83426900B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{6374F645-5D17-494E-9529-7F83426900B3}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{6374F645-5D17-494E-9529-7F83426900B3}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{6374F645-5D17-494E-9529-7F83426900B3}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{4F2498A9-D60D-4D49-95B9-BC78EE2917B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{4F2498A9-D60D-4D49-95B9-BC78EE2917B5}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{4F2498A9-D60D-4D49-95B9-BC78EE2917B5}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{4F2498A9-D60D-4D49-95B9-BC78EE2917B5}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{50D6BEE5-54B5-43F3-BA92-6107AB6E311E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{50D6BEE5-54B5-43F3-BA92-6107AB6E311E}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{50D6BEE5-54B5-43F3-BA92-6107AB6E311E}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{50D6BEE5-54B5-43F3-BA92-6107AB6E311E}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(NestedProjects) = preSolution | ||
{10897D0D-4898-4A4D-8D1E-B2435E93D9A1} = {490DAED7-DAD8-459A-A20E-F57F2F6F619E} | ||
{DB6C020D-1C93-4456-8FB5-EF7CF505DF7B} = {490DAED7-DAD8-459A-A20E-F57F2F6F619E} | ||
{BF4F963A-DBCE-4C53-A209-502F4CAF12C5} = {CF1ABDEA-794F-4474-858D-BCB61F367D72} | ||
{6374F645-5D17-494E-9529-7F83426900B3} = {490DAED7-DAD8-459A-A20E-F57F2F6F619E} | ||
{4F2498A9-D60D-4D49-95B9-BC78EE2917B5} = {490DAED7-DAD8-459A-A20E-F57F2F6F619E} | ||
{50D6BEE5-54B5-43F3-BA92-6107AB6E311E} = {CF1ABDEA-794F-4474-858D-BCB61F367D72} | ||
{D4BB5972-5F7B-43ED-81C1-69ECF0E62D1E} = {03C64D98-FF9F-4760-AE82-203953FF4940} | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {43A8089E-9445-4DE1-B509-F049E211B555} | ||
EndGlobalSection | ||
EndGlobal |
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 @@ | ||
<mxfile host="Electron" modified="2020-02-12T02:07:49.882Z" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/12.6.5 Chrome/80.0.3987.86 Electron/8.0.0 Safari/537.36" etag="DZfUQQbziV9wZCdCpsGX" version="12.6.5" type="device"><diagram name="Page-1" id="9f46799a-70d6-7492-0946-bef42562c5a5">7V1bc6M6Ev41qco8xAXi/hjbSSa1yZnZZM5ln7aIUWwmGLyAk3h+/UogYZCELV8A2+OcOYktblJf1N1ft8SFNph+3sXubPIYeTC4AIr3eaENLwBQddNEf3DLgrSYFmkZx75H2pYNz/4vSBoV0jr3PZhUTkyjKEj9WbVxFIUhHKWVNjeOo4/qaa9RUH3qzB1DruF55AZ869++l05Iq2o6ywNfoT+ekEfbwMoPvLijt3EczUPyvAugvWY/+eGpS+9FBppMXC/6KDVpNxfaII6iNP80/RzAABOXki2/7rbmaNHvGIapzAX6f9X+zPv69S/r759/3Hp/Pv9989cVGcu7G8whHYYZoPv1Z7jL6YKQyfzfHPezP3XjsR9eaNfoqDL7RL9RYzZa3H6VRrP8mF46lsLP9MoN/DG5boQ6DOPlPdGnMfmbPdkvNbhTdMN+wH+7x/d4dUewaK5eUrkjIorPPuUl5lpow/3wZRCFuNulG7ywp6O2Gds2iTHVqIzTAar1Y92KygF8TUtk5u+Nzx0EfiYY+LT7xygcR6RFMH58/tBN3Rc3geUrirYVQ25uBMP+wB1NaIfot4668uj6YYr+R4JL+1Nq6qZT0Wg+RRx9RmSZuk9w7Cfpsnvig5129C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FBTMkUY4ZOH4naF3tapgrenX3b/fjYWizL89vH37x3DDz7vbwRWvXuzKJFbHft/sOqfUApFclV1Xe1Y10aLSZFflrSlIPH6D12YIpfG8V4+krNXr8kZ5+zpZ292wCDsosisocMC7rw7mCVK3a8/LiOcGRSEt3YaVlYPT2HRr/2zW5KeUfVRoCHsoeq+cVrwyNWd1xuARnCEbQ5eFxit3ZTpzWuYdpy1zWgZLbKlYg3Hc1rqLq9whyXxYK/lzVbF1XKuhmYplOLqjMaC9YfaU0g/Qqg+Q36oje4wNsmeYyEGtPga7raues7Wfir7GES6DX56OQrVJvi5cu/k/</diagram></mxfile> |
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,42 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading; | ||
|
||
namespace Etherna.ExecContext.AsyncLocal | ||
{ | ||
/// <summary> | ||
/// Async local context implementation. This can be used as singleton or with multiple instances. | ||
/// The <see cref="AsyncLocal{T}"/> container permits to have an Item instance inside this | ||
/// method calling tree. | ||
/// </summary> | ||
/// <remarks> | ||
/// Before try to use an async local context, call the method <see cref="InitAsyncLocalContext"/> | ||
/// for initialize the <see cref="AsyncLocal{T}"/> container, and receive a context handler. | ||
/// After have used, dispose the handler for destroy the current context dictionary. | ||
/// </remarks> | ||
public class AsyncLocalContext : IAsyncLocalContext, IHandledAsyncLocalContext | ||
{ | ||
// Fields. | ||
private static readonly AsyncLocal<IDictionary<object, object>?> asyncLocalContext = new AsyncLocal<IDictionary<object, object>?>(); | ||
|
||
// Properties. | ||
public IDictionary<object, object>? Items => asyncLocalContext.Value; | ||
|
||
// Static properties. | ||
public static IAsyncLocalContext Instance { get; } = new AsyncLocalContext(); | ||
|
||
// Methods. | ||
public IAsyncLocalContextHandler InitAsyncLocalContext() | ||
{ | ||
if (asyncLocalContext.Value != null) | ||
throw new InvalidOperationException("Only one context at time is supported"); | ||
|
||
asyncLocalContext.Value = new Dictionary<object, object>(); | ||
|
||
return new AsyncLocalContextHandler(this); | ||
} | ||
|
||
public void OnDisposed(IAsyncLocalContextHandler context) => | ||
asyncLocalContext.Value = null; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/ExecutionContext/AsyncLocal/AsyncLocalContextHandler.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 @@ | ||
namespace Etherna.ExecContext.AsyncLocal | ||
{ | ||
/// <summary> | ||
/// The handler for an <see cref="AsyncLocalContext"/> initialization. | ||
/// Dispose this for release the context. | ||
/// </summary> | ||
public sealed class AsyncLocalContextHandler : IAsyncLocalContextHandler | ||
{ | ||
// Constructors. | ||
internal AsyncLocalContextHandler(IHandledAsyncLocalContext handledContext) | ||
{ | ||
HandledContext = handledContext; | ||
} | ||
|
||
// Properties. | ||
internal IHandledAsyncLocalContext HandledContext { get; } | ||
|
||
// Methods. | ||
public void Dispose() => HandledContext.OnDisposed(this); | ||
} | ||
} |
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 @@ | ||
using System; | ||
|
||
namespace Etherna.ExecContext.AsyncLocal | ||
{ | ||
/// <summary> | ||
/// The <see cref="AsyncLocalContext"/> interface. | ||
/// Permits to create an async local context living with the method calling tree. | ||
/// </summary> | ||
public interface IAsyncLocalContext : IExecutionContext | ||
{ | ||
/// <summary> | ||
/// Initialize a new async local context | ||
/// </summary> | ||
/// <returns>The new context handler</returns> | ||
/// <exception cref="InvalidOperationException">Throw when another local context is found</exception> | ||
IAsyncLocalContextHandler InitAsyncLocalContext(); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/ExecutionContext/AsyncLocal/IAsyncLocalContextHandler.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,11 @@ | ||
using System; | ||
|
||
namespace Etherna.ExecContext.AsyncLocal | ||
{ | ||
/// <summary> | ||
/// A disposable interface for <see cref="AsyncLocalContextHandler"/> | ||
/// </summary> | ||
public interface IAsyncLocalContextHandler : IDisposable | ||
{ | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/ExecutionContext/AsyncLocal/IHandledAsyncLocalContext.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,11 @@ | ||
namespace Etherna.ExecContext.AsyncLocal | ||
{ | ||
/// <summary> | ||
/// Interface used by <see cref="AsyncLocalContextHandler"/> for comunicate with its | ||
/// creator <see cref="AsyncLocalContext"/>. | ||
/// </summary> | ||
internal interface IHandledAsyncLocalContext | ||
{ | ||
void OnDisposed(IAsyncLocalContextHandler context); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/ExecutionContext/Exceptions/ExecutionContextNotFoundException.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 @@ | ||
using System; | ||
|
||
namespace Etherna.ExecContext.Exceptions | ||
{ | ||
public class ExecutionContextNotFoundException : Exception | ||
{ | ||
public ExecutionContextNotFoundException(string message) : base(message) | ||
{ } | ||
|
||
public ExecutionContextNotFoundException(string message, Exception innerException) : base(message, innerException) | ||
{ } | ||
|
||
public ExecutionContextNotFoundException() | ||
{ } | ||
} | ||
} |
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 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> | ||
<RootNamespace>Etherna.ExecContext</RootNamespace> | ||
<Authors>Etherna Sagl</Authors> | ||
<Description>Execution context provider</Description> | ||
<LangVersion>8.0</LangVersion> | ||
<Nullable>enable</Nullable> | ||
<RepositoryUrl>https://github.com/Etherna/mongodm</RepositoryUrl> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="GitVersionTask" Version="5.3.7"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.0.0"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
</Project> |
Oops, something went wrong.