public async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            var httpClient     = new HttpClient();
            var feed           = "http://planet.xamarin.com/feed/";
            var responseString = await httpClient.GetStringAsync(feed);

            FeedItems.Clear();
            var items = await ParseFeed(responseString);

            foreach (var item in items)
            {
                item.Image = Gravatar.GetUrl(item.Author);
                FeedItems.Add(item);
            }


            IsBusy = false;
        }
Ejemplo n.º 2
0
        public void GetUrlDefaults()
        {
            string url = Gravatar.GetUrl("*****@*****.**");

            Assert.Equal(
                "http://www.gravatar.com/avatar/f3ada405ce890b6f8204094deb12d8a8?s=80",
                url
                );
        }
Ejemplo n.º 3
0
        public string GetIconUrl(User user)
        {
            if (string.IsNullOrEmpty(user.Email))
            {
                return(string.Empty);
            }

            return(Gravatar.GetUrl(user.Email, size));
        }
Ejemplo n.º 4
0
 public void TestGetUrlEmptyDefaultAction()
 {
     Assert.AreEqual("https://www.gravatar.com/avatar/87373a6b9021f2cd33c7a4e8515968c9",
                     Gravatar.GetUrl("*****@*****.**", ""));
     Assert.AreEqual("https://www.gravatar.com/avatar/3134db8e86cd79b19fa0de1788a916c3",
                     Gravatar.GetUrl("*****@*****.**", ""));
     Assert.AreEqual("https://www.gravatar.com/avatar/34cda77ec30fb5a22d2e6e65d32932e1",
                     Gravatar.GetUrl("*****@*****.**", ""));
 }
Ejemplo n.º 5
0
 public void TestGetUrlNormalFormattingWhitespace()
 {
     Assert.AreEqual("https://www.gravatar.com/avatar/87373a6b9021f2cd33c7a4e8515968c9",
                     Gravatar.GetUrl(" [email protected]"));
     Assert.AreEqual("https://www.gravatar.com/avatar/87373a6b9021f2cd33c7a4e8515968c9",
                     Gravatar.GetUrl("[email protected] "));
     Assert.AreEqual("https://www.gravatar.com/avatar/87373a6b9021f2cd33c7a4e8515968c9",
                     Gravatar.GetUrl("    [email protected]    "));
 }
Ejemplo n.º 6
0
 public void TestGetUrlCaps()
 {
     Assert.AreEqual("https://www.gravatar.com/avatar/87373a6b9021f2cd33c7a4e8515968c9",
                     Gravatar.GetUrl("*****@*****.**"));
     Assert.AreEqual("https://www.gravatar.com/avatar/87373a6b9021f2cd33c7a4e8515968c9",
                     Gravatar.GetUrl("*****@*****.**"));
     Assert.AreEqual("https://www.gravatar.com/avatar/87373a6b9021f2cd33c7a4e8515968c9",
                     Gravatar.GetUrl("*****@*****.**"));
 }
Ejemplo n.º 7
0
        public string GetIconUrl(User user)
        {
            if (string.IsNullOrEmpty(user.Email))
            {
                return(string.Empty);
            }

            return(Gravatar.GetUrl(user.Email, size, scheme: ssl ? "https" : "http"));
        }
