Pattern matching i C#

Nyeste poster

60
Pattern matching i C#
public EstimatedToolRequirement[] Handle(EstimatedToolRequirementsQuery query)
{
    switch(query.OrderType)
    {
        case string s when s == EstimatedToolOrderType.ServiceOrder:
            return ToolRequirements(query.OrderNumber, ToolsRequirementPlanningOrderType.ServiceOrder);
        case string s when s == EstimatedToolOrderType.SFCProductionOrder:
            return ToolRequirements(query.OrderNumber, ToolsRequirementPlanningOrderType.SFCProductionOrder);
        case string s when s == EstimatedToolOrderType.MaintenanceWorkOrder:
            return ToolRequirements(query.OrderNumber, ToolsRequirementPlanningOrderType.MaintenanceWorkOrder);
        case string s when s == EstimatedToolOrderType.ProductionSchedule:
            return ToolRequirements(query.OrderNumber, ToolsRequirementPlanningOrderType.ProductionSchedule);
        default:
            return new EstimatedToolRequirement[0];
    }
     
    if(query.OrderType == EstimatedToolOrderType.ServiceOrder)
        return ToolRequirements(query.OrderNumber, ToolsRequirementPlanningOrderType.ServiceOrder);

    if (query.OrderType == EstimatedToolOrderType.SFCProductionOrder)
        return ToolRequirements(query.OrderNumber, ToolsRequirementPlanningOrderType.SFCProductionOrder);

    if (query.OrderType == EstimatedToolOrderType.MaintenanceWorkOrder)
        return ToolRequirements(query.OrderNumber, ToolsRequirementPlanningOrderType.MaintenanceWorkOrder);

    if (query.OrderType == EstimatedToolOrderType.ProductionSchedule)
        return ToolRequirements(query.OrderNumber, ToolsRequirementPlanningOrderType.ProductionSchedule);

    return new EstimatedToolRequirement[0];
}
×
×

Publiseringdetaljer

  • Postet opprinnelig:
  • Sist oppdatert:

Lesedetaljer

  • Antall ord: 83 ord
  • Lesetid: 1 minutt(er)

Versjoneringdetaljer

  • Commit hash for siste oppdatering: 37800ac
  • Dato for siste oppdateting: 2023-11-09
  • Navn på commit: 'Update reference for all posts'