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...b;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" <an*******@discussions.microsoft.com> escribió en el mensaje
news:B8**********************************@microsof t.com...
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.
Can anyone provide help in this matter?
Thanks,
Andrew Wied