Support List<> for FieldSaver/FieldLoader

This commit is contained in:
Trevor Nichols
2020-10-04 13:44:15 +11:00
committed by abcdefg30
parent d647aab7fe
commit 6f32196f89
2 changed files with 2 additions and 2 deletions

View File

@@ -435,7 +435,7 @@ namespace OpenRA
ret.SetValue(GetValue(fieldName, fieldType.GetElementType(), parts[i].Trim(), field), i);
return ret;
}
else if (fieldType.IsGenericType && fieldType.GetGenericTypeDefinition() == typeof(HashSet<>))
else if (fieldType.IsGenericType && (fieldType.GetGenericTypeDefinition() == typeof(HashSet<>) || fieldType.GetGenericTypeDefinition() == typeof(List<>)))
{
var set = Activator.CreateInstance(fieldType);
if (value == null)

View File

@@ -94,7 +94,7 @@ namespace OpenRA
return ((Array)v).Cast<object>().Select(FormatValue).JoinWith(", ");
}
if (t.IsGenericType && t.GetGenericTypeDefinition() == typeof(HashSet<>))
if (t.IsGenericType && (t.GetGenericTypeDefinition() == typeof(HashSet<>) || t.GetGenericTypeDefinition() == typeof(List<>)))
{
return ((System.Collections.IEnumerable)v).Cast<object>().Select(FormatValue).JoinWith(", ");
}