Skip to content

Instantly share code, notes, and snippets.

@spoon16
Created May 3, 2010 04:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spoon16/387768 to your computer and use it in GitHub Desktop.
Save spoon16/387768 to your computer and use it in GitHub Desktop.
Why is the output of this function (line:46 - $row) an instance of System.Array instead of an instance of Intellidimension.Rdf.TableRow?
function New-TableRow {
<#
.Synopsis
Creates a new table row that can be added to a table
.Description
Creates a new Intellidimension.Rdf.TableRow instance that can be added to a table
.Parameter cellCount
The number of cells the row will have
.Parameter table
The source table the new row should use as a template
.Parameter cells
The values that the new row should be initialized with
#>
[CmdletBinding(DefaultParameterSetName = "FromInt_ParamSet")]
param (
[Parameter(Mandatory = $true, Position = 0, ParameterSetName = "FromInt_ParamSet")]
[Alias("count")]
[int] $cellCount,
[Parameter(Mandatory = $true, Position = 0, ParameterSetName = "FromTable_ParamSet")]
[Alias("tbl", "t")]
[Intellidimension.Rdf.Table] $table,
[Parameter(Mandatory = $true, Position = 1)]
[Intellidimension.Rdf.RdfValue[]] $cells
)
# begin {
# }
process {
switch ($PsCmdlet.ParameterSetName) {
"FromTable_ParamSet" {
$row = $table.NewRow($cells)
}
"FromInt_ParamSet" {
$row = New-Object Intellidimension.Rdf.TableRow $cellCount
for ($i = 0; $i -lt $row.Count -and $i -lt $cells.Length; $i ++) {
$v = $cells[$i]
$row.Cells[$i] = $cells[$i]
}
}
}
, $row
}
# end {
# }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment