Пример #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);
        }