private bool IsFileLoaded(string /*!*/ path, string /*!*/ fullPath, IEnumerable <string> appendExtensions) { var toPath = _toStrStorage.GetSite(CompositeConversionAction.Make(_context, CompositeConversion.ToPathToStr)); var encodedPath = _context.EncodePath(path); var encodedFullPath = (fullPath != null) ? _context.EncodePath(fullPath) : null; foreach (object file in GetLoadedFiles()) { if (file == null) { throw RubyExceptions.CreateTypeConversionError("nil", "String"); } // use case sensitive comparison MutableString loadedFile = Protocols.CastToPath(toPath, file); if (loadedFile.Equals(encodedPath) || loadedFile.Equals(encodedFullPath)) { return(true); } if (appendExtensions != null) { foreach (var extension in appendExtensions) { var pathWithExtension = _context.EncodePath(path + extension); if (loadedFile.Equals(pathWithExtension) || loadedFile.Equals(encodedFullPath)) { return(true); } } } } return(false); }
/// <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); }
private bool IsFileLoaded(MutableString /*!*/ path) { var toStr = _toStrStorage.GetSite(ConvertToStrAction.Make(_context)); foreach (object file in GetLoadedFiles()) { if (file == null) { throw RubyExceptions.CreateTypeConversionError("nil", "String"); } // case sensitive comparison: if (path.Equals(toStr.Target(toStr, file))) { return(true); } } return(false); }
private bool AnyFileLoaded(IEnumerable <MutableString> /*!*/ paths) { var toPath = _toStrStorage.GetSite(CompositeConversionAction.Make(_context, CompositeConversion.ToPathToStr)); foreach (object file in GetLoadedFiles()) { if (file == null) { throw RubyExceptions.CreateTypeConversionError("nil", "String"); } // use case sensitive comparison MutableString loadedPath = Protocols.CastToPath(toPath, file); if (paths.Any((path) => loadedPath.Equals(path))) { return(true); } } return(false); }
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)); }
/// <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)); }