Replaced ImageCacheItem by Tuple

This commit is contained in:
Clemens 2021-07-02 15:57:01 +02:00
parent 2709f90cdc
commit 77c2169999
14 changed files with 60 additions and 122 deletions

View file

@ -75,7 +75,7 @@ namespace MapControl.Caching
}
catch (Exception ex)
{
Debug.WriteLine("FileDbCache.Contains(\"{0}\"): {1}", key, ex.Message);
Debug.WriteLine("FileDbCache.Contains({0}): {1}", key, ex.Message);
}
return false;
@ -100,11 +100,7 @@ namespace MapControl.Caching
return null;
}
return new ImageCacheItem
{
Buffer = (byte[])record[0],
Expiration = (DateTime)record[1]
};
return Tuple.Create((byte[])record[0], (DateTime)record[1]);
}
public override CacheItem GetCacheItem(string key, string regionName = null)
@ -131,12 +127,12 @@ namespace MapControl.Caching
throw new ArgumentNullException(nameof(key));
}
if (!(value is ImageCacheItem imageCacheItem))
if (!(value is Tuple<byte[], DateTime> cacheItem))
{
throw new ArgumentException("The value argument must be a MapControl.Caching.ImageCacheItem instance.", nameof(value));
throw new ArgumentException("The value argument must be a Tuple<byte[], DateTime>.", nameof(value));
}
AddOrUpdateRecord(key, imageCacheItem.Buffer, imageCacheItem.Expiration);
AddOrUpdateRecord(key, cacheItem.Item1, cacheItem.Item2);
}
public override void Set(string key, object value, DateTimeOffset absoluteExpiration, string regionName = null)
@ -184,7 +180,7 @@ namespace MapControl.Caching
}
catch (Exception ex)
{
Debug.WriteLine("FileDbCache.Remove(\"{0}\"): {1}", key, ex.Message);
Debug.WriteLine("FileDbCache.Remove({0}): {1}", key, ex.Message);
}
}

View file

@ -46,8 +46,4 @@
<Reference Include="System.Runtime.Caching" />
<PackageReference Include="FileDb.NET" Version="7.4.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\MapControl\WPF\MapControl.WPF.csproj" />
</ItemGroup>
</Project>