473,385 Members | 1,292 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Macro Question

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
Jul 21 '05 #1
1 1191
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

Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

25
by: Andrew Dalke | last post by:
Here's a proposed Q&A for the FAQ based on a couple recent threads. Appropriate comments appreciated X.Y: Why doesn't Python have macros like in Lisp or Scheme? Before answering that, a...
699
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro...
5
by: Eric Lilja | last post by:
Using a macro, can I change what type an object is being cast to? I know, the initial respone to question might be an instinctive "ugly, don't even think about it!" or "don't use macros at all",...
0
by: Spiro Trikaliotis | last post by:
Hello, assume I define a macro like #if <somecondition> # define MACRO(_x, _y) _x #else # define MACRO(_x, _y) _y #endif
5
by: Mason | last post by:
I'm having some problems converting VBA for Word 2000 to code that VB.Net understands. I recorded a macro in Word to add numbering (a. b. c.) to my paragraphs. I managed to translate quite a bit...
17
by: sounak | last post by:
How could we get a macro name from a macro value such that in a header file #define a 100 #define b 200 now the source file will be such that the user gives 100 then the value is outputted as...
7
by: fei.liu | last post by:
#define ONCFILE_ERR1(funcname, name) \ { \ #ifdef DEBUG\ cerr << __FILE__ << ":" << __LINE__ << " duplicated call to " << funcname << " " << name << endl; \ #endif \ } I want to have...
11
by: Remo | last post by:
Hi All I Have Quation About Macro's plz help why do we have # symbol before any macro line #define STOP 0 ... why con't we use the any other symbol like $, @,, plz answer if any one knows...
5
by: krbyxtrm | last post by:
Hi is there a way to 'manage' function execution using macros? #define MY_CALL_MACRO(MacroName) { g_MacroStack.push_back(MacroName); <some code here...>} such that when i use the...
6
by: pedroalves | last post by:
Hi all, This is not a question about how to #define COMMA , Please keep reading. Recently in binutils, we introduced a macro like this: #define STRING_COMMA_LEN(STR) \ (STR), ((STR) ?...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.