示例#1
0
        public string GetImageLink(BasicInfo data, ImageSize imageSize)
        {
            data.ThrowIfNull(nameof(data));

            if (_serviceConfigurationInfo is null)
            {
                _serviceConfigurationInfo = TmdbServiceConfiguration.Configuration;
            }

            if (!(data is TmdbMovieInfo movieInfo))
            {
                throw new ArgumentException("Data handler has invalid type.", nameof(data));
            }

            int sizeIndex = GetImageSizeIndex(imageSize,
                                              _serviceConfigurationInfo.PosterSizes.Count);

            string imageSizeValue = _serviceConfigurationInfo.PosterSizes[sizeIndex];


            string result = _serviceConfigurationInfo.SecureBaseUrl + imageSizeValue +
                            movieInfo.PosterPath;

            return(result);
        }
示例#2
0
        public string GetImageLink(BasicInfo data, ImageSize imageSize)
        {
            data.ThrowIfNull(nameof(data));

            if (!(data is OmdbMovieInfo movieInfo))
            {
                throw new ArgumentException("Data handler has invalid type.", nameof(data));
            }

            return(movieInfo.PosterPath);
        }
示例#3
0
        private IImageSupplier DetermineImageSupplier(BasicInfo basicInfo)
        {
            basicInfo.ThrowIfNull(nameof(basicInfo));

            return(basicInfo switch
            {
                OmdbMovieInfo _ => new OmdbImageSupplier(),

                TmdbMovieInfo _ => new TmdbImageSupplier(TmdbServiceConfiguration.Configuration),

                SteamGameInfo _ => new SteamImageSupplier(),

                _ => throw new ArgumentOutOfRangeException(nameof(basicInfo), basicInfo,
                                                           "Got unknown type to process.")
            });