Dynamic Enums

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • balabaster
    Recognized Expert Contributor
    • Mar 2007
    • 798

    Dynamic Enums

    Does anyone have any clue how to dynamically build an enum at design time based on items defined in a configuration file? I'm thinking there may be an approach using compiler services and something akin to type extensions... but I've looked for similar things before and came up empty.
  • nateraaaa
    Recognized Expert Contributor
    • May 2007
    • 664

    #2
    Have you looked at the EnumBuilder Class in MSDN? I haven't personally used this class but it appears to be what you are looking for.

    http://msdn.microsoft. com/en-us/library/system.reflecti on.emit.enumbui lder.aspx

    Nathan

    Comment

    • balabaster
      Recognized Expert Contributor
      • Mar 2007
      • 798

      #3
      Originally posted by nateraaaa
      Have you looked at the EnumBuilder Class in MSDN? I haven't personally used this class but it appears to be what you are looking for.



      Nathan
      Cheers, I'll check it out. Although I can't for the life of me remember what I was trying to do with them... it must have been something to do with interfaces, I can't think of another valid reason for building a dynamic enum except as a middle tier to allow simple separation of business logic from GUI logic...

      Ben

      Comment

      Working...