public void LoadMetaFromFile(string inputFileName)
{
// write memorysteam of meta to file
FileStream FS = new FileStream(inputFileName, FileMode.Open);
BinaryReader BR = new BinaryReader(FS);
this.size = (int)FS.Length;
this.MS = new MemoryStream(this.size);
BR.BaseStream.Position = 0;
this.MS.Write(BR.ReadBytes(this.size), 0, this.size);
BR.Close();
FS.Close();
// write idents,strings,reflexives
XmlTextReader xtr = new XmlTextReader(inputFileName + ".xml");
xtr.WhitespaceHandling = WhitespaceHandling.None;
while (xtr.Read())
{
// MessageBox.Show(xtr.Name);
switch (xtr.NodeType)
{
case XmlNodeType.Element:
if (xtr.Name == "Meta")
{
this.type = xtr.GetAttribute("TagType");
this.name = xtr.GetAttribute("TagName");
this.parsed = xtr.GetAttribute("Parsed") == "True" ? true : false;
this.size = Convert.ToInt32(xtr.GetAttribute("Size"));
this.magic = Convert.ToInt32(xtr.GetAttribute("Magic"));
this.padding = Convert.ToChar(xtr.GetAttribute("Padding"));
this.offset = Convert.ToInt32(xtr.GetAttribute("Offset"));
}
else if (xtr.Name == "Reflexive")
{
Reflexive r = new Reflexive();
r.description = xtr.GetAttribute("Description");
r.offset = Convert.ToInt32(xtr.GetAttribute("Offset"));
r.chunkcount = Convert.ToInt32(xtr.GetAttribute("ChunkCount"));
r.chunksize = Convert.ToInt32(xtr.GetAttribute("ChunkSize"));
r.translation = Convert.ToInt32(xtr.GetAttribute("Translation"));
r.pointstotagtype = xtr.GetAttribute("PointsToTagType");
r.pointstotagname = xtr.GetAttribute("PointsToTagName");
r.pointstoTagIndex = Map.Functions.ForMeta.FindByNameAndTagType(
r.pointstotagtype, r.pointstotagname);
r.intagtype = xtr.GetAttribute("TagType");
r.intagname = xtr.GetAttribute("TagName");
r.intag = Map.Functions.ForMeta.FindByNameAndTagType(r.intagtype, r.intagname);
this.items.Add(r);
}
else if (xtr.Name == "Ident")
{
Ident id = new Ident();
id.description = xtr.GetAttribute("Description");
id.offset = Convert.ToInt32(xtr.GetAttribute("Offset"));
id.pointstotagtype = xtr.GetAttribute("PointsToTagType");
id.pointstotagname = xtr.GetAttribute("PointsToTagName");
id.pointstoTagIndex = Map.Functions.ForMeta.FindByNameAndTagType(
id.pointstotagtype, id.pointstotagname);
id.intagtype = xtr.GetAttribute("TagType");
id.intagname = xtr.GetAttribute("TagName");
id.intag = Map.Functions.ForMeta.FindByNameAndTagType(id.intagtype, id.intagname);
this.items.Add(id);
}
else if (xtr.Name == "String")
{
String s = new String();
s.description = xtr.GetAttribute("Description");
s.offset = Convert.ToInt32(xtr.GetAttribute("Offset"));
s.name = xtr.GetAttribute("StringName");
s.intagtype = xtr.GetAttribute("TagType");
s.intagname = xtr.GetAttribute("TagName");
s.intag = Map.Functions.ForMeta.FindByNameAndTagType(s.intagtype, s.intagname);
this.items.Add(s);
}
break;
default:
break;
}
}
xtr.Close();
//
///check for raw
this.rawType = Map.Functions.ForMeta.CheckForRaw(this.type);
if (this.rawType != RawDataContainerType.Empty)
{
this.raw = new RawDataContainer();
this.raw = this.raw.LoadRawFromFile(inputFileName, this);
}
}