Using System;
Using System. Collections. Generic;
Using System. IO;
Using System. reflection;
Using System. LINQ;
Namespace Sampleconsole
{
Class Program
{
Static Void Main ( String [] ARGs)
{
String Find = "Sessionstate" ;
String Dir = @ "D: \ project \ website \ XXX. Core \ trunk \ Lib \ DLL" ;
New Directoryinfo (DIR)
. Enumeratefiles ( "*. Dll" , Searchoption . Alldirectories)
. Asparallel ()
. Select (F => F. fullname)
. Select (P =>
{
Try
{
Return New
{
Path = P. tolower (). Replace (dir. tolower (), String . Empty ),
Assembly = Assembly . Loadfrom (P)
};
}
Catch ( Badimageformatexception ){ Return Null ;}
}). Where (x => X! = Null )
. Select (x =>
{
Try
{
Return New
{
Path = x. path,
Types = x. Assembly. gettypes (). asparallel ()
. Select (t => T. fullname)
. Where (S => S. indexof (FIND)>-1)
};
}
Catch ( Reflectiontypeloadexception ){ Return Null ;}
}). Where (x => X! = Null & X. types. Count ()> 0)
. Tolist ()
. Foreach (x =>
Console . Writeline (X. Path + "\ N" + X. types. Aggregate (a, B) => A + "\ N" + B) + "\ N" )
);
}
}
}