I'm wondering wether there is a way to walk through every branch of this switch without using goto
public static List<KpiGroup> GetKpiGroups(int siteId, int topLevelProjectId, SiteDetailsModel.KpiCategory category, bool applyMapFilters)
{
var kpiGroups = new List<KpiGroup>();
switch (category)
{
case SiteDetailsModel.KpiCategory.Any:
case SiteDetailsModel.KpiCategory.Wbs:
kpiGroups.Add(KPIGetActiveSite(siteId, topLevelProjectId));
if (category == SiteDetailsModel.KpiCategory.Any)
goto task;
break;
case SiteDetailsModel.KpiCategory.Task:
task:
kpiGroups.Add(KPIGetTicketStatus(siteId, topLevelProjectId));
kpiGroups.Add(KPIGetTicketSeverityClosed(siteId, topLevelProjectId));
kpiGroups.Add(KPIGetTicketSeverityOpen(siteId, topLevelProjectId));
kpiGroups.Add(KPIGetTicketOwnerOpen(siteId, topLevelProjectId));
kpiGroups.Add(KPIGetTicketOwnerClosed(siteId, topLevelProjectId));
kpiGroups.Add(KPIGetTicketActivity(siteId, topLevelProjectId));
if (category == SiteDetailsModel.KpiCategory.Any)
goto sysConfig;
break;
case SiteDetailsModel.KpiCategory.SysConfig:
sysConfig:
kpiGroups.Add(KPIGetSysConfigOverview(siteId, topLevelProjectId));
kpiGroups.Add(KPIGetSysConfigDeviceTypes(siteId, topLevelProjectId));
kpiGroups.Add(KPIGetSysConfigLevel(siteId, topLevelProjectId));
break;
default:
throw new ArgumentOutOfRangeException(String.Format("GetKpiGroups {0}", category.ToString()));
}
return kpiGroups;
}
Wbs
,Task
, orSysConfig
) or all three, but not two out of three? \$\endgroup\$