Beispiel #1
0
        public void AddPlayer(Readable_GamePlayer player)
        {
            WriteControlled_Item <Readable_GamePlayer, Writable_GamePlayer> playerPair = new WriteControlled_Item <Readable_GamePlayer, Writable_GamePlayer>(new PlayerConverter());

            playerPair.PutReadonly(player);
            this.players.PutReadonly(player);
            this.TurnOrder.AddLast(player.GetID((Readable_GamePlayer)null));
        }
        // Simulates a deep copy of the underlying writable object (because that doesn't happen until explicitly requested later)
        public WriteControlled_Item <TReadable, TWritable> Clone()
        {
            WriteControlled_Item <TReadable, TWritable> clone = new WriteControlled_Item <TReadable, TWritable>(this.converter);

            // use the same reference as the readable value for both this item and the clone
            this.readonlyItem = clone.GetReadable();
            // record that this is the same reference and that neither may modify the shared object
            this.Revoke_WriteAccess();
            return(clone);
        }