2019-06-30 22:01:19 +00:00
|
|
|
|
using System.Xml;
|
|
|
|
|
using RobloxFiles.DataTypes;
|
2019-05-17 06:14:04 +00:00
|
|
|
|
|
|
|
|
|
namespace RobloxFiles.XmlFormat.PropertyTokens
|
|
|
|
|
{
|
|
|
|
|
public class SharedStringToken : IXmlPropertyToken
|
|
|
|
|
{
|
|
|
|
|
public string Token => "SharedString";
|
|
|
|
|
|
2019-05-17 12:08:06 +00:00
|
|
|
|
public bool ReadProperty(Property prop, XmlNode token)
|
2019-05-17 06:14:04 +00:00
|
|
|
|
{
|
2020-07-13 01:19:30 +00:00
|
|
|
|
string key = token.InnerText;
|
2019-05-17 06:14:04 +00:00
|
|
|
|
prop.Type = PropertyType.SharedString;
|
2020-07-13 01:19:30 +00:00
|
|
|
|
prop.Value = new SharedString(key);
|
2019-05-17 06:14:04 +00:00
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2019-05-17 12:08:06 +00:00
|
|
|
|
|
|
|
|
|
public void WriteProperty(Property prop, XmlDocument doc, XmlNode node)
|
|
|
|
|
{
|
2020-08-18 01:12:24 +00:00
|
|
|
|
var value = prop.Value as SharedString;
|
2020-07-13 01:19:30 +00:00
|
|
|
|
|
2020-08-18 01:12:24 +00:00
|
|
|
|
if (value != null)
|
2020-07-13 01:19:30 +00:00
|
|
|
|
{
|
2020-08-18 01:12:24 +00:00
|
|
|
|
string key = value.Key;
|
|
|
|
|
|
|
|
|
|
if (value.ComputedKey == null)
|
|
|
|
|
{
|
|
|
|
|
var newShared = SharedString.FromBuffer(value.SharedValue);
|
|
|
|
|
key = newShared.ComputedKey;
|
|
|
|
|
}
|
2020-07-13 01:19:30 +00:00
|
|
|
|
|
2020-08-18 01:12:24 +00:00
|
|
|
|
node.InnerText = key;
|
|
|
|
|
}
|
2019-05-17 12:08:06 +00:00
|
|
|
|
}
|
2019-05-17 06:14:04 +00:00
|
|
|
|
}
|
|
|
|
|
}
|