forked from fdorg/flashdevelop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUtilities.cs
More file actions
45 lines (41 loc) · 1.34 KB
/
Utilities.cs
File metadata and controls
45 lines (41 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using System;
using System.IO;
using System.Text;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using System.Xml.Serialization;
using Microsoft.Win32;
namespace FlashDebugger
{
public class Util
{
public class SerializeXML<T>
{
public static void SaveFile(string filename, T obj)
{
XmlSerializer serializer1 = new XmlSerializer(typeof(T));
FileStream fs1 = new FileStream(filename, FileMode.Create);
serializer1.Serialize(fs1, obj);
fs1.Close();
}
public static T LoadFile(string filename)
{
XmlSerializer serializer2 = new XmlSerializer(typeof(T));
FileStream fs2 = new FileStream(filename, FileMode.Open);
T loadClasses = (T)serializer2.Deserialize(fs2);
fs2.Close();
return loadClasses;
}
public static T LoadString(string s)
{
XmlSerializer serializer = new XmlSerializer(typeof(T));
StringReader str = new StringReader(s);
T loadClasses = (T)serializer.Deserialize(str);
str.Close();
return loadClasses;
}
}
}
}