LINQ Cookbook, Recipe 4: Find all complex types in a given assembly (Kit George)

Published 27 June 07 06:30 PM

Ingredients:

-          Visual Studio 2008 (Beta2 or Higher)

-     An assembly which you want to analyze (in this example, we use mscorlib.dll, the assembly which houses String)

-     A definition for 'Complex Type'. In this instance, a complex type is defined as having more than 10 public methods, of which at least one has more than 3 arguments

 

Categories: LINQ-To-Objects, LINQ and types, LINQ and WinForms

 

Instructions:

-          Open Visual Studio 2008, and Click ‘File/New Project’. Find and double-click the ‘Windows Forms Application’ Icon

-          Drag and drop a Listbox to the form. Size the listbox to be fairly tall. Drag and drop a button to the form

-          Double-click the button, and add the following code to the button:

 

Dim q = From type In System.Reflection.Assembly.GetAssembly( _

                  GetType(String)).GetTypes(), _

                  m In type.GetMethods() _

        Where type.IsPublic _

                  AndAlso type.GetMethods.Length > 10 _

                  AndAlso m.GetParameters.Length > 3 _

        Select type Distinct

 

 

ListBox1.Items.AddRange(q.ToArray)

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# Bill_McC said on June 29, 2007 3:05 PM:

Where's the "t" in t.GetMethods() come from ?

# VBTeam said on June 29, 2007 4:30 PM:

thanks, fixed

# Public Sector Developer Weblog said on July 3, 2007 8:24 AM:

The VB team just started a LINQ Cookbook series. These are great because they show you how you can easily

# Noticias externas said on July 3, 2007 9:21 AM:

The VB team just started a LINQ Cookbook series. These are great because they show you how you can easily

# zack said on January 8, 2008 5:27 AM:

引用:LINQ菜谱,菜单4:查找给定程序集中所有复杂类型(KitGeorge) [原文作者]:KitGeorge

[原文链接]:LINQCookbook,Recipe4:F...

Leave a Comment

(required) 
(optional)
(required) 

  
Enter Code Here: Required

This Blog

Syndication

Page view tracker