-
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
11 changed files
with
113 additions
and
20 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 |
---|---|---|
@@ -1,23 +1,23 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netcoreapp2.2</TargetFramework> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> | ||
<RootNamespace>Digicando.MongoDM</RootNamespace> | ||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> | ||
<Version>0.18.2</Version> | ||
<Version>0.18.3</Version> | ||
<Authors>Digicando Srl</Authors> | ||
<Description>ODM framework for MongoDB</Description> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="DomainHelper" Version="0.18.0-dev" /> | ||
<PackageReference Include="Hangfire.Mongo" Version="0.6.3" /> | ||
<PackageReference Include="DomainHelper" Version="0.18.1" /> | ||
<PackageReference Include="Hangfire.Mongo" Version="0.6.6" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" /> | ||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="2.2.0" /> | ||
<PackageReference Include="MongoDB.Driver" Version="2.9.1" /> | ||
<PackageReference Include="MongoDB.Driver.GridFS" Version="2.9.1" /> | ||
<PackageReference Include="morelinq" Version="3.2.0" /> | ||
<PackageReference Include="MongoDB.Driver" Version="2.10.0" /> | ||
<PackageReference Include="MongoDB.Driver.GridFS" Version="2.10.0" /> | ||
<PackageReference Include="morelinq" Version="3.3.1" /> | ||
</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
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
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
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
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 Digicando.MongoDM.Utility | ||
{ | ||
internal interface ILocalContextAccessor | ||
{ | ||
LocalContext Context { get; } | ||
|
||
void OnCreated(LocalContext context); | ||
|
||
void OnDisposed(LocalContext context); | ||
} | ||
} |
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,9 @@ | ||
using System; | ||
|
||
namespace Digicando.MongoDM.Utility | ||
{ | ||
public interface ILocalContextFactory | ||
{ | ||
IDisposable CreateNewLocalContext(); | ||
} | ||
} |
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,24 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace Digicando.MongoDM.Utility | ||
{ | ||
public class LocalContext : IDisposable | ||
{ | ||
// Fields. | ||
private readonly ILocalContextAccessor localContextAccessor; | ||
|
||
// Constructors. | ||
internal LocalContext(ILocalContextAccessor localContextAccessor) | ||
{ | ||
this.localContextAccessor = localContextAccessor; | ||
localContextAccessor.OnCreated(this); | ||
} | ||
|
||
// Properties. | ||
public IDictionary<string, object> Items { get; } = new Dictionary<string, object>(); | ||
|
||
public void Dispose() => | ||
localContextAccessor.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,20 @@ | ||
using System.Threading; | ||
|
||
namespace Digicando.MongoDM.Utility | ||
{ | ||
class LocalContextAccessor : ILocalContextAccessor | ||
{ | ||
// Fields. | ||
private static readonly AsyncLocal<LocalContext> localContextCurrent = new AsyncLocal<LocalContext>(); | ||
|
||
// Properties. | ||
public LocalContext Context => localContextCurrent.Value; | ||
|
||
// Methods. | ||
public void OnCreated(LocalContext context) => | ||
localContextCurrent.Value = context; | ||
|
||
public void OnDisposed(LocalContext context) => | ||
localContextCurrent.Value = null; | ||
} | ||
} |
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 Digicando.MongoDM.Utility | ||
{ | ||
class LocalContextFactory : ILocalContextFactory | ||
{ | ||
private readonly ILocalContextAccessor localContextAccessor; | ||
|
||
public LocalContextFactory( | ||
ILocalContextAccessor localContextAccessor) | ||
{ | ||
this.localContextAccessor = localContextAccessor; | ||
} | ||
|
||
public IDisposable CreateNewLocalContext() => | ||
new LocalContext(localContextAccessor); | ||
} | ||
} |
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