Connecting Tech Pros Worldwide Forums | Help | Site Map

Macro Question

Andrew Wied
Guest
 
Posts: n/a
#1: Nov 18 '05
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

Carlos J. Quintero [MVP]
Guest
 
Posts: n/a
#2: Nov 18 '05

re: Macro Question


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" <anonymous@discussions.microsoft.com> escribió en el mensaje
news:B849575F-44F1-4948-8767-969EB6337B0D@microsoft.com...[color=blue]
> Hello:
> I am writing a macro in Visual Studio .Net 2003, and I was wondering if[/color]
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):[color=blue]
>
> 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[/color]
then print the properties to the screen?[color=blue]
>
> 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[/color]
might be done using reflection, but I don't know how to approach it.[color=blue]
>
> Can anyone provide help in this matter?
>
> Thanks,
> Andrew Wied[/color]


Closed Thread


Similar ASP.NET bytes