Beispiel #1
0
        /// <summary>
        /// Creates all the top level fault tree illustration points based on the
        /// combinations of <see cref="HydraRingWindDirectionClosingSituation"/> and
        /// <see cref="HydraRingFaultTreeIllustrationPoint"/>.
        /// </summary>
        /// <param name="hydraRingTopLevelIllustrationPoints">The collection of
        /// <see cref="HydraRingWindDirectionClosingSituation"/> and <see cref="HydraRingFaultTreeIllustrationPoint"/>
        /// combinations to base the <see cref="TopLevelFaultTreeIllustrationPoint"/> on.</param>
        /// <returns>An <see cref="IEnumerable{T}"/> of <see cref="TopLevelFaultTreeIllustrationPoint"/>.</returns>
        /// <exception cref="IllustrationPointConversionException">Thrown when the combination of
        /// <see cref="HydraRingWindDirectionClosingSituation"/> and <see cref="HydraRingFaultTreeIllustrationPoint"/>
        /// cannot be converted to <see cref="TopLevelSubMechanismIllustrationPoint"/>.</exception>
        private static IEnumerable <TopLevelSubMechanismIllustrationPoint> GetTopLevelSubMechanismIllustrationPoints(
            IDictionary <HydraRingWindDirectionClosingSituation, HydraRingIllustrationPointTreeNode> hydraRingTopLevelIllustrationPoints)
        {
            var topLevelIlustrationPoints = new List <TopLevelSubMechanismIllustrationPoint>();

            foreach (KeyValuePair <HydraRingWindDirectionClosingSituation,
                                   HydraRingIllustrationPointTreeNode> topLevelIllustrationPointTreeNode in hydraRingTopLevelIllustrationPoints)
            {
                IHydraRingIllustrationPoint            hydraIllustrationPointData         = topLevelIllustrationPointTreeNode.Value.Data;
                HydraRingWindDirectionClosingSituation hydraWindDirectionClosingSituation = topLevelIllustrationPointTreeNode.Key;

                var subMechanismIllustrationPoint = hydraIllustrationPointData as HydraRingSubMechanismIllustrationPoint;
                if (subMechanismIllustrationPoint != null)
                {
                    topLevelIlustrationPoints.Add(TopLevelSubMechanismIllustrationPointConverter.Convert(
                                                      hydraWindDirectionClosingSituation, subMechanismIllustrationPoint));
                }
                else
                {
                    string exceptionMessage = $"Expected a fault tree node with data of type {typeof(HydraRingSubMechanismIllustrationPoint)} as root, " +
                                              $"but got {hydraIllustrationPointData.GetType()}";
                    throw new IllustrationPointConversionException(exceptionMessage);
                }
            }

            return(topLevelIlustrationPoints);
        }
        /// <summary>
        /// Creates a new instance of a <see cref="IllustrationPointBase"/> based on the
        /// <paramref name="data"/>.
        /// </summary>
        /// <param name="data">The <see cref="HydraRingIIllustrationPoint"/> to base the
        /// <see cref="IllustrationPointBase"/> to create on.</param>
        /// <returns>A <see cref="IllustrationPointBase"/>.</returns>
        /// <exception cref="IllustrationPointConversionException">Thrown when <paramref name="data"/>
        /// could not be converted.</exception>
        /// <exception cref="NotSupportedException">Thrown when no suitable conversion for <paramref name="data"/>
        /// was found.</exception>
        private static IllustrationPointBase ConvertIllustrationPointTreeNodeData(HydraRingIIllustrationPoint data)
        {
            var faultTreeIllustrationPoint = data as HydraRingFaultTreeIllustrationPoint;

            if (faultTreeIllustrationPoint != null)
            {
                return(FaultTreeIllustrationPointConverter.Convert(faultTreeIllustrationPoint));
            }

            var subMechanismIllustrationPoint = data as HydraRingSubMechanismIllustrationPoint;

            if (subMechanismIllustrationPoint != null)
            {
                return(SubMechanismIllustrationPointConverter.Convert(subMechanismIllustrationPoint));
            }

            throw new NotSupportedException($"Cannot convert {data.GetType()}.");
        }