Skip to content

Commit ddbfdce

Browse files
committed
Split file
1 parent c28abf6 commit ddbfdce

File tree

2 files changed

+48
-43
lines changed

2 files changed

+48
-43
lines changed

src/NHibernate/Id/TableHiLoGenerator.cs

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -115,47 +115,4 @@ public override object Generate(ISessionImplementor session, object obj)
115115

116116
#endregion
117117
}
118-
119-
internal class TenantStateStore<TState> where TState : new()
120-
{
121-
private TState _noTenantState;
122-
private Action<TState> _initializer;
123-
private readonly Lazy<ConcurrentDictionary<string, TState>> _tenantSpecificState = new Lazy<ConcurrentDictionary<string, TState>>(() => new ConcurrentDictionary<string, TState>());
124-
125-
public TenantStateStore(Action<TState> initializer)
126-
{
127-
_initializer = initializer;
128-
}
129-
130-
public TenantStateStore()
131-
{
132-
}
133-
134-
internal TState LocateGenerationState(string tenantIdentifier)
135-
{
136-
if (tenantIdentifier == null)
137-
{
138-
if (_noTenantState == null)
139-
{
140-
_noTenantState = CreateNewState();
141-
}
142-
return _noTenantState;
143-
}
144-
else
145-
{
146-
return _tenantSpecificState.Value.GetOrAdd(tenantIdentifier, _ => CreateNewState());
147-
}
148-
}
149-
150-
internal TState NoTenantGenerationState => _noTenantState ??
151-
throw new HibernateException("Could not locate previous generation state for no-tenant");
152-
153-
154-
private TState CreateNewState()
155-
{
156-
var state = new TState();
157-
_initializer?.Invoke(state);
158-
return state;
159-
}
160-
}
161118
}

src/NHibernate/Id/TenantStateStore.cs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
using System;
2+
using System.Collections.Concurrent;
3+
4+
namespace NHibernate.Id
5+
{
6+
internal class TenantStateStore<TState> where TState : new()
7+
{
8+
private TState _noTenantState;
9+
private Action<TState> _initializer;
10+
private readonly Lazy<ConcurrentDictionary<string, TState>> _tenantSpecificState = new Lazy<ConcurrentDictionary<string, TState>>(() => new ConcurrentDictionary<string, TState>());
11+
12+
public TenantStateStore(Action<TState> initializer)
13+
{
14+
_initializer = initializer;
15+
}
16+
17+
public TenantStateStore()
18+
{
19+
}
20+
21+
internal TState LocateGenerationState(string tenantIdentifier)
22+
{
23+
if (tenantIdentifier == null)
24+
{
25+
if (_noTenantState == null)
26+
{
27+
_noTenantState = CreateNewState();
28+
}
29+
return _noTenantState;
30+
}
31+
else
32+
{
33+
return _tenantSpecificState.Value.GetOrAdd(tenantIdentifier, _ => CreateNewState());
34+
}
35+
}
36+
37+
internal TState NoTenantGenerationState => _noTenantState ??
38+
throw new HibernateException("Could not locate previous generation state for no-tenant");
39+
40+
41+
private TState CreateNewState()
42+
{
43+
var state = new TState();
44+
_initializer?.Invoke(state);
45+
return state;
46+
}
47+
}
48+
}

0 commit comments

Comments
 (0)