## New-GenericObject.ps1 ## Creates an object of a generic type: ## ## Usage: ## ## # Simple generic collection ## $list = New-GenericObject System.Collections.ObjectModel.Collection System.Int32 ## ## # Generic dictionary with two types ## New-GenericObject System.Collections.Generic.Dictionary System.String,System.Int32 ## ## # Generic list as the second type to a generic dictionary ## $secondType = New-GenericObject System.Collections.Generic.List Int32 ## New-GenericObject System.Collections.Generic.Dictionary System.String,$secondType.GetType() ## ## # Generic type with a non-default constructor ## New-GenericObject System.Collections.Generic.LinkedListNode System.Int32 10 ## param( ## Create the generic type name if(-not $genericType) ## Bind the type arguments to it ## Create the closed version of the generic type |
posh | Powershell >