changeset 231:3eaa9372c754 v2

Added SerializationHelpers.SerializeToFile method
author cin
date Thu, 21 Sep 2017 01:06:32 +0300
parents 5f7a3e1d32b9
children 133ba4444acc
files Implab/Xml/SerializationHelpers.cs
diffstat 1 files changed, 6 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/Implab/Xml/SerializationHelpers.cs	Tue Sep 12 19:07:42 2017 +0300
+++ b/Implab/Xml/SerializationHelpers.cs	Thu Sep 21 01:06:32 2017 +0300
@@ -1,5 +1,6 @@
 using System;
 using System.Collections.Generic;
+using System.IO;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
@@ -32,6 +33,11 @@
             return doc;
         }
 
+        public static void SerializeToFile<T>(string file, T obj) {
+            using (var writer = File.CreateText(file))
+                SerializersPool<T>.Instance.Serialize(writer, obj);
+        }
+
         public static T DeserializeFromString<T>(string data) {
             return SerializersPool<T>.Instance.DeserializeFromString(data);
         }