IronRuby.Builtins.Comparable.Compare C# (CSharp) Method

Compare() private static method

Try to compare the lhs and rhs. Throws and exception if comparison returns null. Returns null on failure, -1/0/+1 otherwise.
private static Compare ( BinaryOpStorage compareStorage, BinaryOpStorage lessThanStorage, BinaryOpStorage greaterThanStorage, object lhs, object rhs ) : int?
compareStorage BinaryOpStorage
lessThanStorage BinaryOpStorage
greaterThanStorage BinaryOpStorage
lhs object
rhs object
return int?
        private static int? Compare(BinaryOpStorage/*!*/ compareStorage, BinaryOpStorage/*!*/ lessThanStorage, BinaryOpStorage/*!*/ greaterThanStorage,
            object lhs, object rhs) {

            // calls method_missing, doesn't catch any exception:
            var compare = compareStorage.GetCallSite("<=>");
            object compareResult = compare.Target(compare, lhs, rhs);
            
            if (compareResult != null) {
                return Protocols.ConvertCompareResult(lessThanStorage, greaterThanStorage, compareResult);
            } else {
                throw RubyExceptions.MakeComparisonError(lessThanStorage.Context, lhs, rhs);
            }
        }