コード例 #1
0
        public void AddMemento(PlayerMemento playerMemento)
        {
            if(playerMemento == null)
            {
                throw new ArgumentNullException("playerMemento");
            }

            this.PlayerStorage.Add(playerMemento);
        }
コード例 #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));
            }
        }
コード例 #4
0
        public PlayerMemento StoreToMemento()
        {
            var memento = new PlayerMemento(this.Name, this.Score);

            return(memento);
        }
コード例 #5
0
 public void RestoreFromMemento(PlayerMemento memento)
 {
     this.Name  = memento.Name;
     this.Score = memento.Score;
 }
コード例 #6
0
        /// <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;
        }
コード例 #7
0
 /// <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;
 }