public void Push(Card card, PilePosition position) { if (CardsInPile.Contains(card, CardByRefEqualityComparer.Instance)) { throw new ArgumentException("Given card instance already in pile", nameof(card)); } position.Push(this, card); }
public void Push(IReadOnlyCollection <Card> cards, PilePosition position) { if (!cards.AllUnique(x => x, CardByRefEqualityComparer.Instance)) { throw new ArgumentException("Duplicate instances in given cards", nameof(cards)); } if (CardsInPile.Intersect(cards, CardByRefEqualityComparer.Instance).Any()) { throw new ArgumentException("One of given cards instance already in pile", nameof(cards)); } position.Push(this, cards); }