Ejemplo n.º 1
0
        /// <summary>
        /// Returns representation of this <see cref="YouTubeImageType"/> in YouTube links; such as 'hqdefault'.
        /// </summary>
        public static string ToYouTubeString(this YouTubeImageType type)
        {
            switch (type)
            {
            case YouTubeImageType.Default:
                return("default");

            case YouTubeImageType.MaximumResolution:
                return("maxresdefault");

            case YouTubeImageType.HighQuality:
                return("hqdefault");

            case YouTubeImageType.MediumQuality:
                return("mqdefault");

            case YouTubeImageType.StandardQuality:
                return("sddefault");

            default:
                throw new NotSupportedException($"YouTube image type '{type}' is undefined for the helper.");
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Returns URI for the specified YouTube image.
 /// </summary>
 public static Uri GetYouTubeImageUri(string videoId, YouTubeImageType type, bool useHttps = true)
 => new Uri(string.Format(StandardYouTubeImageUrlFormat,
                          useHttps ? "https" : "http",
                          videoId,
                          type.ToYouTubeString()));