public void AddMemento(PlayerMemento playerMemento)
        {
            if(playerMemento == null)
            {
                throw new ArgumentNullException("playerMemento");
            }

            this.PlayerStorage.Add(playerMemento);
        }
Example #2
0
        public void AddMemento(PlayerMemento playerMemento)
        {
            if (playerMemento == null)
            {
                throw new ArgumentNullException("playerMemento");
            }

            this.PlayerStorage.Add(playerMemento);
        }
        /// <summary>
        /// Add the players.
        /// </summary>
        /// <param name="player">The players.</param>
        public void Add(PlayerMemento player)
        {
            using (FileStream fileStream = new FileStream(this.Filename, FileMode.OpenOrCreate))
            {
                fileStream.Position = fileStream.Length;
                var writer = new StreamWriter(fileStream);
                writer.AutoFlush = true;

                writer.WriteLine(string.Format("{0};{1}", player.Name, player.Score));
            }
        }
Example #4
0
        public PlayerMemento StoreToMemento()
        {
            var memento = new PlayerMemento(this.Name, this.Score);

            return(memento);
        }
Example #5
0
 public void RestoreFromMemento(PlayerMemento memento)
 {
     this.Name  = memento.Name;
     this.Score = memento.Score;
 }
        /// <summary>
        /// The store player to memento.
        /// </summary>
        /// <returns>The <see cref="PlayerMemento"/>.</returns>
        public PlayerMemento StoreToMemento()
        {
            var memento = new PlayerMemento(this.Name, this.Score);

            return memento;
        }
 /// <summary>
 /// The restore player from memento.
 /// </summary>
 /// <param name="memento">The memento.</param>
 public void RestoreFromMemento(PlayerMemento memento)
 {
     this.Name = memento.Name;
     this.Score = memento.Score;
 }