Geowigo.Models.CartridgeTag.AddSavegame C# (CSharp) Method

AddSavegame() public method

Exports a savegame to the isolated storage and adds it to this tag.
public AddSavegame ( CartridgeSavegame cs ) : void
cs CartridgeSavegame The savegame to add.
return void
        public void AddSavegame(CartridgeSavegame cs)
        {
            // Sanity check: a savegame with similar name should
            // not exist.
            if (Savegames.Any(c => c.Name == cs.Name))
            {
				System.Diagnostics.Debug.WriteLine("CartridgeTag: Renaming new savegame because an old one with same name exists: " + cs.Name);
				
				// What's the last savegame following the pattern "name (n)"?
                int dbl = GetLastSavegameNameInteger(cs.Name, " ({0})");

                // Renames the savegame.
                using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())
                {
                    cs.Rename(this, cs.Name + " (" + ++dbl + ")", isf);
                }
            }
            
            // Makes sure the savegame is exported to the cache.
            cs.ExportToIsoStore();
            
            // Adds the savegame.
            _savegames.Add(cs);

            // Notifies of a change.
            RaisePropertyChanged("Savegames");
        }