Remove static variables from stores
This commit is contained in:
1 parent
7b87c81989
commit
f5c3bee255
3 files changed
+11
-11
No files matched your search
@@ -108,10 +108,10 @@ namespace AspNetCore.Identity.MongoDbCore
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the database context for this store.
|
/// Gets the database context for this store.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static IMongoDbContext Context { get; set; }
|
private IMongoDbContext Context { get; }
|
||||||
|
|
||||||
private static IMongoRepository _mongoRepository;
|
private IMongoRepository _mongoRepository;
|
||||||
private static IMongoRepository MongoRepository
|
private IMongoRepository MongoRepository
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -103,10 +103,10 @@ namespace AspNetCore.Identity.MongoDbCore
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the database context for this store.
|
/// Gets the database context for this store.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static TContext Context { get; set; }
|
private TContext Context { get; }
|
||||||
|
|
||||||
private static IMongoRepository _mongoRepository;
|
private IMongoRepository _mongoRepository;
|
||||||
private static IMongoRepository MongoRepository
|
private IMongoRepository MongoRepository
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -130,18 +130,18 @@ namespace AspNetCore.Identity.MongoDbCore
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the database context for this store.
|
/// Gets the database context for this store.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static TContext Context { get; set; }
|
private TContext Context { get; }
|
||||||
|
|
||||||
private static object MongoRepositoryInitializationLock = new object();
|
private readonly object _mongoRepositoryInitializationLock = new object();
|
||||||
private static IMongoRepository _mongoRepository;
|
private IMongoRepository _mongoRepository;
|
||||||
private static IMongoRepository MongoRepository
|
private IMongoRepository MongoRepository
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
// double checked locking to prevent race to initialize the repository in multithreaded environment.
|
// double checked locking to prevent race to initialize the repository in multithreaded environment.
|
||||||
if (_mongoRepository == null)
|
if (_mongoRepository == null)
|
||||||
{
|
{
|
||||||
lock (MongoRepositoryInitializationLock)
|
lock (_mongoRepositoryInitializationLock)
|
||||||
{
|
{
|
||||||
if (_mongoRepository == null)
|
if (_mongoRepository == null)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user