public static TileLoadResult Load(System.IO.Stream fromStream, out TileAnimation ani) { ani = null; try { var xml = new XmlSerializer(typeof(TileAnimation)); var streams = BlubbZipHelper.ExtractBlubbZip(fromStream, ""); if (streams.Count == 0) { return(TileLoadResult.NoEntryInArchiv); } foreach (var key in streams.Keys.Where(key => streams[key] != null && streams[key].Length != 0 && streams[key].CanSeek && streams[key].CanRead)) { streams[key].Seek(0, System.IO.SeekOrigin.Begin); ani = xml.Deserialize(streams[key]) as TileAnimation; streams[key].Dispose(); } } catch (Exception e) { ani = null; System.Diagnostics.Debug.WriteLine(e); return(TileLoadResult.UnkownError); } return(TileLoadResult.Success); }
public void Save(System.IO.Stream stream, string filename) { try { var xml = new XmlSerializer(typeof(TileAnimation)); using (System.IO.Stream xmlStream = new System.IO.MemoryStream()) { xml.Serialize(xmlStream, this); BlubbZipHelper.CreateBlubbZip(stream, "", filename, xmlStream); } } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e); } }