GitSharp.Core.RepositoryCache.openRepository C# (CSharp) Method

openRepository() private method

private openRepository ( Key location, bool mustExist ) : Repository
location Key
mustExist bool
return Repository
        private Repository openRepository(Key location, bool mustExist)
        {
            WeakReference<Repository> @ref = cacheMap.GetValue(location);
            Repository db = @ref != null ? @ref.get() : null;

            if (db == null)
            {
                lock (lockFor(location))
                {
                    @ref = cacheMap.GetValue(location);
                    db = @ref != null ? @ref.get() : null;
                    if (db == null)
                    {
                        db = location.open(mustExist);
                        @ref = new WeakReference<Repository>(db);
                        cacheMap.AddOrReplace(location, @ref);
                    }
                }
            }

            db.IncrementOpen();
            return db;
        }