Common/DocumentResultList: Refactor file loading, add zooflow file loading

This commit is contained in:
Jonathan Jenne
2021-12-17 16:40:25 +01:00
parent 8d19f70abc
commit 1b6a69b24f
14 changed files with 823 additions and 516 deletions

View File

@@ -37,11 +37,11 @@ Public Class DocumentResultCache
End Get
End Property
Public Sub Add(item As DocumentResultInfo) Implements ICollection(Of DocumentResultInfo).Add
Public Sub Add(pItem As DocumentResultInfo) Implements ICollection(Of DocumentResultInfo).Add
SyncLock Lock
If Index.ContainsKey(item.FullPath) Then
List.Remove(Index(item.FullPath))
Index(item.FullPath) = List.AddLast(item)
If Index.ContainsKey(pItem.Id) Then
List.Remove(Index(pItem.Id))
Index(pItem.Id) = List.AddLast(pItem)
Return
End If
@@ -50,23 +50,22 @@ Public Class DocumentResultCache
Remove(Oldest)
End If
Index.Add(item.FullPath, List.AddLast(item))
Index.Add(pItem.Id, List.AddLast(pItem))
If item.Contents IsNot Nothing Then
Count = Count + item.Contents?.Length
If pItem.Contents IsNot Nothing Then
Count += pItem.Contents?.Length
End If
End SyncLock
End Sub
Public Function Contains(item As DocumentResultInfo) As Boolean Implements ICollection(Of DocumentResultInfo).Contains
Return Index.ContainsKey(item.FullPath)
Public Function Contains(pItem As DocumentResultInfo) As Boolean Implements ICollection(Of DocumentResultInfo).Contains
Return Index.ContainsKey(pItem.Id)
End Function
Public Sub CopyTo(array As DocumentResultInfo(), ByVal arrayIndex As Integer) Implements ICollection(Of DocumentResultInfo).CopyTo
Public Sub CopyTo(pArray As DocumentResultInfo(), pIndex As Integer) Implements ICollection(Of DocumentResultInfo).CopyTo
SyncLock Lock
For Each item As DocumentResultInfo In Me
array(Math.Min(System.Threading.Interlocked.Increment(arrayIndex), arrayIndex - 1)) = item
pArray(Math.Min(System.Threading.Interlocked.Increment(pIndex), pIndex - 1)) = item
Next
End SyncLock
End Sub
@@ -84,15 +83,15 @@ Public Class DocumentResultCache
End Get
End Property
Public Function Remove(item As DocumentResultInfo) As Boolean Implements ICollection(Of DocumentResultInfo).Remove
Public Function Remove(pItem As DocumentResultInfo) As Boolean Implements ICollection(Of DocumentResultInfo).Remove
SyncLock Lock
If Index.ContainsKey(item.FullPath) Then
List.Remove(Index(item.FullPath))
Index.Remove(item.FullPath)
If Index.ContainsKey(pItem.Id) Then
List.Remove(Index(pItem.Id))
Index.Remove(pItem.Id)
If item.Contents IsNot Nothing Then
Count -= item.Contents.Length
If pItem.Contents IsNot Nothing Then
Count -= pItem.Contents.Length
End If
Return True