background
I have some scripts that run as part of my build process, which Generate various source code files and some other source code for me.
The script uses CodeDom to generate them, and they read .cs
files using a normal text reader.
Question
is looking for a script to use the class class called PageMenuItem and its purpose is to create a static list of page menu items.
All this is read by reading .cs
files and for the "PageMenuItem"
attributes, it calculates the number of arguments and Trying to figure out which constructor is being used outside, it can separate different pieces of information.
There are 7 constructors for PageMenuItem
with different parameters, so it is becoming very difficult to determine .cs
source code which is the manufacturer And therefore to parse the information.
Rather than trying to parse the text, I would just like to create a PageMenuItem
object in memory and use its properties.
Therefore, I need a way to declare a feature from the .cs
file and create a new example from PageMenuItem
.
Is this possible?
Another way to ask this question:
Looking at this string:
string myCodeStatement = "[MyAttribute (\" asdf \ ", \" Foo \ ")]";
How can I create this type of object MyAttribute
so that I can work with that object? I define MyAttribute
which has full access to the source code.
It seems you can self-relaunch the class files, or alternatively add a annotation to the constructor, which will make your parsing job easier. Aspect-oriented techniques can be helpful - every time a constructor is called, and as is, add items to your list.
No comments:
Post a Comment