2019-06-30 22:01:19 +00:00
|
|
|
|
using System.Xml;
|
2019-01-30 06:36:56 +00:00
|
|
|
|
|
2021-02-25 20:09:54 +00:00
|
|
|
|
namespace RobloxFiles.Tokens
|
2019-01-30 06:36:56 +00:00
|
|
|
|
{
|
2021-02-25 20:09:54 +00:00
|
|
|
|
public class StringToken : IXmlPropertyToken, IAttributeToken<string>
|
2019-01-30 06:36:56 +00:00
|
|
|
|
{
|
2021-02-25 20:09:54 +00:00
|
|
|
|
public string XmlPropertyToken => "string";
|
|
|
|
|
public AttributeType AttributeType => AttributeType.String;
|
|
|
|
|
|
|
|
|
|
public string ReadAttribute(Attribute attr) => attr.ReadString();
|
|
|
|
|
public void WriteAttribute(Attribute attr, string value) => attr.WriteString(value);
|
2019-01-30 06:36:56 +00:00
|
|
|
|
|
2019-05-17 12:08:06 +00:00
|
|
|
|
public bool ReadProperty(Property prop, XmlNode token)
|
2019-01-30 06:36:56 +00:00
|
|
|
|
{
|
|
|
|
|
string contents = token.InnerText;
|
|
|
|
|
prop.Type = PropertyType.String;
|
|
|
|
|
prop.Value = contents;
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2019-05-17 12:08:06 +00:00
|
|
|
|
|
|
|
|
|
public void WriteProperty(Property prop, XmlDocument doc, XmlNode node)
|
|
|
|
|
{
|
|
|
|
|
string value = prop.Value.ToInvariantString();
|
|
|
|
|
|
|
|
|
|
if (value.Contains("\r") || value.Contains("\n"))
|
|
|
|
|
{
|
|
|
|
|
XmlCDataSection cdata = doc.CreateCDataSection(value);
|
|
|
|
|
node.AppendChild(cdata);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
node.InnerText = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-01-30 06:36:56 +00:00
|
|
|
|
}
|
|
|
|
|
}
|