private void SerializeToFile(Diagram diagram, string path) { using (FileStream stream = File.Create(path)) { XmlSerializer serializer = new XmlSerializer(typeof(Diagram)); serializer.Serialize(stream, diagram); } }
//commandd to save diagram private void SaveDiagram() { string path = dialogVM.ShowSave(); if (path != null) { Diagram diagram = new Diagram() { Nodes = Nodes.Select(n => n.Node).ToList(), Lines = Lines.Select(l => l.Line).ToList() }; XMLserializer.Instance.AsyncSerializeToFile(diagram, path); } }
public async void AsyncSerializeToFile(Diagram diagram, string path) { await Task.Run(() => SerializeToFile(diagram, path)); }