public static void LoadPhotoUrl(Photo photo){ if (photo.PhotoBytes == null) { var url = photo.PhotoUrl; var request = HttpWebRequest.Create (url); var ms = new MemoryStream (); locker.WaitOne (); using (var stream = ((HttpWebResponse)request.GetResponse ()).GetResponseStream ()) { var bytes = new byte[256]; int read; while ((read = stream.Read (bytes, 0, bytes.Length)) > 0) { ms.Write (bytes, 0, read); } } locker.Release (); photo.PhotoBytes = ms.ToArray (); } }
public void RemoveFavorite (Photo photo) { if (Favorites.Any (p => p.PhotoID == photo.PhotoID)) { Favorites.Remove (photo); } }
public void AddFavorite (Photo photo) { if (!Favorites.Any (p => p.PhotoID == photo.PhotoID)) { Favorites.Add (photo); } }