There are two basic aproaches:
1) Parse the entire solution and everything it references so you understand all the types involved in the code
2) Parse locally and do your best to guess what types etc are.
The trouble with (2) is that you have to guess, and in some circumstances you just can't tell from a code snippet exactly what everything is. But if you're happy with the sort oif syntax highlighting shown on (e.g.) Stack Overflow, then this approach is easy and quite effective.
To do (1) then you need to do one of (in decreasing order of difficulty):
- Parse all the source code. Not possible if you reference 3rd party assemblies.
- Use reflection on the compiled code to garner type information you can use when parsing the source.
- Use the host IDE's (if avaiable - so not applicable in your case!) code element interfaces to provide the information you need