Add Dictionary<,> support to FieldSaver

This commit is contained in:
Pavel Penev
2015-08-28 03:16:07 +03:00
parent 341b3395c8
commit 8ddbabbfde
2 changed files with 43 additions and 1 deletions

View File

@@ -648,6 +648,7 @@ namespace OpenRA
public string YamlName;
public string Loader;
public bool FromYamlKey;
public bool DictionaryFromYamlKey;
public bool Required;
public SerializeAttribute(bool serialize = true, bool required = false)
@@ -710,6 +711,17 @@ namespace OpenRA
}
}
// Special-cases FieldFromYamlKeyAttribute for use with Dictionary<K,V>.
[AttributeUsage(AttributeTargets.Field)]
public sealed class DictionaryFromYamlKeyAttribute : FieldLoader.SerializeAttribute
{
public DictionaryFromYamlKeyAttribute()
{
FromYamlKey = true;
DictionaryFromYamlKey = true;
}
}
// mirrors DescriptionAttribute from System.ComponentModel but we dont want to have to use that everywhere.
[AttributeUsage(AttributeTargets.All)]
public sealed class DescAttribute : Attribute