public static InvalidValueForType ( RubyContext context, object obj, string type ) : |
||
context | RubyContext | |
obj | object | |
type | string | |
리턴 |
public static Type /*!*/ ToType(RubyContext /*!*/ context, object value) { TypeTracker tt = value as TypeTracker; if (tt != null) { return(tt.Type); } RubyClass rc = value as RubyClass; if (rc != null) { return(rc.GetUnderlyingSystemType()); } throw RubyExceptions.InvalidValueForType(context, value, "Class"); }
public static Type /*!*/ ToType(RubyContext /*!*/ context, object value) { TypeTracker tt = value as TypeTracker; if (tt != null) { return(tt.Type); } RubyModule module = value as RubyModule; if (module != null && (module.IsClass || module.IsClrModule)) { return(module.GetUnderlyingSystemType()); } throw RubyExceptions.InvalidValueForType(context, value, "Class"); }
/// <summary> /// Try to cast the object to an Integer using to_int /// Returns null if the object doesn't implement to_int /// Can return either Bignum or Fixnum /// </summary> public static bool AsInteger(RubyContext /*!*/ context, object obj, out int fixnum, out BigInteger bignum) { // Don't call to_int on types derived from Integer if (AsPrimitiveInteger(obj, out fixnum, out bignum)) { return(true); } if (RubySites.RespondTo(context, obj, "to_int")) { object result = _ToInt.Target(_ToInt, context, obj); if (AsPrimitiveInteger(result, out fixnum, out bignum)) { return(true); } throw RubyExceptions.InvalidValueForType(context, result, "Integer"); } return(false); }