/// <summary> /// Exports a savegame to the isolated storage and adds it to this tag. /// </summary> /// <param name="cs">The savegame to add.</param> 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"); }
/// <summary> /// Exports a savegame to the isolated storage and adds it to this tag if it is not already there. /// </summary> /// <param name="cs"></param> public void RefreshOrAddSavegame(CartridgeSavegame cs) { if (_savegames.Contains(cs)) { // Refresh cs.ExportToIsoStore(); // Notifies of a change. RaisePropertyChanged("Savegames"); } else { AddSavegame(cs); } }
/// <summary> /// Exports a savegame to the isolated storage and adds it to this tag if it is not already there. /// </summary> /// <param name="cs"></param> public void RefreshOrAddSavegame(CartridgeSavegame cs) { if (_savegames.Contains(cs)) { // Refresh cs.ExportToIsoStore(); // Notifies of a change. RaisePropertyChanged("Savegames"); } else { AddSavegame(cs); } }
/// <summary> /// Exports a savegame to the isolated storage and adds it to this tag. /// </summary> /// <param name="cs">The savegame to add.</param> public void AddSavegame(CartridgeSavegame cs) { // Sanity check: a cartridge with similar name should // not exist. if (Savegames.Any(c => c.Name == cs.Name)) { throw new InvalidOperationException("A savegame with the same name already exists for this savegame."); } // Makes sure the savegame is exported to the cache. cs.ExportToIsoStore(); // Adds the savegame. _savegames.Add(cs); // Notifies of a change. RaisePropertyChanged("Savegames"); }
/// <summary> /// Exports a savegame to the isolated storage and adds it to this tag. /// </summary> /// <param name="cs">The savegame to add.</param> 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"); }