public static string SerializeClientObjects(World world) { var saveData = new ClientSaveData() { Objects = world.Objects.ToArray(), }; Trace.TraceInformation("Saving client data"); var watch = Stopwatch.StartNew(); string data; using (var stream = new System.IO.MemoryStream()) { using (var serializer = new Dwarrowdelf.SaveGameSerializer(stream, new[] { new ClientObjectRefResolver(world) })) { serializer.Serialize(saveData); stream.Position = 0; using (StreamReader reader = new StreamReader(stream)) data = reader.ReadToEnd(); } } watch.Stop(); Trace.TraceInformation("Saving client data took {0}", watch.Elapsed); return(data); }
public static void Save(World world, Guid id) { var saveData = new ClientSaveData() { Objects = world.Objects.ToArray(), }; Trace.TraceInformation("Saving client data"); var watch = Stopwatch.StartNew(); string data; using (var stream = new System.IO.MemoryStream()) { using (var serializer = new Dwarrowdelf.SaveGameSerializer(stream, new[] { new ClientObjectRefResolver(world) })) { serializer.Serialize(saveData); stream.Position = 0; using (StreamReader reader = new StreamReader(stream)) data = reader.ReadToEnd(); } } watch.Stop(); Trace.TraceInformation("Saving client data took {0}", watch.Elapsed); var msg = new Messages.SaveClientDataReplyMessage() { ID = id, Data = data }; GameData.Data.User.Send(msg); if (SaveEvent != null) SaveEvent(); }
public static string SerializeClientObjects(World world) { var saveData = new ClientSaveData() { Objects = world.Objects.ToArray(), }; Trace.TraceInformation("Saving client data"); var watch = Stopwatch.StartNew(); string data; using (var stream = new System.IO.MemoryStream()) { using (var serializer = new Dwarrowdelf.SaveGameSerializer(stream, new[] { new ClientObjectRefResolver(world) })) { serializer.Serialize(saveData); stream.Position = 0; using (StreamReader reader = new StreamReader(stream)) data = reader.ReadToEnd(); } } watch.Stop(); Trace.TraceInformation("Saving client data took {0}", watch.Elapsed); return data; }