-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathIO.cs
More file actions
57 lines (47 loc) · 1.59 KB
/
IO.cs
File metadata and controls
57 lines (47 loc) · 1.59 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
46
47
48
49
50
51
52
53
54
55
56
57
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Xml;
using System.Xml.Serialization;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Drawing;
namespace CustomActorToolkit
{
static class IO
{
public static void Export<T>(T Object, string Filename)
{
XmlWriterSettings XWS = new XmlWriterSettings();
XWS.NewLineChars = Environment.NewLine;
XWS.Indent = true;
XmlSerializer XS = new XmlSerializer(Object.GetType());
StreamWriter SW = new StreamWriter(Filename);
XmlWriter XW = XmlWriter.Create(SW, XWS);
XW.WriteStartDocument();
XW.WriteComment("Created with Custom Actor Toolkit");
XS.Serialize(XW, Object);
XW.WriteEndDocument();
XW.Flush();
SW.Close();
}
public static T Import<T>(string Filename)
{
XmlSerializer XS = new XmlSerializer(typeof(T));
StreamReader SR = new StreamReader(Filename);
var ret = (T)XS.Deserialize(SR);
SR.Close();
return ret;
}
/*
public static void BinExport<T>(T Object, string Filename)
{
Stream stream = File.Open(Filename, FileMode.Create);
BinaryFormatter bFormatter = new BinaryFormatter();
bFormatter.Serialize(stream, Object);
stream.Close();
}*/
}
}