Roblox-File-Format/Tokens/Boolean.cs
2021-02-25 14:09:54 -06:00

29 lines
864 B
C#

using System.Xml;
using RobloxFiles.XmlFormat;
namespace RobloxFiles.Tokens
{
public class BoolToken : IXmlPropertyToken, IAttributeToken<bool>
{
public string XmlPropertyToken => "bool";
public AttributeType AttributeType => AttributeType.Bool;
public bool ReadAttribute(Attribute attr) => attr.ReadBool();
public void WriteAttribute(Attribute attr, bool value) => attr.WriteBool(value);
public bool ReadProperty(Property prop, XmlNode token)
{
return XmlPropertyTokens.ReadPropertyGeneric<bool>(prop, PropertyType.Bool, token);
}
public void WriteProperty(Property prop, XmlDocument doc, XmlNode node)
{
string boolString = prop.Value
.ToString()
.ToLower();
node.InnerText = boolString;
}
}
}