我有一个像这样的分层对象结构:
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 ... ...
我遇到的主要问题是如何定义<View>
为 a 选择的项目,该项目Department
基于 a TableControl
,但Department.Employees
在表格控件中显示。
我可以Employee
使用 a 完美地显示(s)View
:
<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>
但是如何在部门之后添加员工表?