-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Bugfix] A smartlist could be set as the source of another list refer…
…encing itself. Happens when changing source, if the previous one was already cached. Will remove all reference to a list in the recursion cache when changing the source.
- Loading branch information
Showing
5 changed files
with
59 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using cYo.Common.Collections; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace cYo.Projects.ComicRack.Engine.Database | ||
{ | ||
public class RecursionCache: Dictionary<Guid, RecursionCacheItem> | ||
{ | ||
private static Lazy<RecursionCache> instance = new Lazy<RecursionCache>(() => new RecursionCache()); | ||
|
||
public static RecursionCache Items => instance.Value; | ||
|
||
private RecursionCache() : base() | ||
{ | ||
|
||
} | ||
|
||
public RecursionCacheItem GetValue(Guid guid) | ||
{ | ||
if (Items.TryGetValue(guid, out RecursionCacheItem cachedResult)) | ||
{ | ||
return cachedResult; | ||
} | ||
|
||
RecursionCacheItem item = RecursionCacheItem.Empty(); | ||
this[guid] = item; | ||
return item; | ||
} | ||
|
||
public void RemoveReference(Guid guid) | ||
{ | ||
//Remove all the cache for this list | ||
Items.Remove(guid); | ||
//And all it's reference | ||
Items.Where(cacheItem => cacheItem.Value.ContainsKey(guid)).SafeForEach(x => x.Value.Remove(guid)); | ||
} | ||
} | ||
|
||
public class RecursionCacheItem : Dictionary<Guid, bool> | ||
{ | ||
private RecursionCacheItem() : base() | ||
{ | ||
|
||
} | ||
|
||
public static RecursionCacheItem Empty() | ||
{ | ||
return new RecursionCacheItem(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters