Skip to content

Instantly share code, notes, and snippets.

@gaelcolas
Created April 21, 2016 10:59
Show Gist options
  • Save gaelcolas/cb45762b8aeb33bbd134eebe0cb41b77 to your computer and use it in GitHub Desktop.
Save gaelcolas/cb45762b8aeb33bbd134eebe0cb41b77 to your computer and use it in GitHub Desktop.
. .\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
}
}
@gaelcolas
Copy link
Author

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