Fixed edge cases for serialization and deserialization of scripts #218
|
@ -45,12 +45,22 @@ namespace SHADE
|
||||||
System::Collections::Generic::IEnumerable<FieldInfo^>^ fields = ReflectionUtilities::GetInstanceFields(object);
|
System::Collections::Generic::IEnumerable<FieldInfo^>^ fields = ReflectionUtilities::GetInstanceFields(object);
|
||||||
for each (FieldInfo^ field in fields)
|
for each (FieldInfo^ field in fields)
|
||||||
{
|
{
|
||||||
// Ignore private and non-SerialiseField
|
try
|
||||||
if (!ReflectionUtilities::FieldIsSerialisable(field))
|
{
|
||||||
continue;
|
// Ignore private and non-SerialiseField
|
||||||
|
if (!ReflectionUtilities::FieldIsSerialisable(field))
|
||||||
|
continue;
|
||||||
|
|
||||||
// Serialise
|
// Serialise
|
||||||
writeFieldIntoYaml(field, object, scriptNode);
|
writeFieldIntoYaml(field, object, scriptNode);
|
||||||
|
}
|
||||||
|
catch (System::Exception^ e)
|
||||||
|
{
|
||||||
|
Debug::LogError
|
||||||
|
(
|
||||||
|
System::String::Format("[SerialisationUtilities] Failed to serialise field ({0}): {1}", field->Name, e->ToString())
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
scriptListNode.push_back(scriptNode);
|
scriptListNode.push_back(scriptNode);
|
||||||
|
@ -74,15 +84,25 @@ namespace SHADE
|
||||||
System::Collections::Generic::IEnumerable<FieldInfo^>^ fields = ReflectionUtilities::GetInstanceFields(object);
|
System::Collections::Generic::IEnumerable<FieldInfo^>^ fields = ReflectionUtilities::GetInstanceFields(object);
|
||||||
for each (FieldInfo^ field in fields)
|
for each (FieldInfo^ field in fields)
|
||||||
{
|
{
|
||||||
// Ignore private and non-SerialiseField
|
try
|
||||||
if (!ReflectionUtilities::FieldIsSerialisable(field))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// Deserialise
|
|
||||||
const std::string FIELD_NAME = Convert::ToNative(field->Name);
|
|
||||||
if (yamlNode[FIELD_NAME])
|
|
||||||
{
|
{
|
||||||
writeYamlIntoField(field, object, yamlNode[FIELD_NAME]);
|
// Ignore private and non-SerialiseField
|
||||||
|
if (!ReflectionUtilities::FieldIsSerialisable(field))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Deserialise
|
||||||
|
const std::string FIELD_NAME = Convert::ToNative(field->Name);
|
||||||
|
if (yamlNode[FIELD_NAME])
|
||||||
|
{
|
||||||
|
writeYamlIntoField(field, object, yamlNode[FIELD_NAME]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (System::Exception^ e)
|
||||||
|
{
|
||||||
|
Debug::LogError
|
||||||
|
(
|
||||||
|
System::String::Format("[SerialisationUtilities] Failed to deserialise field ({0}): {1}", field->Name, e->ToString())
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue