是否有一种方法可以从下面这样的类中获取数组,这样我就不必使用switch语句或dict或其他集合来查找传递给该方法的名称了?
export class ProcessOptions {
Arm = [{
name: 'Expedited Review ("ER") (not available for Level VI, Lung Cancer 2, or Foreign Claims)',
code: 25
},
{
name: 'Individual Review ("IR")',
code: 26
}
];
BW = [{
name: 'Expedited Review ("ER") (not available for Level VI, Lung Cancer 2, or Foreign Claims)',
code: 3
},
{
name: 'Individual Review ("IR")',
code: 4
}
];
GetProcessOptions(trust: string) {
return this.Arm;
}
}
您可以执行以下操作:
export class ProcessOptions {
Arm: [{
name: 'Expedited Review ("ER") (not available for Level VI, Lung Cancer 2, or Foreign Claims)',
code: 25
},
{
name: 'Individual Review ("IR")',
code: 26
}
],
BW: [{
name: 'Expedited Review ("ER") (not available for Level VI, Lung Cancer 2, or Foreign Claims)',
code: 3
},
{
name: 'Individual Review ("IR")',
code: 4
}
]
GetProcessOptions(trust: string) {
return this[trust];
}
}