Esempio n. 1
0
 private void SerializeToFile(Diagram diagram, String path)
 {
     using (FileStream stream = File.Create(path)) {
         XmlSerializer serializer = new XmlSerializer(typeof(Diagram));
         serializer.Serialize(stream, diagram);
     }
 }
Esempio n. 2
0
        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();
        }
Esempio n. 3
0
 public Task<string> AsyncSerializeToString(Diagram diagram)
 {
     return Task.Run(() => SerializeToString(diagram));
 }
Esempio n. 4
0
 public async void save(Diagram diagram, String path)
 {
     await Task.Run(() => SerializeToFile(diagram, path));
 }