我有一个类似这样的层次结构对象:
public class Department
{
public string Name { get; set; }
public string Manager { get; set; }
public Employee[] Employees { get; set; }
}
public class Employee
{
public string Name { get; set;}
public string Speciallity { get; set; }
}
我该如何创建一个自定义的.ps1xml文件,以便按以下形式显示 Department(s)
:
Department : Testers
Manager : P.H. Boss
Name Speciallity
---------- -----------------------------
Some Employee .Net
Another Employee BizTalk
Yet Another PowerShell
... ...
Department : Developers
Manager : Wally
Name Speciallity
---------- -----------------------------
Some Employee .Net
Another Employee BizTalk
Yet Another PowerShell
... ...
我遇到的主要问题是如何定义一个基于TableControl
的被选择的<View>
项目,但它在表格控件中显示Department.Employees
。我可以使用
View
完美地显示Employee
(s)。<View>
<Name>Employee</Name>
<ViewSelectedBy>
<TypeName>Employee</TypeName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>
<TableColumnHeader>
<Label>Name</Label>
<Width>30</Width>
</TableColumnHeader>
<TableColumnHeader>
<Label>Speciallity</Label>
<Width>50</Width>
</TableColumnHeader>
</TableHeaders>
<TableRowEntries>
<TableRowEntry>
<Wrap/>
<TableColumnItems>
<TableColumnItem>
<PropertyName>Name</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Speciallity</PropertyName>
</TableColumnItem>
</TableColumnItems>
</TableRowEntry>
</TableRowEntries>
</TableControl>
</View>
我可以使用列表格式来格式化部门:
<View>
<Name>TestResultSet</Name>
<ViewSelectedBy>
<TypeName>Department</TypeName>
</ViewSelectedBy>
<ListControl>
<ListEntries>
<ListEntry>
<ListItems>
<ListItem>
<Label>Department</Label>
<PropertyName>Name</PropertyName>
</ListItem>
<ListItem>
<PropertyName>Manager</PropertyName>
</ListItem>
</ListItems>
</ListEntry>
</ListEntries>
</ListControl>
</View>
但是我如何在部门之后添加员工表格?