Roblox-File-Format/Tokens/Faces.cs

40 lines
1013 B
C#
Raw Normal View History

2020-08-17 05:33:59 +00:00
using System.Diagnostics.Contracts;
using System.Xml;
2021-02-25 20:09:54 +00:00
using RobloxFiles.DataTypes;
2021-02-25 20:09:54 +00:00
using RobloxFiles.XmlFormat;
2021-02-25 20:09:54 +00:00
namespace RobloxFiles.Tokens
{
public class FacesToken : IXmlPropertyToken
{
2021-02-25 20:09:54 +00:00
public string XmlPropertyToken => "Faces";
public bool ReadProperty(Property prop, XmlNode token)
{
2020-08-17 05:33:59 +00:00
Contract.Requires(prop != null);
2020-08-17 05:33:59 +00:00
if (XmlPropertyTokens.ReadPropertyGeneric(token, out uint value))
{
Faces faces = (Faces)value;
prop.Value = faces;
return true;
}
return false;
}
public void WriteProperty(Property prop, XmlDocument doc, XmlNode node)
{
2020-08-17 05:33:59 +00:00
Contract.Requires(prop != null && doc != null && node != null);
XmlElement faces = doc.CreateElement("faces");
node.AppendChild(faces);
int value = prop.CastValue<int>();
faces.InnerText = value.ToInvariantString();
}
}
}