是否可以使用 New-Module cmdlet 创建从另一个自定义类型派生的自定义类型?
例子:
function New-Shape
{
New-Module -ArgumentList $args -AsCustomObject {
param (
[string]$position
)
{
$script:position = $position
}
Export-ModuleMember -Variable Position
}
}
function New-Circle
{
# How to derive Circle from Shape?
New-Module -ArgumentList $args -AsCustomObject {
param (
[string]$radius
)
{
$script:radius = $radius
}
Export-ModuleMember -Variable Radius
}
}
# So that we can do
$circle = New-Circle $position $radius
$circle.Position
$circle.Radius