I have the code that reflects enum (DictionaryType) option to Guid in very straight-forward way
if (dictionaryType == DictionaryType.RegionType)
return Consts.DictionaryTypeId.RegionType;
if (dictionaryType == DictionaryType.Nationality)
return Consts.DictionaryTypeId.Nationality;
Please, suggest me the best way to reflect Enum option to static readonly guid value.
Thank you in advance
Edited a bit later: I can't assign any attributes to enumeration options, 'cos enumeration is declared in Data Model assembly and enumerations shouldn't be combined with implementation (Guids, Tables...)
In addition to Jon's answer, you can provide the Guids as fields in a separate class, where the fields have the same name as their corresponding enum value.
This can be used to populate a dictionary for fast lookup later:
Outputs:
I'm not entirely sure what I would chose myself, but perhaps a combination of Jon's answer, a dictionary to look up the guids from and reflection like above to populate it.
A couple of simple options:
Dictionary<DictionaryType, Guid>
(which could be populated by reflection if you really wanted)