예제 #1
0
        /// <summary>
        ///     This exception is semantically like the <paramref name="other" />
        ///     exception, and contains exceptions that are
        ///     <see cref="Like">alike</see>.
        /// </summary>
        /// <param name="other">The <see cref="SemanticException" /> to compare against.</param>
        /// <returns>
        ///     A boolean indicating whether <see cref="CompoundSemanticException">this</see>
        ///     and <paramref name="other" /> are alike.
        /// </returns>
        public override bool Like(SemanticException other)
        {
            if (!base.Like(other))
            {
                return(false);
            }

            CompoundSemanticException ce = (CompoundSemanticException)other;

            return((ce.Elements.Count == Elements.Count) &&
                   Elements.All(x => ce.Elements.Any(x.Like)) &&
                   ce.Elements.All(x => Elements.Any(x.Like)));
        }
예제 #2
0
        /// <summary>
        ///     Add an element exception to <see cref="Elements" />.
        /// </summary>
        /// <param name="exception">The exception that must be added.</param>
        public void AddElement(SemanticException exception)
        {
            Contract.Requires(exception != null);
            Contract.Requires(!Closed);
            Contract.Ensures(
                exception is CompoundSemanticException
                    ? ((CompoundSemanticException)exception).Elements.All(ContainsElement)
                    : Elements.Contains(exception));

            CompoundSemanticException cse = exception as CompoundSemanticException;

            if (cse == null)
            {
                Set.Add(exception);
            }
            else
            {
                foreach (SemanticException ex in cse.Elements)
                {
                    AddElement(ex);
                }
            }
        }