コード例 #1
0
 public IList <FanArtImage> GetFanArt(FanArtConstants.FanArtMediaType mediaType, FanArtConstants.FanArtType fanArtType, string name, int maxWidth, int maxHeight, bool singleRandom)
 {
     InitProviders();
     foreach (IFanArtProvider fanArtProvider in _providerList)
     {
         IList <IResourceLocator> fanArtImages;
         if (fanArtProvider.TryGetFanArt(mediaType, fanArtType, name, maxWidth, maxHeight, singleRandom, out fanArtImages))
         {
             IList <IResourceLocator> result = singleRandom ? GetSingleRandom(fanArtImages) : fanArtImages;
             return(result.Select(f => FanArtImage.FromResource(f, maxWidth, maxHeight, mediaType, fanArtType, name)).Where(fanArtImage => fanArtImage != null).ToList());
         }
     }
     foreach (IBinaryFanArtProvider binaryProvider in _providerList.OfType <IBinaryFanArtProvider>())
     {
         if (binaryProvider != null)
         {
             IList <FanArtImage> binaryImages;
             if (binaryProvider.TryGetFanArt(mediaType, fanArtType, name, maxWidth, maxHeight, singleRandom, out binaryImages))
             {
                 return(singleRandom ? GetSingleRandom(binaryImages) : binaryImages);
             }
         }
     }
     return(null);
 }
コード例 #2
0
 public IList <FanArtImage> GetFanArt(string mediaType, string fanArtType, string name, int maxWidth, int maxHeight, bool singleRandom)
 {
     InitProviders();
     foreach (FanArtProviderSource source in Enum.GetValues(typeof(FanArtProviderSource)))
     {
         foreach (IFanArtProvider fanArtProvider in _providerList.Where(p => p.Source == source))
         {
             IList <IResourceLocator> fanArtImages;
             if (fanArtProvider.TryGetFanArt(mediaType, fanArtType, name, maxWidth, maxHeight, singleRandom, out fanArtImages))
             {
                 IList <IResourceLocator> result = singleRandom ? GetSingleRandom(fanArtImages) : fanArtImages;
                 return(result.Select(f => FanArtImage.FromResource(f, maxWidth, maxHeight)).Where(fanArtImage => fanArtImage != null).ToList());
             }
         }
         foreach (IBinaryFanArtProvider binaryProvider in _providerList.OfType <IBinaryFanArtProvider>().Where(p => p.Source == source))
         {
             if (binaryProvider != null)
             {
                 IList <FanArtImage> binaryImages;
                 if (binaryProvider.TryGetFanArt(mediaType, fanArtType, name, maxWidth, maxHeight, singleRandom, out binaryImages))
                 {
                     return(singleRandom ? GetSingleRandom(binaryImages) : binaryImages);
                 }
             }
         }
     }
     return(null);
 }