public static ArrayProperty Parse(string propertyName, int index, BinaryReader reader, int size, out int overhead) { var result = new ArrayProperty(propertyName, index) { Type = reader.ReadLengthPrefixedString() }; overhead = result.Type.Length + 6; byte unk = reader.ReadByte(); Trace.Assert(unk == 0); switch (result.Type) { case StructProperty.TypeName: { result.Elements.AddRange(StructProperty.ParseArray(reader)); //for (var i = 0; i < count; i++) //{ // var prop = SerializedProperty.Parse(reader, out int _, out int _); // result.Elements.Add(prop); //} } break; case ObjectProperty.TypeName: { var count = reader.ReadInt32(); for (var i = 0; i < count; i++) { var obj1 = reader.ReadLengthPrefixedString(); var obj2 = reader.ReadLengthPrefixedString(); result.Elements.Add(new ObjectProperty($"Element {i}", obj1, obj2)); } } break; case IntProperty.TypeName: { var count = reader.ReadInt32(); for (var i = 0; i < count; i++) { var value = reader.ReadInt32(); result.Elements.Add(new IntProperty($"Element {i}") { Value = value }); } } break; default: throw new NotImplementedException(); } return(result); }
public static ArrayProperty Parse(string propertyName, int index, BinaryReader reader, int size, out int overhead) { var result = new ArrayProperty(propertyName, index) { Type = reader.ReadLengthPrefixedString() }; overhead = result.Type.Length + 6; byte unk = reader.ReadByte(); Trace.Assert(unk == 0); switch (result.Type) { case StructProperty.TypeName: { result.Elements.AddRange(StructProperty.ParseArray(reader)); } break; case ObjectProperty.TypeName: { var count = reader.ReadInt32(); for (var i = 0; i < count; i++) { var obj1 = reader.ReadLengthPrefixedString(); var obj2 = reader.ReadLengthPrefixedString(); result.Elements.Add(new ObjectProperty($"Element {i}", obj1, obj2)); } } break; case IntProperty.TypeName: { var count = reader.ReadInt32(); for (var i = 0; i < count; i++) { var value = reader.ReadInt32(); result.Elements.Add(new IntProperty($"Element {i}") { Value = value }); } } break; case ByteProperty.TypeName: { var count = reader.ReadInt32(); for (var i = 0; i < count; i++) { var value = reader.ReadByte(); result.Elements.Add(new ByteProperty($"Element {i}") { Type = "None", Value = value.ToString() }); } } break; case EnumProperty.TypeName: { var count = reader.ReadInt32(); for (var i = 0; i < count; i++) { var str = reader.ReadLengthPrefixedString(); result.Elements.Add(new EnumProperty($"Element {i}") { Type = str.Split(':')[0], Name = str }); } } break; case StrProperty.TypeName: { var count = reader.ReadInt32(); for (var i = 0; i < count; i++) { var str = reader.ReadLengthPrefixedString(); result.Elements.Add(new StrProperty($"Element {i}") { Value = str }); } } break; default: throw new NotImplementedException(); } return(result); }