vendredi 6 septembre 2019

How do I get the overload definitions programmatically from all constructors?

I am able to get overload definitions from interactive session.

How do I do this programmatically in powershell for reflective types.

$Assembly=[appdomain]::currentdomain.GetAssemblies() | Where-Object Location -match 'FileNet.API'
$Class=$Assembly.GetModules().gettypes()
$Constructors=$Class.GetMembers()| where-object {$_.IsConstructor -eq $True}| where-object {$_.IsPublic-eq $True}


foreach ($constructor in $Constructors) {
    $myconstructor=$constructor.DeclaringType.ToString()
    if ($myconstructor -eq "FileNet.Api.Core.Factory+Domain") {
        [type]$mytype=$constructor.DeclaringType
        "========================================="
        $myconstructor
        "========================================="
        $Members=($mytype.DeclaredMembers).Name
        foreach ($Member in $Members) {
            $mytype::$Member.OverloadDefinition
        }
    }
}
111

PS> $Definition=$mytype::FetchInstance.OverloadDefinitions
PS> $Definition
static FileNet.Api.Core.IDomain FetchInstance(FileNet.Api.Core.IConnection conn, string name, FileNet.Api.Property.PropertyFilter filter)





Aucun commentaire:

Enregistrer un commentaire