private void SerializeToFile(Diagram diagram, String path) { using (FileStream stream = File.Create(path)) { XmlSerializer serializer = new XmlSerializer(typeof(Diagram)); serializer.Serialize(stream, diagram); } }
private string SerializeToString(Diagram diagram) { var stringBuilder = new StringBuilder(); using (TextWriter stream = new StringWriter(stringBuilder)) { XmlSerializer serializer = new XmlSerializer(typeof(Diagram)); serializer.Serialize(stream, diagram); } return stringBuilder.ToString(); }
public Task<string> AsyncSerializeToString(Diagram diagram) { return Task.Run(() => SerializeToString(diagram)); }
public async void save(Diagram diagram, String path) { await Task.Run(() => SerializeToFile(diagram, path)); }