Question

I have a powershell module that wraps around some web services. The web services take complex Plain Old Dot Net Objects (PODOs) and I have been using HashTables as in cmdlet parameters and New-Object MyPODO -Property $MyHashTable to transform the hashtable into the request object like so

function Get-Stuff ([HashTable]$WhatStuff) {
    $service = New-ServiceProxy . . . .
    $request = New-Object GetStuffRequest -Property $WhatStuff;
    return $service.GetStuff($request);
    $response;
}

However, sometimes I have a cmdlet whose response object can directly become a request object like so:

function Find-Stuff ([HashTable]$KindaStuff) {
    $service = New-ServiceProxy . . . .
    $request = New-Object GetStuffRequest -Property $KindaStuff;
    return $service.SearchStuff($request);
}

Is there some sort of way to decorate the $WhatStuff parameter to accept either a HashTable or a PODO of a particular type?

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top