列挙体の確認はGetNamesメソッドを使用して、以下のように確認することが可能です。
PS > [System.ConsoleColor]::GetNames([System.ConsoleColor]) Black DarkBlue DarkGreen DarkCyan DarkRed DarkMagenta DarkYellow Gray DarkGray Blue Green Cyan Red Magenta Yellow White
System.ConsoleColorのところを変更すれば、他の列挙体も確認することができます。
しかし、見てわかるように、System.ConsoleColor を2度書く必要があるので面倒です。
ということで、関数にしてみました。
#========================================================================================= # Get-EnumLis: 指定された列挙体の値を表示する # # UPDATE 2008/06/04 Ver.1.0.0 # # copyright HIRO's.NET(http://hiros-dot.net/) #========================================================================================= function global:Get-EnumList([System.Type]$enum_name) { $enum_name::GetNames($enum_name) }
この関数は、下記のようにして使用します。
PS > Get-EnumList System.ConsoleColor Black DarkBlue DarkGreen DarkCyan DarkRed DarkMagenta DarkYellow Gray DarkGray Blue Green Cyan Red Magenta Yellow White
Theme design by Jelle Druyts
Pick a theme: BlogXP business calmBlue Candid Blue dasBlog dasblogger DirectionalRedux Discreet Blog Blue Elegante essence Just Html MadsSimple Mobile Mono Movable Radio Blue Movable Radio Heat nautica022 orangeCream Portal Project84 Project84Grass Slate Sound Waves Tricoleur useit.com Voidclass2 BlogXP business calmBlue Candid Blue dasBlog dasblogger DirectionalRedux Discreet Blog Blue Elegante essence Just Html MadsSimple Mobile Mono Movable Radio Blue Movable Radio Heat nautica022 orangeCream Portal Project84 Project84Grass Slate Sound Waves Tricoleur useit.com Voidclass2
Powered by: newtelligence dasBlog 2.0.7226.0
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
© Copyright 2009, HIRO
E-mail