예제 #1
0
        public override bool Equals(object obj)
        {
            var eqGoal = obj as EqGoal;

            if (eqGoal != null)
            {
                if (Rhs == null)
                {
                    return(Lhs.Equals(eqGoal.Lhs));
                }

                bool isNum1 = LogicSharp.IsNumeric(Rhs);
                bool isNum2 = LogicSharp.IsNumeric(eqGoal.Rhs);
                bool result;
                if (isNum1 && isNum2)
                {
                    result = LogicSharp.NumericEqual(Rhs, eqGoal.Rhs);
                }
                else
                {
                    result = Rhs.Equals(eqGoal.Rhs);
                }
                return(Lhs.Equals(eqGoal.Lhs) && result);
            }

            var eq = obj as Equation;

            if (eq != null)
            {
                if (Rhs == null)
                {
                    return(Lhs.Equals(eq.Lhs));
                }
                bool isNum1 = LogicSharp.IsNumeric(Rhs);
                bool isNum2 = LogicSharp.IsNumeric(eq.Rhs);
                bool result;
                if (isNum1 && isNum2)
                {
                    result = LogicSharp.NumericEqual(Rhs, eq.Rhs);
                }
                else
                {
                    result = Rhs.Equals(eq.Rhs);
                }

                if (eq.Lhs == null)
                {
                    return(false);
                }
                return(Lhs.ToString().Equals(eq.Lhs.ToString()) && result);
            }

            return(false);
        }
예제 #2
0
        public override bool Equals(object obj)
        {
            if (obj is Term)
            {
                var term = obj as Term;
                if (!Op.Equals(term.Op))
                {
                    return(false);
                }

                var lst  = Args as List <object>;
                var lst1 = term.Args as List <object>;
                Debug.Assert(lst != null);
                Debug.Assert(lst1 != null);
                if (lst.Count != lst1.Count)
                {
                    return(false);
                }

                for (int i = 0; i < lst.Count; i++)
                {
                    var curr1 = lst[i];
                    var curr2 = lst1[i];

                    bool isNum1 = LogicSharp.IsNumeric(curr1);
                    bool isNum2 = LogicSharp.IsNumeric(curr2);
                    bool result;
                    if (isNum1 && isNum2)
                    {
                        result = LogicSharp.NumericEqual(curr1, curr2);
                    }
                    else
                    {
                        if (curr1 == null || curr2 == null)
                        {
                            return(false);
                        }
                        result = curr1.Equals(curr2);
                    }
                    if (!result)
                    {
                        return(false);
                    }
                }
                return(true);
                //return !lst.Where((t, i) => !t.Equals(lst1[i])).Any();
            }
            return(false);
        }