Automating the world one-liner at a time…
Here is a quick and dirty function I wrote after getting PO'd at having to look up documentation for constructors:
NOTE: Jim Truher thinks long typenames are useful so I added a switch (-FullName) so you could get them if you want them.
function get-Constructor ([type]$type, [Switch]$FullName){ foreach ($c in $type.GetConstructors()) { $type.Name + "(" foreach ($p in $c.GetParameters()) { if ($fullName) { "`t{0} {1}," -f $p.ParameterType.FullName, $p.Name }else { "`t{0} {1}," -f $p.ParameterType.Name, $p.Name } } ")" }}
PS> get-Constructor System.Windows.ThicknessThickness( Double uniformLength,)Thickness( Double left, Double top, Double right, Double bottom,)
PS>
PS> get-Constructor System.Datetime -FullNameDateTime( System.Int64 ticks,)DateTime( System.Int64 ticks, System.DateTimeKind kind,)DateTime( System.Int32 year, System.Int32 month, System.Int32 day,)DateTime( System.Int32 year, System.Int32 month, System.Int32 day, System.Globalization.Calendar calendar,)DateTime( System.Int32 year, System.Int32 month, System.Int32 day, System.Int32 hour, System.Int32 minute, System.Int32 second,)DateTime( System.Int32 year, System.Int32 month, System.Int32 day, System.Int32 hour, System.Int32 minute, System.Int32 second, System.DateTimeKind kind,)DateTime( System.Int32 year, System.Int32 month, System.Int32 day, System.Int32 hour, System.Int32 minute, System.Int32 second, System.Globalization.Calendar calendar,)DateTime( System.Int32 year, System.Int32 month, System.Int32 day, System.Int32 hour, System.Int32 minute, System.Int32 second, System.Int32 millisecond,)DateTime( System.Int32 year, System.Int32 month, System.Int32 day, System.Int32 hour, System.Int32 minute, System.Int32 second, System.Int32 millisecond, System.DateTimeKind kind,)DateTime( System.Int32 year, System.Int32 month, System.Int32 day, System.Int32 hour, System.Int32 minute, System.Int32 second, System.Int32 millisecond, System.Globalization.Calendar calendar,)DateTime( System.Int32 year, System.Int32 month, System.Int32 day, System.Int32 hour, System.Int32 minute, System.Int32 second, System.Int32 millisecond, System.Globalization.Calendar calendar, System.DateTimeKind kind,)Enjoy!
Jeffrey Snover [MSFT]Windows Management Partner ArchitectVisit the Windows PowerShell Team blog at: http://blogs.msdn.com/PowerShellVisit the Windows PowerShell ScriptCenter at: http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx
PingBack from http://www.alvinashcraft.com/2008/09/02/dew-drop-september-2-2008/
sometimes, it's good to know the fullname of the parameter type (since you might not know that Calendar is actually System.Globalization.Calendar. Changing $p.ParameterType.Name to $p.ParameterType.FullName gives you that!
DateTime(
System.Int32 year,
System.Int32 month,
System.Int32 day,
System.Int32 hour,
System.Int32 minute,
System.Int32 second,
System.Int32 millisecond,
System.Globalization.Calendar calendar,
System.DateTimeKind kind,
)