예제 #1
0
 /// <summary>
 /// Returns true if the repository containsthe provided <see cref="Fav"/>
 /// </summary>
 /// <param name="target"><see cref="Fav"/> to find ; cannot be null</param>
 /// <exception cref="ArgumentNullException"> when the parameter is null</exception>
 /// <returns>true if the repository a matching <see cref="Fav"/>, false otherwise</returns>
 public bool Contains(Fav target)
 {
     if (target == null)
     {
         throw new ArgumentNullException();
     }
     return(this.favs.Where(fav => fav.Name == target.Name && fav.Uri.AbsoluteUri == target.Uri.AbsoluteUri).Any());
 }
예제 #2
0
 /// <summary>
 /// Return a <see cref="Fav"/> matching the provided one, or null if no record was found
 /// </summary>
 /// <param name="target"><see cref="Fav"/> to find ; cannot be null</param>
 /// <exception cref="ArgumentNullException"> when the parameter is null</exception>
 /// <returns>Matching <see cref="Fav"/> or null</returns>
 public Fav Find(Fav target)
 {
     if (target == null)
     {
         throw new ArgumentNullException();
     }
     return(this.Contains(target) ? this.favs.Where(fav => fav.Name == target.Name && fav.Uri.AbsoluteUri == target.Uri.AbsoluteUri).Single() : null);
 }
예제 #3
0
 /// <summary>
 /// Adds a new <see cref="Fav"/> to the favorites repository
 /// Throws a <see cref="FavAlreadyExistsException"/> if the provided <see cref="Fav"/> already exists in the respository
 /// </summary>
 /// <exception cref="FavAlreadyExistsException"/>
 /// <exception cref="ArgumentNullException"> when the parameter is null</exception>
 /// <param name="fav"><see cref="Fav"/> to add to the repository ; cannot be null</param>
 public void Add(Fav fav)
 {
     if (fav == null)
     {
         throw new ArgumentNullException();
     }
     if (this.Contains(fav))
     {
         throw new FavAlreadyExistsException();
     }
     this.favs.Add(fav);
 }
예제 #4
0
 /// <summary>
 /// Removes a <see cref="Fav"/> from the repository
 /// Throws a <see cref="FavDoesntExistException"/> if the provided <see cref="Fav"/> doesn't exist in the repository
 /// </summary>
 /// <exception cref="FavDoesntExistException"/>
 /// <param name="fav"><see cref="Fav"/> to remove ; cannot be null</param>
 /// <exception cref="ArgumentNullException"> when the parameter is null</exception>
 public void Remove(Fav fav)
 {
     if (fav == null)
     {
         throw new ArgumentNullException();
     }
     if (!this.Contains(fav))
     {
         throw new FavDoesntExistException();
     }
     this.favs.Remove(fav);
 }