0
我有我試圖腳本對其中最重要的一個調用有以下方法簽名的C#庫:將接口類型傳遞給Powershell腳本中的c#?
DoThing(IDictionary<int, IList<int>> dict)
我需要編寫構建中要傳遞的對象PowerShell腳本我已經寫了PowerShell來構造同樣的事情,但具體類:
$myArg= New-Object 'Collections.Generic.Dictionary[int, Collections.Generic.List[int]]'
$list = New-Object 'Collections.Generic.List[int]'
$myArg.Add(7, $list)
[PowershellReflectionTest.ReflectionTester]::DoThing($myArg)
然而,這有效地創建一個Dictionary<int, List<int>>
對象,這是(出於某種原因,我不知道爲什麼)不符合IDictionary<int, IList<int>>
。
如何在PowerShell中創建兼容類型?
哇。我不敢相信我沒有想過這樣做。我之所以假設,是因爲在PowerShell中沒有強大的左側輸入,它不足以滿足任何需求。 – Benjin