private static int GetSizePriority(ArtistImageSize size)
 {
     if (ImageSizes2.ContainsKey(size))
     {
         return(ImageSizes2[size]);
     }
     return(999);
 }
Exemplo n.º 2
0
        public Bitmap Image(ArtistImageSize imageSize)
        {
            var imageElements = xmlDocument.Elements().First().Elements().
                Where(e => e.Name.LocalName == "artist").Elements().
                Where(e => e.Name.LocalName == "image");

            string imageUrl = (from imageElement in imageElements
                                from xAttribute in
                                    imageElement.Attributes().Where(xAttribute => xAttribute.Name.LocalName == "size").
                                    Where(xAttribute => xAttribute.Value == imageSize.ToString().ToLower())
                                select imageElement.Value).FirstOrDefault();

            WebRequest request = WebRequest.Create(imageUrl);
            Stream responseStream = request.GetResponse().GetResponseStream();

            Bitmap bitmap = new Bitmap(responseStream);

            request = null;
            responseStream = null;

            return bitmap;
        }