Optimizations and memory leak fixes
This commit is contained in:
@ -9,9 +9,7 @@ namespace RobloxFiles.XmlFormat.PropertyTokens
|
||||
|
||||
public bool ReadProperty(Property prop, XmlNode token)
|
||||
{
|
||||
uint value;
|
||||
|
||||
if (XmlPropertyTokens.ReadPropertyGeneric(token, out value))
|
||||
if (XmlPropertyTokens.ReadPropertyGeneric(token, out uint value))
|
||||
{
|
||||
Axes axes = (Axes)value;
|
||||
prop.Value = axes;
|
||||
|
@ -13,9 +13,7 @@ namespace RobloxFiles.XmlFormat.PropertyTokens
|
||||
|
||||
public bool ReadProperty(Property prop, XmlNode token)
|
||||
{
|
||||
int value;
|
||||
|
||||
if (XmlPropertyTokens.ReadPropertyGeneric(token, out value))
|
||||
if (XmlPropertyTokens.ReadPropertyGeneric(token, out int value))
|
||||
{
|
||||
BrickColor brickColor = BrickColor.FromNumber(value);
|
||||
prop.XmlToken = "BrickColor";
|
||||
|
@ -1,5 +1,7 @@
|
||||
using System.Xml;
|
||||
using RobloxFiles.DataTypes;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System;
|
||||
|
||||
namespace RobloxFiles.XmlFormat.PropertyTokens
|
||||
{
|
||||
@ -9,9 +11,7 @@ namespace RobloxFiles.XmlFormat.PropertyTokens
|
||||
|
||||
public bool ReadProperty(Property prop, XmlNode token)
|
||||
{
|
||||
uint value;
|
||||
|
||||
if (XmlPropertyTokens.ReadPropertyGeneric(token, out value))
|
||||
if (XmlPropertyTokens.ReadPropertyGeneric(token, out uint value))
|
||||
{
|
||||
uint r = (value >> 16) & 0xFF;
|
||||
uint g = (value >> 8) & 0xFF;
|
||||
@ -28,14 +28,16 @@ namespace RobloxFiles.XmlFormat.PropertyTokens
|
||||
|
||||
public void WriteProperty(Property prop, XmlDocument doc, XmlNode node)
|
||||
{
|
||||
Color3uint8 color = prop.CastValue<Color3uint8>();
|
||||
Color3uint8 color = prop?.CastValue<Color3uint8>();
|
||||
Contract.Requires(node != null);
|
||||
|
||||
|
||||
uint r = color.R,
|
||||
g = color.G,
|
||||
b = color.B;
|
||||
|
||||
uint rgb = (255u << 24) | (r << 16) | (g << 8) | b;
|
||||
node.InnerText = rgb.ToString();
|
||||
node.InnerText = rgb.ToInvariantString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Reflection;
|
||||
using System.Xml;
|
||||
|
||||
@ -10,9 +11,9 @@ namespace RobloxFiles.XmlFormat.PropertyTokens
|
||||
|
||||
public bool ReadProperty(Property prop, XmlNode token)
|
||||
{
|
||||
uint value;
|
||||
Contract.Requires(prop != null);
|
||||
|
||||
if (XmlPropertyTokens.ReadPropertyGeneric(token, out value))
|
||||
if (XmlPropertyTokens.ReadPropertyGeneric(token, out uint value))
|
||||
{
|
||||
Instance inst = prop.Instance;
|
||||
Type instType = inst?.GetType();
|
||||
@ -36,13 +37,13 @@ namespace RobloxFiles.XmlFormat.PropertyTokens
|
||||
|
||||
public void WriteProperty(Property prop, XmlDocument doc, XmlNode node)
|
||||
{
|
||||
Contract.Requires(prop != null && node != null);
|
||||
object rawValue = prop.Value;
|
||||
Type valueType = rawValue.GetType();
|
||||
|
||||
|
||||
int signed = (int)rawValue;
|
||||
uint value = (uint)signed;
|
||||
|
||||
node.InnerText = value.ToString();
|
||||
node.InnerText = value.ToInvariantString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System.Xml;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Xml;
|
||||
using RobloxFiles.DataTypes;
|
||||
|
||||
namespace RobloxFiles.XmlFormat.PropertyTokens
|
||||
@ -9,9 +10,9 @@ namespace RobloxFiles.XmlFormat.PropertyTokens
|
||||
|
||||
public bool ReadProperty(Property prop, XmlNode token)
|
||||
{
|
||||
uint value;
|
||||
Contract.Requires(prop != null);
|
||||
|
||||
if (XmlPropertyTokens.ReadPropertyGeneric(token, out value))
|
||||
if (XmlPropertyTokens.ReadPropertyGeneric(token, out uint value))
|
||||
{
|
||||
Faces faces = (Faces)value;
|
||||
prop.Value = faces;
|
||||
@ -24,6 +25,8 @@ namespace RobloxFiles.XmlFormat.PropertyTokens
|
||||
|
||||
public void WriteProperty(Property prop, XmlDocument doc, XmlNode node)
|
||||
{
|
||||
Contract.Requires(prop != null && doc != null && node != null);
|
||||
|
||||
XmlElement faces = doc.CreateElement("faces");
|
||||
node.AppendChild(faces);
|
||||
|
||||
|
Reference in New Issue
Block a user