File tree 1 file changed +5
-5
lines changed
1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -8,18 +8,18 @@ public interface IDocumentStoreFactory
8
8
9
9
public class DocumentStoreFactory : IDocumentStoreFactory
10
10
{
11
- private readonly ConcurrentDictionary < string , IDocumentStore > _stores ;
11
+ private readonly ConcurrentDictionary < string , Lazy < IDocumentStore > > _stores ;
12
12
13
13
public DocumentStoreFactory ( )
14
14
{
15
- _stores = new ConcurrentDictionary < string , IDocumentStore > ( ) ;
15
+ _stores = new ConcurrentDictionary < string , Lazy < IDocumentStore > > ( ) ;
16
16
}
17
17
18
18
public IDocumentStore GetStore ( string tenantId )
19
19
{
20
- if ( _stores . TryGetValue ( tenantId , out IDocumentStore value ) )
20
+ if ( _stores . TryGetValue ( tenantId , out var value ) )
21
21
{
22
- return value ;
22
+ return value . Value ;
23
23
}
24
24
25
25
var store = new DocumentStore
@@ -30,7 +30,7 @@ public IDocumentStore GetStore(string tenantId)
30
30
31
31
store . Initialize ( ) ;
32
32
33
- _stores [ tenantId ] = store ;
33
+ _stores [ tenantId ] = new Lazy < IDocumentStore > ( store ) ;
34
34
35
35
return store ;
36
36
}
You can’t perform that action at this time.
0 commit comments