1

I'd like to mimic the behavior of the "profile provider" that is available in .Net. The profile provider acquires profile properties from the web.config and those properties are immediately available as an enum for use in the code behind.

I'm unsure how to do this, and wondered whether someone may be able to help.

Essentially I'd like to allow developers to enter Role information into the web.config, and then have this role information available for use within an enum in the codebehind.

Thanks in advance!

Nick W
  • 117
  • 3
  • 10

2 Answers2

2

I think what you're trying to do is use dynamic enums?

If so, I think you might have to consider a different implementation - enums are defined at compile-time so what you want to do isn't going to be possible using them.

A similar question was asked before: Dynamic enum in C# and it can be done, via buildproviders. But there might be another (simpler) way to achieve what you want to do ...

Community
  • 1
  • 1
immutabl
  • 6,857
  • 13
  • 45
  • 76
  • 1
    Yep, this was what I was after. If anyone's curious, this article is quite helpful too. [Custom Build Providers](http://www.codeproject.com/KB/aspnet/EXCustomBuildProviders.aspx) – Nick W Feb 15 '11 at 01:18
  • That's a great article - I had avoided up till now due to the relative incomprehensibility (to me, anyway) of the MSDN documentation about this. Many thanks for sharing :-) – immutabl Feb 15 '11 at 10:15
1

I haven't done this myself, but I think "build provider" is the word you're looking for... http://www.google.no/search?q=build+provider+asp.net

Arjan Einbu
  • 13,543
  • 2
  • 56
  • 59