예제 #1
0
        public ConstraintResult Constrain(PlanningItem pi)
        {
            var c1passed = C1.Constrain(pi);
            var c2passed = C2.Constrain(pi);

            var passed = c1passed.IsSuccess && c1passed.IsSuccess ||
                         c2passed.IsSuccess && c2passed.IsSuccess;

            var msg =
                $"{(passed ? "One or both constraints passed" : "Neither constraint passed")} \n{c1passed.Message} \n{c2passed.Message}";

            return(new ConstraintResult(this, passed ? PASSED : GetFailedResultType(), msg,
                                        $"{c1passed.Value}/{c2passed.Value}"));
        }
예제 #2
0
        public ConstraintResult Constrain(PlanningItem pi)
        {
            ConstraintResult c1passed = new ConstraintResult(C1, ResultType.ACTION_LEVEL_3, string.Empty);
            ConstraintResult c2passed = new ConstraintResult(C1, ResultType.ACTION_LEVEL_3, string.Empty);

            try { if (C1.CanConstrain(pi).IsSuccess)
                  {
                      c1passed = C1.Constrain(pi);
                  }
            } catch (Exception e) { c1passed.Message = e.Message; }
            try { if (C2.CanConstrain(pi).IsSuccess)
                  {
                      c2passed = C2.Constrain(pi);
                  }
            } catch (Exception e) { c2passed.Message = e.Message; }

            var passed = c1passed.IsSuccess || c2passed.IsSuccess;

            var msg =
                $"{(passed ? "One or both constraints passed" : "Neither constraint passed")} \n{c1passed.Message} \n{c2passed.Message}";

            return(new ConstraintResult(this, passed ? PASSED : GetFailedResultType(), msg,
                                        $"{c1passed.Value}/{c2passed.Value}"));
        }