473,461 Members | 1,316 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Reflection, Classes and the Lack of Binary Compatibility

Does anyone happen to have a snippet of [VB 2003] code that,
for a given Type, produces a list of [all] the properties, methods,
constructors, and so on for that Class?

TIA,
Phill W.
Nov 23 '05 #1
4 1119
"Phill. W" <P.A.Ward@o-p-e-n-.-a-c-.-u-k> schrieb:
Does anyone happen to have a snippet of [VB 2003] code that,
for a given Type, produces a list of [all] the properties, methods,
constructors, and so on for that Class?


I do not have such a snippet, but creatint such a snippet should not be that
hard when using the 'Type' class and its methods.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 23 '05 #2
Phill,
Have you looked at the on-line help for System.Type? Specifically:

Type.GetMembers

http://msdn.microsoft.com/library/de...mberstopic.asp

If want specific "types" of members instead of all members, try:

Type.GetProperties
Type.GetFields
Type.GetEvents
Type.GetMethods
Type.GetConstructors
Type.GetNestedTypes
--
Hope this helps
Jay [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
"Phill. W" <P.A.Ward@o-p-e-n-.-a-c-.-u-k> wrote in message
news:dl**********@yarrow.open.ac.uk...
| Does anyone happen to have a snippet of [VB 2003] code that,
| for a given Type, produces a list of [all] the properties, methods,
| constructors, and so on for that Class?
|
| TIA,
| Phill W.
|
|
Nov 23 '05 #3
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:Ow**************@TK2MSFTNGP10.phx.gbl...
"Phill. W" <P.A.Ward@o-p-e-n-.-a-c-.-u-k> schrieb:
Does anyone happen to have a snippet of [VB 2003] code that,
for a given Type, produces a list of [all] the properties, methods,
constructors, and so on for that Class?
I do not have such a snippet, but creatint such a snippet should not be

that hard when using the 'Type' class and its methods.


Herfried,

You're right; it's /not/ that bad - at least up to a point.
I've successfully iterated all my constructors, methods and properties
(using the fairly obvious GetConstructors, GetMethods, GetProperties),
but how do I pull out any Enum's my class might expose?

TIA,
Phill W.
Nov 23 '05 #4
Phill,
You would need to use Type.GetNestedTypes() to get any Enums (and other
types) that you may have nested inside another type.

FWIW: I rarely nest Enums inside of another type, rather I place them at
file scope either in with the primary type that uses them or in their own
file. Something like:

---x--- class1.vb ---x---
Public Enum Enum1
Value1
End Enum

Public Class Class1
...
End Class
---x---
---x--- Enum2.vb ---x---
Public Enum Enum2
Value1
End Enum
---x---

---x--- AnotherType.vb ---x---
Public Class AnotherType
...
End Class
---x---

--
Hope this helps
Jay [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
"Phill. W" <P.A.Ward@o-p-e-n-.-a-c-.-u-k> wrote in message
news:dl**********@yarrow.open.ac.uk...
| "Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
| news:Ow**************@TK2MSFTNGP10.phx.gbl...
| > "Phill. W" <P.A.Ward@o-p-e-n-.-a-c-.-u-k> schrieb:
| > > Does anyone happen to have a snippet of [VB 2003] code that,
| > > for a given Type, produces a list of [all] the properties, methods,
| > > constructors, and so on for that Class?
| >
| > I do not have such a snippet, but creatint such a snippet should not be
| that
| > hard when using the 'Type' class and its methods.
|
| Herfried,
|
| You're right; it's /not/ that bad - at least up to a point.
| I've successfully iterated all my constructors, methods and properties
| (using the fairly obvious GetConstructors, GetMethods, GetProperties),
| but how do I pull out any Enum's my class might expose?
|
| TIA,
| Phill W.
|
|
Nov 23 '05 #5

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

Similar topics

17
by: Phil Powell | last post by:
Where can I find an online PHP form validator script library to use? I have tried hacking the one here at work for weeks now and it's getting more and more impossible to customize, especially now...
2
by: Robert May | last post by:
We have a VB6 COM component that I don't have control over. All of the values are returned from method calls using byref parameters. They frequently break binary compatibility, in fact, there are...
6
by: someone | last post by:
Suppose that I have a class in an assembly that is delivered to the user, what can I do to change the class so that it doesn't break the binary compatibility? That is, user application can run...
47
by: Steven T. Hatton | last post by:
This is a purely *hypothetical* question. That means, it's /pretend/, CP. ;-) If you were forced at gunpoint to put all your code in classes, rather than in namespace scope (obviously classes...
2
by: danny van elsen | last post by:
hello all, in my application, I want to save the state of a number of classes to disk: what would be the best way to do this? right now, I'm hard coding the fields of the classes, but of course...
24
by: Alf P. Steinbach | last post by:
The eighth chapter (chapter 2.1) of my attempted Correct C++ tutorial is now available, although for now only in Word format -- comments welcome! Use the free & system-independent Open Office...
68
by: vim | last post by:
hello everybody Plz tell the differance between binary file and ascii file............... Thanks in advance vim
5
by: heddy | last post by:
I understand that reflection allows me to discover the metadata of a class at runtime (properties, methods etc). What I don't understand is where this is useful. For example: If I am the sole...
1
by: Simon Woods | last post by:
Hi I have a dll ('dll-X') which runs on top of (dependent upon) several other dlls. My build environment has a folder structure binaries compat-libs
17
by: osama178 | last post by:
Hi, What does it mean for an object to be binary compatible? And why aren't STL objects binary compatible? Any insights, links, resources for further reading are greatly appreciated. Thanks.
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.