Beispiel #1
0
 public void MoveAllCardsTo(CardCollectionBase collection)
 {
     // TODO: add check for move to self
     while (this.Cards.Count > 0)
     {
         this.Cards.First.Value.moveTo(collection);
     }
 }
 /// <summary>
 /// moves the current Card to the specified collection
 /// </summary>
 /// <param name="collection">the targeted collection</param>
 /// <param name="position">position at which the card should be inserted</param>
 public void moveTo(CardCollectionBase collection, int position)
 {
     if (this.collection != null)
     {
         this.collection.PerformMoveFrom();
         this.collection.RemoveCard(this);
         this.collection.PerformMovedFrom();
     }
     collection.PerformMoveTo();
     this.collection = collection;
     this.collection.AddCard(this, position);
     this.collection.PerformMovedTo();
 }
        // Initializer
        private void Init(T type, CardCollectionBase collection)
        {
            if (type is null)
            {
                throw new ArgumentNullException("type");
            }
            if (collection is null)
            {
                throw new ArgumentNullException("collection");
            }

            this.Type = type;
            this.moveTo(collection);
        }
 public void moveTo(CardCollectionBase collection)
 {
     this.moveTo(collection, 0);
 }
 /// <summary>
 /// Generates a new Card with a given type
 /// </summary>
 /// <param name="name">name of the new card</param>
 /// <param name="type">type of the new card</param>
 public Card(T type, CardCollectionBase collection)
 {
     Init(type, collection);
 }