Created
December 2, 2022 15:33
-
-
Save AThraen/f40d9e09c829f8e33c08786b68f8fd5d to your computer and use it in GitHub Desktop.
Optimizely/Episerver CMS Generic Enum Selection Factory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class GenericEnumSelectionFactory<TEnum> : EnumSelectionFactory where TEnum : Enum | |
| { | |
| protected override Type EnumType => typeof(TEnum); | |
| public GenericEnumSelectionFactory() : this(LocalizationService.Current) | |
| { | |
| } | |
| public GenericEnumSelectionFactory(LocalizationService localization) : base(localization) | |
| { | |
| } | |
| protected override string GetStringForEnumValue(int value) => | |
| this.LocalizationService.GetString("/Enums/" + nameof(TEnum) + "/" + Enum.GetNames(EnumType)[value], Enum.GetNames(EnumType)[value]); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment