mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 02:36:19 +02:00
fixing all warnings and info for infra (#5891)
This commit is contained in:
@@ -19,11 +19,14 @@ namespace Wox.Infrastructure.Image
|
||||
public static class ImageLoader
|
||||
{
|
||||
private static readonly ImageCache ImageCache = new ImageCache();
|
||||
private static BinaryStorage<Dictionary<string, int>> _storage;
|
||||
private static readonly ConcurrentDictionary<string, string> GuidToKey = new ConcurrentDictionary<string, string>();
|
||||
|
||||
private static BinaryStorage<Dictionary<string, int>> _storage;
|
||||
private static IImageHashGenerator _hashGenerator;
|
||||
public static string ErrorIconPath;
|
||||
public static string DefaultIconPath;
|
||||
|
||||
public static string ErrorIconPath { get; set; }
|
||||
|
||||
public static string DefaultIconPath { get; set; }
|
||||
|
||||
private static readonly string[] ImageExtensions =
|
||||
{
|
||||
@@ -194,7 +197,7 @@ namespace Wox.Infrastructure.Image
|
||||
return new ImageResult(image, type);
|
||||
}
|
||||
|
||||
private static bool EnableImageHash = true;
|
||||
private static readonly bool _enableImageHash = true;
|
||||
|
||||
public static ImageSource Load(string path, bool loadFullImage = false)
|
||||
{
|
||||
@@ -202,20 +205,23 @@ namespace Wox.Infrastructure.Image
|
||||
|
||||
var img = imageResult.ImageSource;
|
||||
if (imageResult.ImageType != ImageType.Error && imageResult.ImageType != ImageType.Cache)
|
||||
{ // we need to get image hash
|
||||
string hash = EnableImageHash ? _hashGenerator.GetHashFromImage(img) : null;
|
||||
{
|
||||
// we need to get image hash
|
||||
string hash = _enableImageHash ? _hashGenerator.GetHashFromImage(img) : null;
|
||||
|
||||
if (hash != null)
|
||||
{
|
||||
int ImageCacheValue;
|
||||
if (GuidToKey.TryGetValue(hash, out string key))
|
||||
{ // image already exists
|
||||
if (ImageCache.Usage.TryGetValue(path, out ImageCacheValue))
|
||||
{
|
||||
// image already exists
|
||||
if (ImageCache.Usage.TryGetValue(path, out _))
|
||||
{
|
||||
img = ImageCache[key];
|
||||
}
|
||||
}
|
||||
else
|
||||
{ // new guid
|
||||
{
|
||||
// new guid
|
||||
GuidToKey[hash] = path;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user