public int GetVerificationHash() { string json = SerializationHelpers.Serialize(GetRawSnapshot(), RequiredConverters.GetConverters(), RequiredConverters.GetContextObjects(Maybe <GameEngine> .Empty)); return(json.GetHashCode()); }
/// <summary> /// Restores a GameSnapshot using the given GameSnapshot JSON and the given TemplateGroup /// JSON. /// </summary> public static GameSnapshotRestorer Restore(string snapshotJson, string templateJson, Maybe <GameEngine> gameEngine) { string json = CombineJson(snapshotJson, templateJson); return(SerializationHelpers.Deserialize <GameSnapshotRestorer>(json, RequiredConverters.GetConverters(), RequiredConverters.GetContextObjects(gameEngine))); }
public IGameSnapshot TakeSnapshot() { string snapshotJson = SerializationHelpers.Serialize(GetRawSnapshot(), RequiredConverters.GetConverters(), RequiredConverters.GetContextObjects(Maybe <GameEngine> .Empty)); var restored = GameSnapshotRestorer.Restore(snapshotJson, _templateJson, Maybe <GameEngine> .Empty); return(restored.GameSnapshot); }
/// <summary> /// Loads an ITemplateGroup from the given JSON. The JSON should have been generated by /// calling SaveTemplates. /// </summary> /// <exception cref="DeserializationException">An error loading the group /// occurred.</exception> public static ITemplateGroup LoadTemplateGroup(string json) { try { ITemplateGroup group = SerializationHelpers.Deserialize <TemplateGroup>(json, RequiredConverters.GetConverters(), RequiredConverters.GetContextObjects(Maybe <GameEngine> .Empty, new TemplateConversionContext())); return(group); } catch (Exception e) { throw new DeserializationException(json, e); } }
/// <summary> /// Converts a template group to JSON that can be restored later. /// </summary> public static string SaveTemplateGroup(ITemplateGroup templates) { return(SerializationHelpers.Serialize <TemplateGroup>((TemplateGroup)templates, RequiredConverters.GetConverters(), RequiredConverters.GetContextObjects(Maybe <GameEngine> .Empty))); }
/// <summary> /// Converts a game snapshot to JSON that can be restored later. /// </summary> public static string SaveSnapshot(IGameSnapshot snapshot) { return(SerializationHelpers.Serialize <GameSnapshot>((GameSnapshot)snapshot, RequiredConverters.GetConverters(), RequiredConverters.GetContextObjects(Maybe <GameEngine> .Empty))); }