示例#1
0
 public bool TryGetParentDirectory(BaseEntry entry, out DirectoryEntry directory)
 {
     lock (_directoriesLockObject)
     {
         return(_directories.TryGetValue(entry.DirectoryId, out directory));
     }
 }
示例#2
0
 public bool CanWrite(BaseEntry entry)
 {
     lock (_writeLockObject)
     {
         var entryLocker = EntryLockerAccessorFactory.GetEntryLockerAccessor(Operation.Write)(this);
         return(!entryLocker.CheckIsLocked(entry));
     }
 }
示例#3
0
 public bool CanRead(BaseEntry entry)
 {
     lock (_readLockObject)
     {
         var entryLocker = EntryLockerAccessorFactory.GetEntryLockerAccessor(Operation.Read)(this);
         return(!entryLocker.CheckIsLocked(entry));
     }
 }
示例#4
0
 public void Unlock(BaseEntry entry)
 {
     lock (_lockObject)
     {
         if (CheckIsLocked(entry))
         {
             _dictionary[entry]--;
         }
     }
 }
示例#5
0
            public void Lock(BaseEntry entry)
            {
                lock (_lockObject)
                {
                    if (!_dictionary.ContainsKey(entry))
                    {
                        _dictionary.Add(entry, 0);
                    }

                    _dictionary[entry]++;
                }
            }
示例#6
0
        public void AddEntry(BaseEntry entry)
        {
            switch (entry)
            {
            case FileEntry file:
                addFile(file);
                break;

            case DirectoryEntry directory:
                addDirectory(directory);
                break;
            }
        }
示例#7
0
        public void RemoveEntry(BaseEntry entry)
        {
            switch (entry)
            {
            case FileEntry file:
                removeFile(file);
                break;

            case DirectoryEntry directory:
                removeDirectory(directory);
                break;
            }
        }
示例#8
0
        public bool TryLockWriting(BaseEntry entry, out LockerOperation operation)
        {
            lock (_writeLockObject)
            {
                operation = null;
                if (!CanWrite(entry))
                {
                    return(false);
                }

                operation = LockWriting(entry);
                return(true);
            }
        }
        private IEnumerable <DirectoryEntry> getDirectoryChain(BaseEntry entry)
        {
            var tmpEntry = entry;

            while (tmpEntry.DirectoryId > -1)
            {
                if (!Indexer.TryGetParentDirectory(tmpEntry, out var retv))
                {
                    continue;
                }

                tmpEntry = retv;
                yield return(retv);
            }
        }
示例#10
0
 public bool CheckIsLocked(BaseEntry entry)
 {
     lock (_lockObject)
         return(_dictionary.ContainsKey(entry) && _dictionary[entry] > 0);
 }
示例#11
0
 public LockerOperation LockWriting(BaseEntry entry)
 {
     return(LockWriting(new[] { entry }));
 }