Index: Riskeer/Common/src/Riskeer.Common.Forms/Views/GeneralResultFaultTreeIllustrationPointView.cs =================================================================== diff -u -r5caf7b7a82d7d6803feb223fd0e13e629ca9a651 -r4d30d1d25f7571ffaf029d0ad65b7dc315bdbf5c --- Riskeer/Common/src/Riskeer.Common.Forms/Views/GeneralResultFaultTreeIllustrationPointView.cs (.../GeneralResultFaultTreeIllustrationPointView.cs) (revision 5caf7b7a82d7d6803feb223fd0e13e629ca9a651) +++ Riskeer/Common/src/Riskeer.Common.Forms/Views/GeneralResultFaultTreeIllustrationPointView.cs (.../GeneralResultFaultTreeIllustrationPointView.cs) (revision 4d30d1d25f7571ffaf029d0ad65b7dc315bdbf5c) @@ -75,10 +75,7 @@ public object Data { - get - { - return data; - } + get => data; set { data = value as ICalculation; @@ -132,17 +129,15 @@ ? topLevelFaultTreeIllustrationPoint.ClosingSituation : string.Empty; - var faultTreeIllustrationPoint = selection.Data as FaultTreeIllustrationPoint; - if (faultTreeIllustrationPoint != null) + if (selection.Data is FaultTreeIllustrationPoint faultTreeIllustrationPoint) { Selection = new IllustrationPointContext(faultTreeIllustrationPoint, selection, topLevelFaultTreeIllustrationPoint.WindDirection.Name, closingSituation); } - var subMechanismIllustrationPoint = selection.Data as SubMechanismIllustrationPoint; - if (subMechanismIllustrationPoint != null) + if (selection.Data is SubMechanismIllustrationPoint subMechanismIllustrationPoint) { Selection = new IllustrationPointContext(subMechanismIllustrationPoint, selection, @@ -188,20 +183,17 @@ /// is not of type or . private static IEnumerable GetStochasts(IllustrationPointBase illustrationPoint) { - var faultTreeIllustrationPoint = illustrationPoint as FaultTreeIllustrationPoint; - if (faultTreeIllustrationPoint != null) + switch (illustrationPoint) { - return faultTreeIllustrationPoint.Stochasts; + case FaultTreeIllustrationPoint faultTreeIllustrationPoint: + return faultTreeIllustrationPoint.Stochasts; + case SubMechanismIllustrationPoint subMechanismIllustrationPoint: + return subMechanismIllustrationPoint.Stochasts; + default: + throw new NotSupportedException( + $"IllustrationPointNode of type {illustrationPoint.GetType().Name} is not supported. " + + $"Supported types: {nameof(FaultTreeIllustrationPoint)} and {nameof(SubMechanismIllustrationPoint)}"); } - - var subMechanismIllustrationPoint = illustrationPoint as SubMechanismIllustrationPoint; - if (subMechanismIllustrationPoint != null) - { - return subMechanismIllustrationPoint.Stochasts; - } - - throw new NotSupportedException($"IllustrationPointNode of type {illustrationPoint.GetType().Name} is not supported. " + - $"Supported types: {nameof(FaultTreeIllustrationPoint)} and {nameof(SubMechanismIllustrationPoint)}"); } private void UpdateIllustrationPointsFaultTreeControl() @@ -229,8 +221,7 @@ /// or . private void ProvideIllustrationPointSelection() { - var selection = illustrationPointsControl.Selection as IllustrationPointControlItem; - Selection = selection != null + Selection = illustrationPointsControl.Selection is IllustrationPointControlItem selection ? new SelectedTopLevelFaultTreeIllustrationPoint((TopLevelFaultTreeIllustrationPoint) selection.Source, GetIllustrationPointControlItems().Select(ipci => ipci.ClosingSituation)) : null;