Esempio n. 1
0
        public bool ApproximateMatch(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.NumericApproximateEqual(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.NumericApproximateEqual(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);
        }