コード例 #1
0
        /// <summary>
        /// Creates a new <see cref="GraphNode"/> based on the provided input.
        /// </summary>
        /// <param name="illustrationPoint">The illustration point.</param>
        /// <param name="childNodes">The child nodes of the illustration point.</param>
        /// <returns>The newly created <see cref="GraphNode"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when any input parameter is null.</exception>
        /// <exception cref="NotSupportedException">Thrown when <paramref name="illustrationPoint"/>
        /// is not of type <see cref="FaultTreeIllustrationPoint"/> or <see cref="SubMechanismIllustrationPoint"/>.</exception>
        public static GraphNode CreateGraphNode(IllustrationPointBase illustrationPoint, IEnumerable <GraphNode> childNodes)
        {
            if (illustrationPoint == null)
            {
                throw new ArgumentNullException(nameof(illustrationPoint));
            }

            if (childNodes == null)
            {
                throw new ArgumentNullException(nameof(childNodes));
            }

            var subMechanismIllustrationPoint = illustrationPoint as SubMechanismIllustrationPoint;

            if (subMechanismIllustrationPoint != null)
            {
                return(CreateEndGraphNode(illustrationPoint.Name,
                                          CreateGraphNodeContent(illustrationPoint.Beta)));
            }

            var faultTreeIllustrationPoint = illustrationPoint as FaultTreeIllustrationPoint;

            if (faultTreeIllustrationPoint != null)
            {
                return(CreateFaultTreeGraphNode(faultTreeIllustrationPoint,
                                                childNodes));
            }

            throw new NotSupportedException($"IllustrationPointNode of type {illustrationPoint.GetType().Name} is not supported. " +
                                            $"Supported types: {nameof(FaultTreeIllustrationPoint)} and {nameof(SubMechanismIllustrationPoint)}");
        }
コード例 #2
0
        /// <summary>
        /// Returns the stochasts of the <paramref name="illustrationPoint"/>.
        /// </summary>
        /// <param name="illustrationPoint">The illustration point to get the stochasts from.</param>
        /// <returns>The stochasts.</returns>
        /// <exception cref="NotSupportedException">Thrown when <paramref name="illustrationPoint"/>
        /// is not of type <see cref="FaultTreeIllustrationPoint"/> or <see cref="SubMechanismIllustrationPoint"/>.</exception>
        private static IEnumerable <Stochast> GetStochasts(IllustrationPointBase illustrationPoint)
        {
            switch (illustrationPoint)
            {
            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)}");
            }
        }