-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathIdentityMapScope.cs
51 lines (46 loc) · 1.26 KB
/
IdentityMapScope.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System;
using Havit.Scopes;
namespace Havit.Business;
/// <summary>
/// <see cref="Scope{T}"/> pro <see cref="IdentityMap"/>.
/// </summary>
public class IdentityMapScope : Scope<IdentityMap>
{
#if NETFRAMEWORK
private static IScopeRepository<IdentityMap> scopeRepository = new Havit.Business.Scopes.WebApplicationScopeRepository<IdentityMap>();
#endif
#if NETSTANDARD
private static readonly IScopeRepository<IdentityMap> scopeRepository = new AsyncLocalScopeRepository<IdentityMap>();
#endif
/// <summary>
/// Repository pro uložení scopů IdentityMap.
/// Implementováno jako WebApplicationScopeRepository pro .NET Framework a jako AsyncLocalScopeRepository pro .NET Core.
/// </summary>
public static IScopeRepository<IdentityMap> ScopeRepository
{
get
{
return scopeRepository;
}
set
{
scopeRepository = value ?? throw new ArgumentNullException(nameof(value));
}
}
/// <summary>
/// Vrátí IdentityMapu pro aktuální scope.
/// </summary>
public static IdentityMap Current
{
get
{
return GetCurrent(ScopeRepository);
}
}
/// <summary>
/// Vytvoří <see cref="IdentityMapScope"/> obalující novou <see cref="IdentityMap"/>.
/// </summary>
public IdentityMapScope() : base(new IdentityMap(), ScopeRepository)
{
}
}