Steve B
Steve B

Reputation: 37660

Syntax to be explained

In this script : WindowsCredentialVault.psm1, I see this code :

function InitializeWindowsCredential
{
    Write-Verbose ("Loading PasswordVault Class.")
    [void][Windows.Security.Credentials.PasswordVault,Windows.Security.Credentials,ContentType=WindowsRuntime]
}

InitializeWindowsCredential

However, I don't understand these syntax : [Windows.Security.Credentials.PasswordVault,Windows.Security.Credentials,ContentType=WindowsRuntime].

As far as I know, brackets are for specifying types. Here, there's multiple strings withing the brackets.

Is there any explanation about this syntax?

Upvotes: 1

Views: 93

Answers (1)

Remko
Remko

Reputation: 7330

This syntax is used to get a UWP class or type and appears to work like this:

[class/type name, namespace, ContentType = WindowsRuntime]

I couldn't find any documentation but this msdn blog link give some explanation: Loading WinRT Types via Reflection in Windows 8

EDIT: the purpose of the [void] preceeding the call is simply to surpress output as an object is returned:

PS C:\Users\me> [Windows.Security.Credentials.PasswordVault,Windows.Security.Credentials,ContentType=WindowsRuntime]

IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     False    PasswordVault                            System.Runtime.InteropServices.WindowsRuntime.RuntimeClass

Upvotes: 2

Related Questions