MakeCoercionError() public static méthode

public static MakeCoercionError ( RubyContext context, object self, object other ) : Exception
context RubyContext
self object
other object
Résultat System.Exception
Exemple #1
0
        /// <summary>
        /// Applies given operator on coerced values and returns the result.
        /// </summary>
        /// <exception cref="TypeError">
        /// "coerce" method is not defined, throws a subclass of SystemException, or returns something other than a pair of objects.
        /// </exception>
        public static object CoerceAndApply(BinaryOpStorage /*!*/ coercionStorage, BinaryOpStorage /*!*/ binaryOpStorage,
                                            string /*!*/ binaryOp, object self, object other)
        {
            object result;

            if (TryCoerceAndApply(coercionStorage, binaryOpStorage, binaryOp, self, other, out result))
            {
                return(result);
            }

            throw RubyExceptions.MakeCoercionError(coercionStorage.Context, other, self);
        }
Exemple #2
0
        /// <summary>
        /// Coerce the values of self and other (using other as the object) then call the passed in method.
        /// </summary>
        public static object CoerceAndCall(RubyContext /*!*/ context, object self, object other, DynamicInvocation invoke)
        {
            RubyArray coercedValues;

            try {
                // Swap self and other around to do the coercion.
                coercedValues = RubySites.Coerce(context, other, self);
            } catch (MemberAccessException x) {
                throw RubyExceptions.MakeCoercionError(context, self, other, x);
            } catch (ArgumentException x) {
                throw RubyExceptions.MakeCoercionError(context, self, other, x);
            }
            // But then swap them back when invoking the operation
            return(invoke(context, coercedValues[0], coercedValues[1]));
        }