jeudi 25 mai 2017

Proper Code or Design Pattern to select combination of items from an enum

I want to select multiple items from a enum based on the some of parameters. So, for example suppose I have an enum named Animal

public enum Animal
{
   [DisplayName("Dog")]
   Dog,
   [DisplayName("Cat")]
   Cat,
   [DisplayName("Mouse")]
   Mouse,
   [DisplayName("Ant")]
   Ant,
   [DisplayName("Monkey")]
   Monkey
}

And I want to get only specific items from this enum based on the parameter, so if my parameter is "FourLegged" I should get Dog, Cat, Mouse, for other parameter I should get different set. And there could be multiple combination of enum and parameters, I can pass one or more pararmeter to get related items from the enum.

What should be the best/proper way to implement this? Is there any code or design pattern to implement this? It can be other approach than using enum.

Aucun commentaire:

Enregistrer un commentaire