Ejemplo n.º 1
0
        /// <summary>
        ///     Converts the string representation of a <see cref="VideoSize"/> into its <see cref="VideoSize"/> object equivalent and
        ///     returns a boolean indicating if the conversion succeeded.
        /// </summary>
        ///
        /// <param name="s">
        ///     A string representing a <see cref="VideoSize"/>.
        /// </param>
        /// <param name="result">
        /// </param>
        /// <returns>
        ///     <c>true</c> if the conversion succeeded; otherwise, <c>false</c>.
        /// </returns>
        public static bool TryParse(string s, out VideoSize result)
        {
            result = default(VideoSize);
            if (string.IsNullOrWhiteSpace(s))
            {
                return(false);
            }
            if (s.CountOccurences("x") != 1)
            {
                return(false);
            }

            var split  = s.Split('x');
            var width  = 0;
            var height = 0;

            if (string.IsNullOrWhiteSpace(split[0]) || string.IsNullOrWhiteSpace(split[1]))
            {
                return(false);
            }
            if (!int.TryParse(split[0], out width) || !int.TryParse(split[1], out height))
            {
                return(false);
            }
            if (width < 0 || height < 0)
            {
                return(false);
            }

            result = new VideoSize(width, height);
            return(true);
        }
Ejemplo n.º 2
0
 internal YoutubeVideoFormat(Uri url, VideoSize size, int formatCode)
 {
     _videoUrl   = url;
     _formatCode = formatCode;
     _size       = size;
 }
Ejemplo n.º 3
0
 internal YoutubeVideoFormat(string ext, VideoSize size, bool is3d = false)
 {
     _extension = ext;
     _size      = size;
 }
Ejemplo n.º 4
0
 /// <summary>
 ///     Determines whether the specified <see cref="VideoSize"/> object is equal to the current <see cref="VideoSize"/> object.
 /// </summary>
 ///
 /// <param name="obj">
 ///     The <see cref="VideoSize"/> object to compare with the current <see cref="VideoSize"/> object.
 /// </param>
 ///
 /// <returns>
 ///     <c>true</c> if the specified <see cref="VideoSize"/> object is equal with the current <see cref="VideoSize"/> object; otherwise, <c>false</c>.
 /// </returns>
 public bool Equals(VideoSize obj)
 {
     return(obj.Width == Width && obj.Height == Height);
 }