Как правильно называется [ordered] в PowerShell 3.0?

В PowerShell вы можете указать тип с помощью квадратных скобок следующим образом:

PS C:\Users\zippy> [int]

IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     True     Int32                                    System.ValueType

Существуют также встроенные ускорители типов например [xml], который экономит несколько нажатий клавиш, когда вы хотите привести что-то к XmlDocument.

PS C:\Users\zippy> [xml]

IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     False    XmlDocument                              System.Xml.XmlNode

Вы можете сгенерировать список с помощью одной из двух команд:

  • PS v2.0 [type]::gettype("System.Management.Automation.TypeAccelerators")::Get
  • PS v3 .0 [psobject].assembly.gettype("System.Management.Automation.TypeAccelerators")::Get

PowerShell 3.0 добавляет оператор с именем [ordered]. Однако это не псевдоним типа.

PS C:\Users\zippy> [ordered]
Unable to find type [ordered]: make sure that the assembly containing this type is loaded.
At line:1 char:1
+ [ordered]
+ ~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (ordered:TypeName) [], RuntimeException
    + FullyQualifiedErrorId : TypeNotFound

Однако он может привести Hashtableк OrderedDictionarys.

PS C:\Users\zippy> ([ordered]@{}).GetType()

IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     True     OrderedDictionary                        System.Object

Итак, мой вопрос: если [ordered] не ускоритель типов, то что это такое?

5
задан Justin Dearing 15 June 2012 в 18:46
поделиться

0 ответов

Другие вопросы по тегам:

Похожие вопросы: