Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
. .\lib.common\MethodHelpers.ps1
. .\lib.common\PowerObject.ps1
function Get-Color{
[cmdletBinding()]
Param ()
DynamicParam {
[System.Drawing.Color]::FromName,[System.Drawing.Color]::FromKnownColor | Get-DynamicParamForMethod
}
process {
[System.Drawing.Color]::FromName,[System.Drawing.Color]::FromKnownColor | Invoke-MethodOverloadFromBoundParam -parameterSet $PSCmdlet.ParameterSetName -Parameters $PSBoundParameters
}
}
Owner

gaelcolas commented Apr 21, 2016

Slightly changed the code to allow several method through the use of the pipeline.
I haven't tested loads of cases, and there's no collision detection between the method signature.
If 2 methods have same empty signature it's probably not going to work, or if a parameter has the same name but different type. Be warned :)

Do provide me with example if stuff do not work, and I might have a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment