enums' Describe attribute in FormDialog fails to be recognized as a valid option

Viewed 47

I know I can rely on the system to automatically show SummerLineUp into "Summer Line Up" but I want more control on the displayed texts for my enums.

So I would like to use the Describe attribute for friendlier displays like so:

public enum ProductTypeOptions
{
    [Describe("Summer line up")]
    ProductA = 1,
    [Describe("Fall line up")]
    ProductB = 2,
    [Describe("Winter line up")]
    ProductC = 3,
}

Those show nice and pretty but fails during validation with "Summer line up is not a valid Product Type option".

Is there a different attribute I can use?

2 Answers

A simpler way would be to add the Terms decoration to ProductTypeOptions each item.

So the code would be :

public enum ProductTypeOptions
    {
        [Terms(new string[] { "Summer line up", "Whatever more you want" })]
        [Describe("Summer line up")]
        ProductA = 1,

        [Terms(new string[] { "Fall line up" })]
        [Describe("Fall line up")]
        ProductB = 2,

        [Terms(new string[] { "Winter line up" })]
        [Describe("Winter line up")]
        ProductC = 3,
    };

Now your bot will automatically understand the value of "Summer line up" as ProductA.

Related