Hi,
I have a List of objects (string filename, BitmapImage image) to use as a cache of images.
private static readonly List<ImageData> imageCache = new List<ImageData>();
I created a Lookup to check this cache for an image each time it is required. If the image is not in the list it is added to the list.
The Looked is statically created
private static Lookup<string, ImageData> FileNameLookup = (Lookup<string, ImageData>)
imageCache.ToLookup(data => data.ImageFileName, data => data);
However, unless I recreate the FileNameLookup each time I add an element to the list the Lookup never returns objects that do have the same file name.
public static void Reinit()
{
FileNameLookup = (Lookup<string, ImageData>) imageCache.ToLookup(data =>
data.ImageFileName, data => data);
}
Should a Lookup only be used if the contents of the list is static? I can easily use a Dictionary but wanted to try a Lookup.
Cheers,
James