예제 #1
0
 public static (bool isDefault, byte[] bytes) GetPicture(PictureDefinition def)
 {
     if (!cache.ContainsKey(def))
     {
         var path = getPath(def);
         cache[def]
             = File.Exists(path)
                                 ? File.ReadAllBytes(path)
                                 : null;
     }
     return(cache[def] == null, cache[def] ?? getDefaultImage(def.Size));
 }
예제 #2
0
        private static void saveFile(PictureDefinition def, byte[] bytes)
        {
            var path = getPath(def);

            File.WriteAllBytes(path, bytes);
        }
예제 #3
0
 private static string getPath(PictureDefinition def)
 => Path.Combine(ImagesDirectory, $"{def.PictureId}{def.Size}.jpg");
예제 #4
0
        private static byte[] downloadBytes(PictureDefinition def)
        {
            var sz = def.Size.ToString().Split('x')[1];

            return(imageDownloadClient.GetByteArrayAsync("ht" + $"tps://images-na.ssl-images-amazon.com/images/I/{def.PictureId}._SL{sz}_.jpg").Result);
        }