By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,512 Members | 3,689 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,512 IT Pros & Developers. It's quick & easy.

Enumerating built-in and custom Types available

P: n/a
I'm building an application generator and within it a user can create a new
property (for the class they are building). I'd like then to offer a list of
Types - built-in and custom - for this new property to be shown in a combo
box ie similar to Intellisense.

How do you enumerate the Types available? Are their mechanisms for filtering
the list to show only (say) primitive types or custom types or reference
types?

TIA

Crispin

Nov 21 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
"CrispinH" <Cr******@discussions.microsoft.com> schrieb:
I'm building an application generator and within it a user can create a
new
property (for the class they are building). I'd like then to offer a list
of
Types - built-in and custom - for this new property to be shown in a combo
box ie similar to Intellisense.

How do you enumerate the Types available? Are their mechanisms for
filtering
the list to show only (say) primitive types or custom types or reference
types?


At runtime: 'System.Reflection', 'Assembly.GetTypes', 'Type' class, ...

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

Nov 21 '05 #2

P: n/a
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> escribió en el mensaje
news:un*************@TK2MSFTNGP10.phx.gbl...
At runtime: 'System.Reflection', 'Assembly.GetTypes', 'Type' class, ...


Assembly.GetExportedTypes() will perform better, since you are interested
normally in public types...

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com
Nov 21 '05 #3

P: n/a
Herfried

Thanks for that. Reflection was the clue I needed, but I'm not completely
where I want to be. Since I'm effectively trying to emulate VB.NET:

Dim objObject As ...

where the ... is the IntelliSense drop-down box. Thus far I've created test
code:

Dim objSystemObjectAssembly As [Assembly] =
[Assembly].GetAssembly(GetType(System.Object))
Dim objTypes() As Type = objSystemObjectAssembly.GetTypes

I chose the System.Object which returns 1480 items, many of which are not
relevant, so I filtered out those that weren't 'Public'.

However in a Visual Studio project, one puts in references eg:

System
System.Data
System.Drawing
System.Windows.Forms
System.XML

and this extends the Types available. I'd like to do a similar thing for my
users. I could pick an object at random in (say) System.Data and replace
System.Object in the above code, but this doesn't seem very elegant. Is
there a better way of achieving this?

Regards

Crispin

"Herfried K. Wagner [MVP]" wrote:
"CrispinH" <Cr******@discussions.microsoft.com> schrieb:
I'm building an application generator and within it a user can create a
new
property (for the class they are building). I'd like then to offer a list
of
Types - built-in and custom - for this new property to be shown in a combo
box ie similar to Intellisense.

How do you enumerate the Types available? Are their mechanisms for
filtering
the list to show only (say) primitive types or custom types or reference
types?


At runtime: 'System.Reflection', 'Assembly.GetTypes', 'Type' class, ...

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

Nov 21 '05 #4

P: n/a
Carlos

I tried GetExportedTypes instead of GetTypes and the count on the System
Object fell from 1480 to 905 which is a benefit. Filtering to include only
Public types brings it to 174 again (same for both).

I think I may to to implement some kind of Frequently Used Types system.

Thanks for your help.
Crispin

"Carlos J. Quintero [.NET MVP]" wrote:
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> escribió en el mensaje
news:un*************@TK2MSFTNGP10.phx.gbl...
At runtime: 'System.Reflection', 'Assembly.GetTypes', 'Type' class, ...


Assembly.GetExportedTypes() will perform better, since you are interested
normally in public types...

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com

Nov 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.