コード例 #1
0
        /// <summary>
        /// Gets all the stochast names present in the <paramref name="faultTreeIllustrationPoint"/>.
        /// </summary>
        /// <param name="faultTreeIllustrationPoint">The <see cref="FaultTreeIllustrationPoint"/>
        /// to retrieve stochast names from.</param>
        /// <returns>A collection of all stochast names.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="faultTreeIllustrationPoint"/>
        /// is <c>null</c>.</exception>
        public static IEnumerable <string> GetStochastNames(this FaultTreeIllustrationPoint faultTreeIllustrationPoint)
        {
            if (faultTreeIllustrationPoint == null)
            {
                throw new ArgumentNullException(nameof(faultTreeIllustrationPoint));
            }

            return(faultTreeIllustrationPoint.Stochasts.Select(s => s.Name));
        }
コード例 #2
0
        /// <summary>
        /// Validates a <see cref="FaultTreeIllustrationPoint"/> by comparing the stochasts in child nodes with its
        /// own stochasts.
        /// </summary>
        /// <param name="data">The <see cref="FaultTreeIllustrationPoint"/> to be validated.</param>
        /// <param name="children">The collection of <see cref="IllustrationPointNode"/> to be validated.</param>
        /// <exception cref="ArgumentException">Thrown when <paramref name="children"/> contains stochasts that
        /// are not in <paramref name="data"/>'s stochasts.</exception>
        private static void ValidateChildStochasts(FaultTreeIllustrationPoint data, IEnumerable <IllustrationPointNode> children)
        {
            List <string> stochastNames = children.SelectMany(c => c.GetStochastNames()).ToList();

            if (data.GetStochastNames().Intersect(stochastNames).Count() != stochastNames.Distinct().Count())
            {
                throw new ArgumentException(string.Format(Resources.Child_stochasts_not_same_as_parent_stochasts));
            }
        }