static public OldCatanGame Deserialize(string savedGame) { OldCatanGame game = new OldCatanGame(); game.Serializing = true; Dictionary <string, string> sections = null; try { sections = StaticHelpers.GetSections(savedGame); if (sections == null) { game.Error = String.Format($"Error parsing the file into sections.\nThere are no sections. Please load a valid .catangame file."); return(game); } } catch (Exception e) { game.Error = e.Message; return(game); } StaticHelpers.DeserializeObject <OldCatanGame>(game, sections["View"], false); for (int groupCount = 0; groupCount < game.GroupCount; groupCount++) { TileGroup tg = new TileGroup(); string tgAsString = sections[$"TileGroup {groupCount}"]; tg.Deserialize(tgAsString, sections, groupCount); game.TileGroups.Add(tg); } game.Serializing = false; return(game); }
public bool Deserialize(string s) { Dictionary <string, string> sections = StaticHelpers.GetSections(s); StaticHelpers.DeserializeObject <Settings>(this, sections["Settings"], "=", StaticHelpers.lineSeperator); string[] positions = sections["GridPositions"].Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries); GridPositions.Clear(); foreach (string line in positions) { GridPosition gp = new GridPosition(line); GridPositions.Add(gp); } return(true); }
// // this only deserializes the [View] section of the file, and in particular doesn't create any XAML objects.. public bool FastDeserialize(string savedGame) { this.Serializing = true; try { this.Sections = StaticHelpers.GetSections(savedGame); if (this.Sections == null) { this.Error = String.Format($"Error parsing the file into sections.\nThere are no sections. Please load a valid .catangame file."); return(false); } } catch (Exception e) { this.Error = e.Message; return(false); } StaticHelpers.DeserializeObject <OldCatanGame>(this, this.Sections["View"], false); this.Serializing = false; return(true); }
public bool Deserialize(string s, Deck deck) { Dictionary <string, string> sections = StaticHelpers.GetSections(s); return(Deserialize(sections, deck)); }