public bool Write(StreamWriter writer, Game game) { var writerText = new SaveWriterTextSection("game", 0); game.WriteTo(writerText); return(writerText.Write(writer)); }
public override SaveWriterText AddSection(string subName, uint subNumber) { var section = new SaveWriterTextSection(subName, subNumber); sections.Add(section); return(section); }
/* Generic save/load function that will try to detect the right * format on load and save to the best format on write. */ public bool Save(string path, Game game) { path = path.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar); path = path.ReplaceInvalidPathChars('_'); var writer = new SaveWriterTextSection("game", 0); game.WriteTo(writer); try { bool success = writer.Save(path); LastOperationResult = success ? LastOperationStatus.SaveSuccess : LastOperationStatus.SaveFail; return(success); } catch { LastOperationResult = LastOperationStatus.SaveFail; throw; } }