public void WildExceptionsTest()
 {
     foreach (AbstractRousseauObject aro in m_Subjects)
     {
         CompoundSemanticException cpe = aro.WildExceptions();
     }
 }
示例#2
0
        public override CompoundSemanticException WildExceptions()
        {
#if EXTRA_CONTRACTS
            Contract.Ensures(!State.HasValue ==
                             Contract.Result <CompoundSemanticException>().ContainsElement(new PropertyException(this, "State", ExceptionStrings.Mandatory, null)));
            Contract.Ensures(State.HasValue && !IsSingleTaskState(State.Value) ==
                             Contract.Result <CompoundSemanticException>().ContainsElement(new PropertyException(this, "State", ExceptionStrings.EnumFlagsSingleOption, null)));
            Contract.Ensures(string.IsNullOrEmpty(TaskType) ==
                             Contract.Result <CompoundSemanticException>().ContainsElement(new PropertyException(this, "TaskType", ExceptionStrings.Mandatory, null)));
            Contract.Ensures(string.IsNullOrEmpty(Reference) ==
                             Contract.Result <CompoundSemanticException>().ContainsElement(new PropertyException(this, "Reference", ExceptionStrings.Mandatory, null)));
#endif

            CompoundSemanticException cse = base.WildExceptions();

            if (!State.HasValue)
            {
                cse.AddElement(new PropertyException(this, "State", MandatoryMessage, null));
            }
            if (State.HasValue && !IsSingleTaskState(State.Value))
            {
                cse.AddElement(new PropertyException(this, "State", EnumFlagsSingleOption, null));
            }
            if (string.IsNullOrEmpty(TaskType))
            {
                cse.AddElement(new PropertyException(this, "TaskType", MandatoryMessage, null));
            }

            return(cse);
        }
        public void ThrowIfNotCivilized()
        {
            CompoundSemanticException cse = WildExceptions();

            if (cse != null && !cse.IsEmpty)
            {
                cse.Closed = true;
                throw cse;
            }
        }
示例#4
0
        public override CompoundSemanticException WildExceptions()
        {
            CompoundSemanticException sce = base.WildExceptions();

            if (Company == null)
            {
                sce.AddElement(new PropertyException(this, "Company", PropertyException.MandatoryMessage, null));
            }

            return(sce);
        }
示例#5
0
        public override CompoundSemanticException WildExceptions()
        {
            CompoundSemanticException cpe = base.WildExceptions();

            if (MockWild)
            {
                cpe.AddElement(new SemanticException("TEST"));
            }

            return(cpe);
        }
示例#6
0
        public static CompoundSemanticException Compact([CanBeNull] IEnumerable <CompoundSemanticException> compoundSemanticExceptions)
        {
            if ((compoundSemanticExceptions != null) && compoundSemanticExceptions.Any())
            {
                CompoundSemanticException compactedCompoundSemanticException = new CompoundSemanticException();
                foreach (CompoundSemanticException cse in compoundSemanticExceptions)
                {
                    foreach (SemanticException se in GetSemanticExceptions(cse).Where(se => !compactedCompoundSemanticException.ContainsElement(se)))
                    {
                        compactedCompoundSemanticException.AddElement(se);
                    }
                }

                return(compactedCompoundSemanticException);
            }

            return(null);
        }
示例#7
0
 public static IEnumerable <SemanticException> GetSemanticExceptions([CanBeNull] CompoundSemanticException cse)
 {
     if (cse != null)
     {
         foreach (SemanticException se in cse.Elements)
         {
             if (se is CompoundSemanticException cse2)
             {
                 foreach (SemanticException se2 in GetSemanticExceptions(cse2))
                 {
                     yield return(se2);
                 }
             }
             else
             {
                 yield return(se);
             }
         }
     }
 }
示例#8
0
 protected virtual IEnumerable <Message> Translate([NotNull] ExceptionContext context, [NotNull] CompoundSemanticException cse)
 {
     foreach (SemanticException exc in cse.Elements)
     {
         foreach (Message message in Translate(context, (dynamic)exc))
         {
             yield return(message);
         }
     }
 }