Macro Question

G

Guest

Hello
I am writing a macro in Visual Studio .Net 2003, and I was wondering if it is possible for a macro to access properties of objects that are selected. For instance, assume I have the following object declared (on a different page, but it can still be instanciated)

Class rectangl
Private _height as doubl
Private _length as doubl

Public Property height(
Public Property width(
End Clas

Now, is there a way, using a macro, to take a name of an object type and then print the properties to the screen

For instance - the object name 'rectangle' would print out
'rectangle
Property: heigh
Property: weigh

I'm relatively new to this, and I suspect that if it could be done, it might be done using reflection, but I don't know how to approach it

Can anyone provide help in this matter

Thanks
Andrew Wied
 
C

Carlos J. Quintero [MVP]

I suppose that when you say "object" you mean "class" since the source code
has classes, not objects; objects are instances of classes that exist only
at run-time. If I understand well, then you have a source code file with a
"rectangle" class and you want a macro that receives the name of the class
and shows its properties, right?

This must be done using the code model functionality of the extensibility
model for addins and macros. The code model has 2 entry points:

- Project.CodeModel
- ProjectItem.FileCodeModel (a project item is a file).

You should read the documentation about the code model, but to have an idea
of the code that you need to use, see this article that I wrote to report a
bug and that has a macro that uses the code model:

http://support.microsoft.com/default.aspx?scid=kb;en-us;555114

Notice that if your class resides on a compiled assembly instead of in
source code, you should need to use Reflection.

--

Carlos J. Quintero (Visual Developer - .NET MVP)

FAQs, Knowledge Base, Files, Docs, Articles, Utilities, etc. for .NET
addins:
http://groups.yahoo.com/group/vsnetaddin/ (free join)



Andrew Wied said:
Hello:
I am writing a macro in Visual Studio .Net 2003, and I was wondering if
it is possible for a macro to access properties of objects that are
selected. For instance, assume I have the following object declared (on a
different page, but it can still be instanciated):
Class rectangle
Private _height as double
Private _length as double

Public Property height()
Public Property width()
End Class

Now, is there a way, using a macro, to take a name of an object type and
then print the properties to the screen?
For instance - the object name 'rectangle' would print out:
'rectangle'
Property: height
Property: weight

I'm relatively new to this, and I suspect that if it could be done, it
might be done using reflection, but I don't know how to approach it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top