public static IPicture Read(this IPictureReader target, Stream stream, string hash = null)
        {
            if (!(stream is MemoryStream memoryStream))
            {
                memoryStream = new MemoryStream();
                stream.CopyTo(memoryStream);
            }

            var bytes = memoryStream.ToArray();

            return(target.Read(bytes));
        }
        public static async Task <IPicture> ReadAsync(this IPictureReader target, Stream stream, string hash = null)
        {
            if (!(stream is MemoryStream memoryStream))
            {
                memoryStream = new MemoryStream();
                await stream.CopyToAsync(memoryStream);
            }

            var bytes = memoryStream.ToArray();

            return(target.Read(bytes));
        }
Пример #3
0
 public NamedPicture Map(ImageInfo fromItem)
 {
     if (fromItem == null || string.IsNullOrEmpty(fromItem.ArtistName) || string.IsNullOrEmpty(fromItem.ImageData))
     {
         throw new ArgumentNullException(nameof(fromItem));
     }
     if (IsUrlOfImage(fromItem.ImageData))
     {
         //get it from the web
         return(webPictureReader.Read(fromItem.ArtistName, fromItem.ImageData));
     }
     //get it from the payload
     return(dataPictureReader.Read(fromItem.ArtistName, fromItem.ImageData));
 }