public void Deserialize_Array(teStructuredDataMgr manager, teStructuredData data, STUField_Info field, Array target, int index) { if (data.Format == teStructuredDataFormat.V2) { int value = data.DynData.ReadInt32(); data.DynData.ReadInt32(); // Padding for in-place deserialization if (value == -1) { return; } if (value < data.Instances.Length) { STUInstance embeddedInstance = data.Instances[value]; if (embeddedInstance != null) { embeddedInstance.Usage = TypeUsage.EmbedArray; } target.SetValue(embeddedInstance, index); } else { throw new ArgumentOutOfRangeException( $"Instance index is out of range. Id: {value}, Type: EmbeddedInstanceFieldReader, DynData offset: {data.DynData.Position() - 8}"); } } else if (data.Format == teStructuredDataFormat.V1) { long offset = data.Data.ReadInt32(); data.Data.ReadInt32(); if (offset == -1) { return; } STUInstance embeddedInstance = data.GetInstanceAtOffset(offset); if (embeddedInstance != null) { embeddedInstance.Usage = TypeUsage.EmbedArray; } target.SetValue(embeddedInstance, index); } }
public void Deserialize(teStructuredDataMgr manager, teStructuredData data, STUField_Info field, object instance, FieldInfo target) { if (data.Format == teStructuredDataFormat.V2) { int value = data.Data.ReadInt32(); if (value == -1) { return; } if (value < data.Instances.Length) { STUInstance embeddedInstance = data.Instances[value]; if (embeddedInstance != null) { embeddedInstance.Usage = TypeUsage.Embed; } target.SetValue(instance, embeddedInstance); } } else if (data.Format == teStructuredDataFormat.V1) { int value = data.Data.ReadInt32(); data.Data.ReadInt32(); if (value <= 0) { return; } STUInstance embeddedInstance = data.GetInstanceAtOffset(value); if (embeddedInstance != null) { embeddedInstance.Usage = TypeUsage.Embed; } target.SetValue(instance, embeddedInstance); } }