Roblox-File-Format/XmlFormat/PropertyTokens/Tokens/Ref.cs
CloneTrooper1019 47112242e7 Added write support for binary files!
Holy cow, this took a lot of work. I think I may need to do a few more
things before I consider this a 1.0 release, but I'm glad to have
finally overcome this hurdle!
2019-06-07 22:43:28 -05:00

32 lines
768 B
C#

using System.Xml;
namespace RobloxFiles.XmlFormat.PropertyTokens
{
public class RefToken : IXmlPropertyToken
{
public string Token => "Ref";
public bool ReadProperty(Property prop, XmlNode token)
{
string refId = token.InnerText;
prop.Type = PropertyType.Ref;
prop.Value = refId;
return true;
}
public void WriteProperty(Property prop, XmlDocument doc, XmlNode node)
{
string result = "null";
if (prop.Value != null && prop.Value.ToString() != "null")
{
Instance inst = prop.Value as Instance;
result = inst.Referent;
}
node.InnerText = result;
}
}
}