views:

37

answers:

2

I have an XML file that lists a series of items, and the items are often referenced by their name in code.

Is there any way to use reflection within Visual Studio to make this list 'accessible' sort of like intellisence? I've seen it done before - and I'm pretty sure it's ridiculously difficult, but I figure it can't hurt to at least ask.

+1  A: 

I think he wants to access xml from c# code with intelligences.

My guess is that you would have to build some sort of code generator that would generate c# class that has the properties of you xml field... kind of how visual studio generates code for resourcefiles.

Petoj
+1  A: 

I would recommend against using reflection for this.

Apart from the added complexity in the code you are also opening the code up to abuse from somebody modifying your XML to get your code to do what they want (think injection attack).

You would be better off parsing the XML as usual but using a big if / switch statement to define what how the code runs. That way you have more chance of catching any problems and validating the input.

From string to function call sounds great but will bite you in the bum.

CResults
I figured this would be the case, I just wanted to throw the thought out to see if there was any merit. Thanks a lot!
Stacey