Fixed primitive fields not being serialised
This commit is contained in:
parent
cfed342f9c
commit
4bc91283c8
|
@ -73,7 +73,7 @@ namespace SHADE
|
||||||
// Create YAML object
|
// Create YAML object
|
||||||
YAML::Node scriptNode;
|
YAML::Node scriptNode;
|
||||||
scriptNode.SetStyle(YAML::EmitterStyle::Block);
|
scriptNode.SetStyle(YAML::EmitterStyle::Block);
|
||||||
scriptNode[SCRIPT_TYPE_YAMLTAG] = Convert::ToNative(object->GetType()->FullName);
|
scriptNode[SCRIPT_TYPE_YAMLTAG.data()] = Convert::ToNative(object->GetType()->FullName);
|
||||||
|
|
||||||
// Get all fields
|
// Get all fields
|
||||||
System::Collections::Generic::IEnumerable<FieldInfo^>^ fields = GetInstanceFields(object);
|
System::Collections::Generic::IEnumerable<FieldInfo^>^ fields = GetInstanceFields(object);
|
||||||
|
@ -129,7 +129,7 @@ namespace SHADE
|
||||||
YAML::Node fieldNode;
|
YAML::Node fieldNode;
|
||||||
|
|
||||||
// Retrieve string for the YAML
|
// Retrieve string for the YAML
|
||||||
if (fieldInsertYaml<System::Int16> (fieldInfo, object, fieldNode) ||
|
const bool PRIMITIVE_SERIALIZED = fieldInsertYaml<System::Int16>(fieldInfo, object, fieldNode) ||
|
||||||
fieldInsertYaml<System::Int32>(fieldInfo, object, fieldNode) ||
|
fieldInsertYaml<System::Int32>(fieldInfo, object, fieldNode) ||
|
||||||
fieldInsertYaml<System::Int64>(fieldInfo, object, fieldNode) ||
|
fieldInsertYaml<System::Int64>(fieldInfo, object, fieldNode) ||
|
||||||
fieldInsertYaml<System::UInt16>(fieldInfo, object, fieldNode) ||
|
fieldInsertYaml<System::UInt16>(fieldInfo, object, fieldNode) ||
|
||||||
|
@ -138,11 +138,12 @@ namespace SHADE
|
||||||
fieldInsertYaml<System::Byte>(fieldInfo, object, fieldNode) ||
|
fieldInsertYaml<System::Byte>(fieldInfo, object, fieldNode) ||
|
||||||
fieldInsertYaml<bool>(fieldInfo, object, fieldNode) ||
|
fieldInsertYaml<bool>(fieldInfo, object, fieldNode) ||
|
||||||
fieldInsertYaml<float>(fieldInfo, object, fieldNode) ||
|
fieldInsertYaml<float>(fieldInfo, object, fieldNode) ||
|
||||||
fieldInsertYaml<double> (fieldInfo, object, fieldNode))
|
fieldInsertYaml<double>(fieldInfo, object, fieldNode);
|
||||||
|
|
||||||
|
// Serialization of more complex types
|
||||||
|
if (!PRIMITIVE_SERIALIZED)
|
||||||
{
|
{
|
||||||
return;
|
if (fieldInfo->FieldType->IsSubclassOf(System::Enum::typeid))
|
||||||
}
|
|
||||||
else if (fieldInfo->FieldType->IsSubclassOf(System::Enum::typeid))
|
|
||||||
{
|
{
|
||||||
fieldNode = std::to_string(safe_cast<int>(fieldInfo->GetValue(object)));
|
fieldNode = std::to_string(safe_cast<int>(fieldInfo->GetValue(object)));
|
||||||
}
|
}
|
||||||
|
@ -175,6 +176,7 @@ namespace SHADE
|
||||||
));
|
));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Store the field into YAML
|
// Store the field into YAML
|
||||||
yamlNode[Convert::ToNative(fieldInfo->Name)] = fieldNode;
|
yamlNode[Convert::ToNative(fieldInfo->Name)] = fieldNode;
|
||||||
|
|
|
@ -58,8 +58,7 @@ namespace SHADE
|
||||||
/// deserialised data into the specified object if there are matching fields.
|
/// deserialised data into the specified object if there are matching fields.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="yamlNode">
|
/// <param name="yamlNode">
|
||||||
/// The JSON string that contains the data to copy into this PlushieScript
|
/// The JSON string that contains the data to copy into this Script object.
|
||||||
/// object.
|
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <param name="object">The object to copy deserialised data into.</param>
|
/// <param name="object">The object to copy deserialised data into.</param>
|
||||||
static void Deserialise(System::Object^ object, YAML::Node& yamlNode);
|
static void Deserialise(System::Object^ object, YAML::Node& yamlNode);
|
||||||
|
|
Loading…
Reference in New Issue