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

VBTeam

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)

0 comments

Leave a comment

Feedback usabilla icon