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

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

  • Comments 5

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)
Leave a Comment
  • Please add 6 and 1 and type the answer here:
  • Post
  • Where's the "t" in t.GetMethods() come from ?

  • thanks, fixed

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

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

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

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

Page 1 of 1 (5 items)