Further fixes

This commit is contained in:
Lohikar 2017-11-17 13:32:53 -06:00
parent f98750212c
commit 2e3b7d9c2e
6 changed files with 39 additions and 15 deletions

View file

@ -59,6 +59,14 @@ namespace AuroraRecordGenerator
var attr = species.GetAttributeOfType<SubspeciesMetaAttribute>();
return attr?.NiceName ?? Enum.GetName(typeof(SpeciesSubType), species);
}
public static SpeciesSubType SubspeciesNiceNameToEnum(string nicename)
{
return (from item in Enum.GetValues(typeof(SpeciesSubType)).Cast<SpeciesSubType>()
let attr = item.GetAttributeOfType<SubspeciesMetaAttribute>()
where attr != null && attr.NiceName == nicename
select item).FirstOrDefault();
}
}
// From https://stackoverflow.com/questions/1799370/getting-attributes-of-enums-value