Added write support for binary files!
Holy cow, this took a lot of work. I think I may need to do a few more things before I consider this a 1.0 release, but I'm glad to have finally overcome this hurdle!
This commit is contained in:
@ -98,7 +98,7 @@ namespace RobloxFiles.XmlFormat
|
||||
if (refToken != null && file != null)
|
||||
{
|
||||
string referent = refToken.InnerText;
|
||||
inst.XmlReferent = referent;
|
||||
inst.Referent = referent;
|
||||
|
||||
if (file.Instances.ContainsKey(referent))
|
||||
throw error("Got an Item with a duplicate 'referent' attribute!");
|
||||
|
@ -40,10 +40,10 @@ namespace RobloxFiles.XmlFormat
|
||||
foreach (Instance child in inst.GetChildren())
|
||||
RecordInstances(file, child);
|
||||
|
||||
if (inst.XmlReferent.Length < 35)
|
||||
inst.XmlReferent = CreateReferent();
|
||||
if (inst.Referent.Length < 35)
|
||||
inst.Referent = CreateReferent();
|
||||
|
||||
file.Instances.Add(inst.XmlReferent, inst);
|
||||
file.Instances.Add(inst.Referent, inst);
|
||||
}
|
||||
|
||||
public static XmlElement CreateRobloxElement(XmlDocument doc)
|
||||
@ -141,7 +141,7 @@ namespace RobloxFiles.XmlFormat
|
||||
{
|
||||
XmlElement instNode = doc.CreateElement("Item");
|
||||
instNode.SetAttribute("class", instance.ClassName);
|
||||
instNode.SetAttribute("referent", instance.XmlReferent);
|
||||
instNode.SetAttribute("referent", instance.Referent);
|
||||
|
||||
XmlElement propsNode = doc.CreateElement("Properties");
|
||||
instNode.AppendChild(propsNode);
|
||||
|
@ -1,12 +0,0 @@
|
||||
using System.Xml;
|
||||
|
||||
namespace RobloxFiles.XmlFormat
|
||||
{
|
||||
public interface IXmlPropertyToken
|
||||
{
|
||||
string Token { get; }
|
||||
|
||||
bool ReadProperty(Property prop, XmlNode token);
|
||||
void WriteProperty(Property prop, XmlDocument doc, XmlNode node);
|
||||
}
|
||||
}
|
@ -22,7 +22,7 @@ namespace RobloxFiles.XmlFormat.PropertyTokens
|
||||
if (prop.Value != null && prop.Value.ToString() != "null")
|
||||
{
|
||||
Instance inst = prop.Value as Instance;
|
||||
result = inst.XmlReferent;
|
||||
result = inst.Referent;
|
||||
}
|
||||
|
||||
node.InnerText = result;
|
||||
|
@ -40,12 +40,13 @@ namespace RobloxFiles.XmlFormat
|
||||
try
|
||||
{
|
||||
string value = token.InnerText;
|
||||
Type type = typeof(T);
|
||||
|
||||
if (typeof(T) == typeof(int))
|
||||
if (type == typeof(int))
|
||||
prop.Value = Formatting.ParseInt(value);
|
||||
else if (typeof(T) == typeof(float))
|
||||
else if (type == typeof(float))
|
||||
prop.Value = Formatting.ParseFloat(value);
|
||||
else if (typeof(T) == typeof(double))
|
||||
else if (type == typeof(double))
|
||||
prop.Value = Formatting.ParseDouble(value);
|
||||
|
||||
if (prop.Value == null)
|
||||
|
@ -29,7 +29,7 @@ namespace RobloxFiles.XmlFormat
|
||||
string xml = Encoding.UTF8.GetString(buffer);
|
||||
Root.LoadXml(xml);
|
||||
}
|
||||
catch (Exception e)
|
||||
catch
|
||||
{
|
||||
throw new Exception("XmlRobloxFile: Could not read provided buffer as XML!");
|
||||
}
|
||||
@ -110,7 +110,7 @@ namespace RobloxFiles.XmlFormat
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("XmlRobloxFile: No 'roblox' tag found!");
|
||||
throw new Exception("XmlRobloxFile: No 'roblox' element found!");
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user