diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2018-08-06 09:19:53 +0300 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2018-08-06 09:19:53 +0300 |
| commit | cd22de677cf942c8bf82c8bbb6e02ee5630076eb (patch) | |
| tree | 5fde4c94370c174e4aac3f06cf89dbb09e51b9a8 /Software/Visual_Studio/Tango.SQLExaminer/ExaminerSerializedObject.cs | |
| parent | 4fb8ff57dcd3bce39ac54d4c52cef091df8c570b (diff) | |
| download | Tango-cd22de677cf942c8bf82c8bbb6e02ee5630076eb.tar.gz Tango-cd22de677cf942c8bf82c8bbb6e02ee5630076eb.zip | |
Working on SQL Examiner Reports Loading..
Diffstat (limited to 'Software/Visual_Studio/Tango.SQLExaminer/ExaminerSerializedObject.cs')
| -rw-r--r-- | Software/Visual_Studio/Tango.SQLExaminer/ExaminerSerializedObject.cs | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Tango.SQLExaminer/ExaminerSerializedObject.cs b/Software/Visual_Studio/Tango.SQLExaminer/ExaminerSerializedObject.cs new file mode 100644 index 000000000..7416ee29a --- /dev/null +++ b/Software/Visual_Studio/Tango.SQLExaminer/ExaminerSerializedObject.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Serialization; + +namespace Tango.SQLExaminer +{ + public abstract class ExaminerSerializedObject<T> where T : class + { + public static T FromFile(String filePath) + { + return FromString(File.ReadAllText(filePath)); + } + + public static T FromString(String xml) + { + XmlSerializer f = new XmlSerializer(typeof(T), ""); + + T config = null; + + using (var reader = new StringReader(xml)) + { + config = f.Deserialize(reader) as T; + } + + return config; + } + + public void ToFile(String filePath) + { + File.WriteAllText(filePath, ToXml(), Encoding.Unicode); + } + + public String ToXml() + { + XmlSerializerNamespaces ns = new XmlSerializerNamespaces(); + ns.Add("", ""); + + XmlSerializer f = new XmlSerializer(typeof(T), ""); + + String result = String.Empty; + + using (var st = new StringWriter()) + { + f.Serialize(st, this, ns); + result = st.ToString(); + } + + return result; + } + } +} |
