Added FieldLoader.SerializeAttribute.Required to require fields in MiniYaml

This commit is contained in:
atlimit8
2015-07-11 09:49:35 -05:00
parent f5d7df621f
commit 7881ff40bf
4 changed files with 66 additions and 14 deletions

View File

@@ -94,7 +94,16 @@ namespace OpenRA
throw new YamlException("Junk value `{0}` on trait node {1}"
.F(my.Value, traitName));
var info = Game.CreateObject<ITraitInfo>(traitName + "Info");
FieldLoader.Load(info, my);
try
{
FieldLoader.Load(info, my);
}
catch (FieldLoader.MissingFieldsException e)
{
var header = "Trait name " + traitName + ": " + (e.Missing.Length > 1 ? "Required properties missing" : "Required property missing");
throw new FieldLoader.MissingFieldsException(e.Missing, header);
}
return info;
}