public static void Import(GameStorage storage, Stream stream) { var serializer = new JsonSerializer(); serializer.TypeNameHandling = TypeNameHandling.Auto; using (var json = new JsonTextReader(new StreamReader(stream))) { var export = serializer.Deserialize<JsonExportHolder>(json); foreach (var ply in export.Players) storage.RecordPlayer(ply, true); foreach (var end in export.EndStats) storage.RecordGame(end); storage.Commit(); } }
public static void Import(GameStorage storage, Stream stream) { var serializer = new JsonSerializer(); serializer.TypeNameHandling = TypeNameHandling.Auto; using (var json = new JsonTextReader(new StreamReader(stream))) { var export = serializer.Deserialize <JsonExportHolder>(json); foreach (var ply in export.Players) { storage.RecordPlayer(ply, true); } foreach (var end in export.EndStats) { storage.RecordGame(end); } storage.Commit(); } }