public Task Save(Stream stream, Map map) { return(Task.Factory.StartNew(() => { var list = new List <SerialisedObject> { _factory.Serialise(map.Root) }; list.AddRange(map.Data.Select(_factory.Serialise).Where(x => x != null)); _formatter.Serialize(stream, list); })); }
public void Write(Stream stream, MapFile map, string styleHint) { var list = new List <SerialisedObject>(); list.AddRange(map.AdditionalObjects); var visObj = new SerialisedObject("visgroups"); SaveVisgroups(map.Visgroups, visObj); list.Add(visObj); SaveWorld(map, list); SaveCameras(map, list); _formatter.Serialize(stream, list); }
private string CreateCopyStream(IEnumerable <IMapObject> copiedObjects) { var clip = new SerialisedObject(SerialisedName); foreach (var obj in copiedObjects) { var so = _factory.Serialise(obj); clip.Children.Add(so); } using (var ms = new MemoryStream()) { _formatter.Serialize(ms, clip); ms.Position = 0; using (var sr = new StreamReader(ms)) { return(sr.ReadToEnd()); } } }