Beispiel #1
0
        public override bool Evaluate(IInternalContextAdapter context)
        {
            Object left  = GetChild(0).Value(context);
            Object right = GetChild(1).Value(context);

            try
            {
                return(ObjectComparer.CompareObjects(left, right) != 0);
            }
            catch
            {
                // Ignore, we can't compare decently by value, but we honestly don't give a sh*t
            }

            // If we can't actually compare the objects, try the operator as fallback
            // For operator overloaded types, this will not really be a reference comp, but that's ok.
            return(left != right);
        }
Beispiel #2
0
        /// <summary>
        /// Calculates the value of the logical expression
        ///
        /// arg1 == arg2
        ///
        /// All class types are supported.   Uses equals() to
        /// determine equivalence.  This should work as we represent
        /// with the types we already support, and anything else that
        /// implements equals() to mean more than identical references.
        /// </summary>
        /// <param name="context"> internal context used to evaluate the LHS and RHS </param>
        /// <returns>
        /// true if equivalent, false if not equivalent,
        /// false if not compatible arguments, or false
        /// if either LHS or RHS is null
        /// </returns>
        public override bool Evaluate(IInternalContextAdapter context)
        {
            Object left  = GetChild(0).Value(context);
            Object right = GetChild(1).Value(context);

            // for equality, they are allowed to be null references
            try
            {
                if (ObjectComparer.CompareObjects(left, right) == 0)
                {
                    return(true);
                }
            }
            catch
            {
                // Ignore, we can't compare decently by value, but we honestly don't give a sh*t
            }

            // They are not equal by value, try a reference comparison
            // reference equal => definitely equal objects ;)
            // For operator overloaded types, this will not really be a reference comp, but that's ok.
            return(left == right);
        }