-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLuaConverter.cs
More file actions
38 lines (34 loc) · 1.26 KB
/
LuaConverter.cs
File metadata and controls
38 lines (34 loc) · 1.26 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
using System.IO;
using System.Xml.Serialization;
using XmlToLuaTableConverter.Data;
using XmlToLuaTableConverter.Interface;
namespace XmlToLuaTableConverter
{
class LuaConverter : ILuaConverter
{
public DkpEntryObject[] ReadXmlFile(string xmlFileName)
{
DkpTableObject dkpTableObject;
using (TextReader reader = new StreamReader(xmlFileName))
{
XmlSerializer serializer = new XmlSerializer(typeof(DkpTableObject));
dkpTableObject = (DkpTableObject)serializer.Deserialize(reader);
}
return dkpTableObject.dkpEntryObjects;
}
public bool WriteLuaTableFile(DkpEntryObject[] dkpEntryArray, string luaFileName)
{
string luaString = LuaWriter.writeDkpTableStartEntry();
int count = 1;
foreach (DkpEntryObject dkpEntryobject in dkpEntryArray)
{
luaString += LuaWriter.writeStartEntry();
luaString += dkpEntryobject.WriteLuaString();
luaString += LuaWriter.writeEndEntry(count++);
}
luaString += LuaWriter.writeDkpTableEndEntry();
File.WriteAllText(luaFileName, luaString);
return true;
}
}
}