Exemple #1
0
 public static string MakeCatalogImageUri(
     Guid imageId,
     int width,
     int height,
     ImageIdType imageIdType,
     ImageRequested requestedImage)
 {
     return(MakeCatalogImageUri(imageId, width, height, imageIdType, requestedImage, false, false));
 }
Exemple #2
0
        public static string MakeCatalogImageUri(
            Guid imageId,
            int width,
            int height,
            ImageIdType imageIdType,
            ImageRequested requestedImage,
            bool forceImageResize,
            bool ignoreZeroLengths)
        {
            if (_endPoint == null)
            {
                _endPoint = Service.GetEndPointUri(EServiceEndpointId.SEID_ImageCatalog);
            }
            string empty = string.Empty;
            string urlPath;

            switch (imageIdType)
            {
            case ImageIdType.MovieId:
                urlPath = string.Format("{0}/movie/{1}/{2}", _endPoint, imageId.ToString(), requestedImage.ToString());
                break;

            case ImageIdType.ArtistId:
                urlPath = string.Format("{0}/music/artist/{1}/{2}", _endPoint, imageId.ToString(), requestedImage.ToString());
                break;

            case ImageIdType.MovieTrailerId:
                urlPath = string.Format("{0}/movieTrailer/{1}/{2}", _endPoint, imageId.ToString(), requestedImage.ToString());
                break;

            case ImageIdType.ParentalRatingId:
                urlPath = string.Format("{0}/apps/{1}/ratingImage", Service.GetEndPointUri(EServiceEndpointId.SEID_RootCatalog), imageId.ToString());
                break;

            default:
                urlPath = string.Format("{0}/image/{1}", _endPoint, imageId.ToString());
                break;
            }
            List <string> stringList = new List <string>();

            if (forceImageResize)
            {
                stringList.AddRange(new string[2]
                {
                    "resize",
                    "true"
                });
            }
            int width1  = width;
            int height1 = height;

            if (width1 != ImageConstants.NowPlaying.Width && height1 != ImageConstants.NowPlaying.Height)
            {
                CalculateImageUriSize(ref width1, ref height1);
            }
            if (width > 0 || !ignoreZeroLengths)
            {
                stringList.AddRange(new string[2]
                {
                    nameof(width),
                    width1.ToString()
                });
            }
            if (height > 0 || !ignoreZeroLengths)
            {
                stringList.AddRange(new string[2]
                {
                    nameof(height),
                    height1.ToString()
                });
            }
            return(MakeUrlEx(urlPath, stringList.ToArray()));
        }