Exemplo n.º 1
0
        /// <summary>
        /// Creates a new instance of <see cref="TopLevelFaultTreeIllustrationPoint"/>.
        /// </summary>
        /// <param name="windDirection">The wind direction.</param>
        /// <param name="closingSituation">The closing situation.</param>
        /// <param name="faultTreeNodeRoot">The illustration point root node.</param>
        /// <exception cref="ArgumentNullException">Thrown when any input parameter
        /// is <c>null</c>.</exception>
        public TopLevelFaultTreeIllustrationPoint(WindDirection windDirection,
                                                  string closingSituation,
                                                  IllustrationPointNode faultTreeNodeRoot)
            : base(windDirection, closingSituation)
        {
            if (faultTreeNodeRoot == null)
            {
                throw new ArgumentNullException(nameof(faultTreeNodeRoot));
            }

            FaultTreeNodeRoot = faultTreeNodeRoot;
        }
        /// <summary>
        /// Gets all the stochast names present in the <paramref name="illustrationPointNode"/> and its children.
        /// </summary>
        /// <param name="illustrationPointNode">The illustration point node
        /// to retrieve child stochast names from.</param>
        /// <returns>A list of all stochast names.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="illustrationPointNode"/>
        /// is <c>null</c>.</exception>
        public static IEnumerable <string> GetStochastNamesRecursively(this IllustrationPointNode illustrationPointNode)
        {
            if (illustrationPointNode == null)
            {
                throw new ArgumentNullException(nameof(illustrationPointNode));
            }

            List <string> stochastNames = illustrationPointNode.Children.SelectMany(GetStochastNamesRecursively).ToList();

            stochastNames.AddRange(illustrationPointNode.GetStochastNames());

            return(stochastNames);
        }
        /// <summary>
        /// Gets all the stochast names present in the <paramref name="illustrationPointNode"/>.
        /// </summary>
        /// <param name="illustrationPointNode">The <see cref="IllustrationPointNode"/>
        /// to retrieve stochast names from.</param>
        /// <returns>A list of all stochast names.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="illustrationPointNode"/>
        /// is <c>null</c>.</exception>
        public static IEnumerable <string> GetStochastNames(this IllustrationPointNode illustrationPointNode)
        {
            if (illustrationPointNode == null)
            {
                throw new ArgumentNullException(nameof(illustrationPointNode));
            }

            var faultTreeData = illustrationPointNode.Data as FaultTreeIllustrationPoint;

            if (faultTreeData != null)
            {
                return(faultTreeData.GetStochastNames());
            }

            var subMechanismData = illustrationPointNode.Data as SubMechanismIllustrationPoint;

            if (subMechanismData != null)
            {
                return(subMechanismData.GetStochastNames());
            }

            return(new List <string>());
        }