Ejemplo n.º 8
0
        public void GetUrl_UsesParameterSizeBeforeInstanceSize()
        {
            var gravatar = new Gravatar {
                Size = 88
            };
            var actual   = gravatar.GetUrl("*****@*****.**", size: 87);
            var expected = "http://www.gravatar.com/avatar/bccc2b381d103797427c161951be5fa5?s=87";

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 9
0
        public void GetUrl_UsesParameterRatingBeforeInstanceRating()
        {
            var gravatar = new Gravatar {
                Rating = GravatarRating.G
            };
            var actual   = gravatar.GetUrl("*****@*****.**", rating: GravatarRating.X);
            var expected = "http://www.gravatar.com/avatar/bccc2b381d103797427c161951be5fa5?r=x";

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 10
0
        public void GetUrl_IncludesForceDefault()
        {
            var gravatar = new Gravatar {
                Default = "my_default.jpg"
            };
            var actual   = gravatar.GetUrl("*****@*****.**", forceDefault: true);
            var expected = "http://www.gravatar.com/avatar/bccc2b381d103797427c161951be5fa5?d=my_default.jpg&f=y";

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 11
0
        public static string Url(string email, int size)
        {
            var url = email == null ? null : Gravatar.GetUrl(email, size, "retro", GravatarRating.G);

            if (url != null && ShouldUseSecureGravatar())
            {
                url = url.Replace(UnsecureGravatarUrl, SecureGravatarUrl);
            }

            return(HttpUtility.HtmlDecode(url));
        }
Ejemplo n.º 12
0
        public void GetUrl_UsesInstanceProperties()
        {
            var gravatar = new Gravatar {
                Default = "https://some.avatar.png/image",
                Rating  = GravatarRating.PG,
                Size    = 94
            };
            var actual   = gravatar.GetUrl("*****@*****.**");
            var expected = "http://www.gravatar.com/avatar/bccc2b381d103797427c161951be5fa5?s=94&r=pg&d=https%3a%2f%2fsome.avatar.png%2fimage";

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 13
0
        public void Gravatar_ReturnsUrl() {
            var size = 274;
            var email = "*****@*****.**";
            var defaultImage = "pathtodefault.img";
            var maxRating = GravatarRating.X;
            var gravatarSrc = GravatarUrl.Gravatar(null, email, size, maxRating, defaultImage);

            var gravatar = new Gravatar();
            gravatar.Size = size;
            gravatar.Default = defaultImage;
            gravatar.Rating = maxRating;

            Assert.AreEqual(gravatar.GetUrl(email), gravatarSrc);
        }
Ejemplo n.º 14
0
        public void Gravatar_ReturnsUrl()
        {
            var size         = 274;
            var email        = "*****@*****.**";
            var defaultImage = "pathtodefault.img";
            var maxRating    = GravatarRating.X;
            var gravatarSrc  = GravatarUrl.Gravatar(null, email, size, maxRating, defaultImage);

            var gravatar = new Gravatar();

            gravatar.Size    = size;
            gravatar.Default = defaultImage;
            gravatar.Rating  = maxRating;

            Assert.AreEqual(gravatar.GetUrl(email), gravatarSrc);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Generates a URL to Gravatar that isn't proxied.
        /// </summary>
        /// <param name="email">The user's email address.</param>
        /// <param name="size">The size of the gravatar image.</param>
        /// <returns>The image URL, direct to Gravatar without proxying.</returns>
        public static string RawUrl(string email, int size)
        {
            // The maximum allowed Gravatar size is 512 pixels.
            if (size > 512)
            {
                size = 512;
            }

            var url = email == null ? null : Gravatar.GetUrl(email, size, "retro", GravatarRating.G);

            if (url != null && ShouldUseSecureGravatar())
            {
                url = url.Replace(UnsecureGravatarUrl, SecureGravatarUrl);
            }

            return(HttpUtility.HtmlDecode(url));
        }
Ejemplo n.º 16
0
 public void GetUrl_UsesInstanceProperties() {
     var gravatar = new Gravatar {
         Default = "https://some.avatar.png/image",
         Rating = GravatarRating.PG,
         Size = 94
     };
     var actual = gravatar.GetUrl("*****@*****.**");
     var expected = "http://www.gravatar.com/avatar/bccc2b381d103797427c161951be5fa5?s=94&r=pg&d=https%3a%2f%2fsome.avatar.png%2fimage";
     Assert.AreEqual(expected, actual);
 }
Ejemplo n.º 17
0
 private string GetUrl(IUserWithEmail user, int sizePx) => Gravatar.GetUrl(user.Email, sizePx);
Ejemplo n.º 18
0
 public void GetUrl_UsesParameterSizeBeforeInstanceSize() {
     var gravatar = new Gravatar { Size = 88 };
     var actual = gravatar.GetUrl("*****@*****.**", size: 87);
     var expected = "http://www.gravatar.com/avatar/bccc2b381d103797427c161951be5fa5?s=87";
     Assert.AreEqual(expected, actual);
 }
Ejemplo n.º 19
0
 public void GetUrl_UsesParameterRatingBeforeInstanceRating() {
     var gravatar = new Gravatar { Rating = GravatarRating.G };
     var actual = gravatar.GetUrl("*****@*****.**", rating: GravatarRating.X);
     var expected = "http://www.gravatar.com/avatar/bccc2b381d103797427c161951be5fa5?r=x";
     Assert.AreEqual(expected, actual);
 }
Ejemplo n.º 20
0
 public void GetUrl_IncludesForceDefault() {
     var gravatar = new Gravatar { Default = "my_default.jpg" };
     var actual = gravatar.GetUrl("*****@*****.**", forceDefault: true);
     var expected = "http://www.gravatar.com/avatar/bccc2b381d103797427c161951be5fa5?d=my_default.jpg&f=y";
     Assert.AreEqual(expected, actual);
 }
 private string GetUrl(IUserWithEmail user, int sizePx) => Gravatar.GetUrl(user.Email, sizePx, scheme: "https");
Ejemplo n.º 22
0
 private string GetUrl(IUserWithEmail user, int sizePx)
 {
     return(Gravatar.GetUrl(user.Email, sizePx, scheme: ssl ? "https" : "http"));
 }