Here's a little function you might want to try.. (I haven't tested it yet, as I don't have any criteria to test this with easily..)
It can be used by supplying the paths (one or more full or relative paths separated by commas) on the command line like this
CheckForAbstractClassInheritance -Abstract System.Object -Assembly c:\assemblies\assemblytotest.dll, assemblytotest2.dll
or from the pipeline
'c:\assemblies\assemblytotest.dll','assemblytotest2.dll' | CheckForAbstractClassInheritance -Abstract System.Object
or with fileinfo objects from Get-Childitem (dir)
dir c:\assemblies *.dll | CheckForAbstractClassInheritance -Abstract System.Object
Tweak as needed..
function CheckForAbstractClassInheritance()
{
param ([string]$AbstractClassName, [string[]]$AssemblyPath = $null)
BEGIN
{
if ($AssemblyPath -ne $null)
{
$AssemblyPath | Load-AssemblyForReflection
}
}
PROCESS
{
if ($_ -ne $null)
{
if ($_ -is [FileInfo])
{
$path = $_.fullname
}
else
{
$path = (resolve-path $_).path
}
$types = ([system.reflection.assembly]::ReflectionOnlyLoadFrom($path)).GetTypes()
foreach ($type in $types)
{
if ($type.IsSubClassOf($AbstractClassName))
{
#If the type is a subclass of the requested type,
#write it to the pipeline
$type
}
}
}
}
}