Take the community feedback survey now.
AI OnAI Off
Take the community feedback survey now.
Hi,
There are couple of options here:
public class EnumSelectionFactory<TEnum, TUnderlying> where TEnum : struct
{
public IEnumerable GetSelections(ExtendedMetadata metadata)
{
return Enum.GetValues(typeof(TEnum))
.Cast<TEnum>()
.Select(s => new SelectItem
{
Value = ...,
Text = ValueName(s as Enum)
});
}
private static string ValueName(Enum value)
{
return value.Translate();
}
}
Also, IMHO if you are using that Enum as flags, value for the "Small" should not be "3" but "4".
Good luck!
thank you Valdis..
I tried both approaches and both do the job. Slowly i'm getting the hang of this nice package. Thanks alot for your response.
And yes the Flags attribute was just a test and was not needed. Thanks for pointing it out.
Hey Guys,
i'm using DbLocalizationProvider with an EnumSelectionFactory to fill in a dropdown property in the CMS.
I want to be able to translate the text of the dropdown items.
But with below code i always get "String.System" as result of the translation. What am i missing here?
I checked the github : https://github.com/valdisiljuconoks/LocalizationProvider/commit/f7c4536c75fbf48f67e3fee1bd2d77da6f273463 and they do the same thing basically.
I'm on the latest NUget packages of everything.
mu enum class:
[Pasting files is not allowed]