/// <summary> /// Converts an object to string using to_str protocol (<see cref="ConvertToStrAction"/>). /// </summary> public static MutableString /*!*/ CastToString(ConversionStorage <MutableString> /*!*/ stringCast, object obj) { var site = stringCast.GetSite(ConvertToStrAction.Make(stringCast.Context)); var result = site.Target(site, obj); if (result == null) { throw RubyExceptions.CreateTypeConversionError("nil", "String"); } return(result); }
internal Loader(RubyContext /*!*/ context) { Assert.NotNull(context); _context = context; _toStrStorage = new ConversionStorage <MutableString>(context); _loadPaths = MakeLoadPaths(context.RubyOptions); _loadedFiles = new RubyArray(); _unfinishedFiles = new Stack <string>(); #if FEATURE_ASSEMBLY_RESOLVE if (!context.RubyOptions.NoAssemblyResolveHook) { new AssemblyResolveHolder(this).HookAssemblyResolve(); } #endif }
public static void TryConvertToOptions(ConversionStorage <IDictionary <object, object> > /*!*/ toHash, ref IDictionary <object, object> options, ref object param1, ref object param2) { if (options == null && param1 != Missing.Value) { var toHashSite = toHash.GetSite(TryConvertToHashAction.Make(toHash.Context)); if (param2 != Missing.Value) { options = toHashSite.Target(toHashSite, param2); if (options != null) { param2 = Missing.Value; } } else { options = toHashSite.Target(toHashSite, param1); if (options != null) { param1 = Missing.Value; } } } }
public static int CastToFixnum(ConversionStorage <int> /*!*/ conversionStorage, object value) { var site = conversionStorage.GetSite(ConvertToFixnumAction.Make(conversionStorage.Context)); return(site.Target(site, value)); }
public static double CastToFloat(ConversionStorage <double> /*!*/ floatConversion, object value) { var site = floatConversion.GetSite(ConvertToFAction.Make(floatConversion.Context)); return(site.Target(site, value)); }
public static IntegerValue CastToInteger(ConversionStorage <IntegerValue> /*!*/ integerConversion, object value) { var site = integerConversion.GetSite(ConvertToIntAction.Make(integerConversion.Context)); return(site.Target(site, value)); }
public static IList TryConvertToArray(ConversionStorage <IList> /*!*/ tryToA, object obj) { var site = tryToA.GetSite(TryConvertToAAction.Make(tryToA.Context)); return(site.Target(site, obj)); }
public static IList TryCastToArray(ConversionStorage <IList> /*!*/ arrayTryCast, object obj) { var site = arrayTryCast.GetSite(TryConvertToArrayAction.Make(arrayTryCast.Context)); return(site.Target(site, obj)); }
public static RubyEncoding ConvertToEncoding(ConversionStorage <MutableString> /*!*/ toStr, object /*!*/ obj) { return(obj as RubyEncoding ?? toStr.Context.GetRubyEncoding(Protocols.CastToString(toStr, obj))); }
/// <summary> /// Convert to string using to_s protocol (<see cref="ConvertToSAction"/>). /// </summary> public static MutableString /*!*/ ConvertToString(ConversionStorage <MutableString> /*!*/ tosConversion, object obj) { var site = tosConversion.GetSite(ConvertToSAction.Make(tosConversion.Context)); return(site.Target(site, obj)); }
/// <summary> /// Converts an object to string using try-to_str protocol (<see cref="TryConvertToStrAction"/>). /// </summary> public static MutableString TryCastToString(ConversionStorage <MutableString> /*!*/ stringTryCast, object obj) { var site = stringTryCast.GetSite(TryConvertToStrAction.Make(stringTryCast.Context)); return(site.Target(site, obj)); }
/// <summary> /// Converts an object to string using to_path-to_str protocol. /// Protocol: /// ? to_path => to_path() and to_str conversion on the result /// ? to_str => to_str() /// </summary> public static MutableString /*!*/ CastToPath(ConversionStorage <MutableString> /*!*/ toPath, object obj) { return(CastToPath(toPath.GetSite(CompositeConversionAction.Make(toPath.Context, CompositeConversion.ToPathToStr)), obj)); }
/// <summary> /// Converts an object to string using to_str protocol (<see cref="ConvertToStrAction"/>). /// </summary> public static MutableString /*!*/ CastToString(ConversionStorage <MutableString> /*!*/ stringCast, object obj) { return(CastToString(stringCast.GetSite(ConvertToStrAction.Make(stringCast.Context)), obj)); }