예제 #1
0
        /// <summary>
        /// Gets a link to the image file of the Gravatar for the specified <paramref name="email"/>.
        /// </summary>
        /// <param name="email">The email whose Gravatar image source should be returned.</param>
        /// <returns>The URI of the Gravatar for the specified <paramref name="email"/>.</returns>
        public string GetImageSource(string email) {
            if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(email.Trim()))
                throw new ArgumentException("The email is empty.", "email");

            var imageUrl = "http://www.gravatar.com/avatar.php?";
            var hash = new Gremail(email).Hash();

            imageUrl += "gravatar_id=" + hash;
            imageUrl += "&rating=" + MaxRating.ToString();
            imageUrl += "&size=" + Size.ToString();

            var defImg = DefaultImage;
            if (!string.IsNullOrEmpty(defImg))
                imageUrl += "&default=" + System.Web.HttpUtility.UrlEncode(defImg);

            return imageUrl;
        }
예제 #2
0
        /// <summary>
        /// Gets a link to the image file of the Gravatar for the specified <paramref name="email"/>.
        /// </summary>
        /// <param name="email">The email whose Gravatar image source should be returned.</param>
        /// <returns>The URI of the Gravatar for the specified <paramref name="email"/>.</returns>
        public string GetImageSource(string email)
        {
            if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(email.Trim()))
            {
                throw new ArgumentException("The email is empty.", "email");
            }

            var imageUrl = "http://www.gravatar.com/avatar.php?";
            var hash     = new Gremail(email).Hash();

            imageUrl += "gravatar_id=" + hash;
            imageUrl += "&rating=" + MaxRating.ToString();
            imageUrl += "&size=" + Size.ToString();

            var defImg = DefaultImage;

            if (!string.IsNullOrEmpty(defImg))
            {
                imageUrl += "&default=" + System.Web.HttpUtility.UrlEncode(defImg);
            }

            return(imageUrl);
        }