Mapper: implement enum mappings

pull/2/head
Harald Wolff 2019-10-11 11:40:16 +02:00
parent 6358af9250
commit c64736e8e0
1 changed files with 8 additions and 0 deletions

View File

@ -187,6 +187,14 @@ namespace ln.types.odb.ng
mappings.Add(type, new mappings.ListMapping(type));
return mappings[type];
}
else if (type.IsEnum)
{
mappings.Add(type, new SimpleMapping(
(mapper, value) => new ODBStringValue(Enum.GetName(type, value)),
(mapper, oval) => Enum.Parse(type, (oval as ODBStringValue).Value as String)
));
return mappings[type];
}
else if (!type.IsPrimitive)
{
mappings.Add(type, new mappings.ClassMapping(type));