Roblox-File-Format/Tokens/Float.cs

25 lines
839 B
C#
Raw 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 FloatToken : IXmlPropertyToken, IAttributeToken<float>
{
2021-02-25 20:09:54 +00:00
public string XmlPropertyToken => "float";
public AttributeType AttributeType => AttributeType.Float;
public float ReadAttribute(Attribute attr) => attr.ReadFloat();
public void WriteAttribute(Attribute attr, float value) => attr.WriteFloat(value);
public bool ReadProperty(Property prop, XmlNode token)
{
return XmlPropertyTokens.ReadPropertyGeneric<float>(prop, PropertyType.Float, token);
}
public void WriteProperty(Property prop, XmlDocument doc, XmlNode node)
{
float value = prop.CastValue<float>();
node.InnerText = value.ToInvariantString();
}
}
}