Roblox-File-Format/Tokens/Boolean.cs

29 lines
870 B
C#
Raw Permalink Normal View History

using System.Xml;
2021-02-25 20:09:54 +00:00
using RobloxFiles.XmlFormat;
2021-02-25 20:09:54 +00:00
namespace RobloxFiles.Tokens
{
2021-02-25 20:09:54 +00:00
public class BoolToken : IXmlPropertyToken, IAttributeToken<bool>
{
2021-02-25 20:09:54 +00:00
public string XmlPropertyToken => "bool";
public AttributeType AttributeType => AttributeType.Bool;
2021-06-05 22:21:12 +00:00
public bool ReadAttribute(RbxAttribute attr) => attr.ReadBool();
public void WriteAttribute(RbxAttribute 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;
}
}
}