From ab0453e0aba1459a9567b1424faa185c4d203e76 Mon Sep 17 00:00:00 2001 From: That_One_Nerd Date: Wed, 10 May 2023 09:56:12 -0400 Subject: [PATCH] Nice progress on the node tree conversion. --- SrcMod/Valve.NET/Vkv/VkvConvert.cs | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/SrcMod/Valve.NET/Vkv/VkvConvert.cs b/SrcMod/Valve.NET/Vkv/VkvConvert.cs index d4af015..02a7d8e 100644 --- a/SrcMod/Valve.NET/Vkv/VkvConvert.cs +++ b/SrcMod/Valve.NET/Vkv/VkvConvert.cs @@ -165,20 +165,28 @@ public static class VkvConvert foreach (FieldInfo field in validFields) { - // TODO: check if the node tree has that field. + string name = field.Name; - // TODO: - // parsables - // enums - // casting - // sub-conversion + VkvNode? subNode = tree[name]; + if (subNode is null) continue; + + object? result = FromNodeTree(field.FieldType, subNode, options); + if (result is null) continue; + field.SetValue(instance, result); } foreach (PropertyInfo prop in validProperties) { - // TODO: check if the node tree has that field. + string name = prop.Name; + + VkvNode? subNode = tree[name]; + if (subNode is null) continue; + + object? result = FromNodeTree(prop.PropertyType, subNode, options); + if (result is null) continue; + prop.SetValue(instance, result); } - return null; + return instance; } else throw new VkvSerializationException("Unknown VKV node type."); }