Added read support for Instance Attributes.

This isn't 100% finished yet. I intend to add some better API for reading specific attributes, as well as write support (of course!)
This commit is contained in:
CloneTrooper1019
2019-10-31 21:40:31 -05:00
parent fd8598c1b5
commit e14b092aa7
30 changed files with 580 additions and 95 deletions

View File

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
@ -57,9 +58,23 @@ namespace RobloxFiles
/// <summary>A list of CollectionService tags assigned to this Instance.</summary>
public List<string> Tags => RawTags;
/// <summary>The attributes defined for this Instance.</summary>
public Attributes Attributes { get; private set; }
/// <summary>The internal serialized data of this Instance's attributes</summary>
internal byte[] AttributesSerialize;
internal byte[] AttributesSerialize
{
get
{
return Attributes?.Serialize() ?? new byte[0];
}
set
{
MemoryStream data = new MemoryStream(value);
Attributes = new Attributes(data);
}
}
/// <summary>
/// Internal format of the Instance's CollectionService tags.
/// Property objects will look to this member for serializing the Tags property.
@ -538,6 +553,7 @@ namespace RobloxFiles
}
Property tags = GetProperty("Tags");
Property attributes = GetProperty("AttributesSerialize");
if (tags == null)
{
@ -545,6 +561,12 @@ namespace RobloxFiles
AddProperty(ref tags);
}
if (attributes == null)
{
attributes = new Property("AttributesSerialize", PropertyType.String);
AddProperty(ref attributes);
}
return Properties;
}
}