예제 #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);
     }
 }
예제 #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();
        }
예제 #3
0
 public Task<string> AsyncSerializeToString(Diagram diagram)
 {
     return Task.Run(() => SerializeToString(diagram));
 }
예제 #4
0
 public async void save(Diagram diagram, String path)
 {
     await Task.Run(() => SerializeToFile(diagram, path));
 }