public static CreateTypeConversionError ( string fromType, string toType ) : |
||
fromType | string | |
toType | string | |
return |
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_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(CallSite <Func <CallSite, object, MutableString> > /*!*/ toPath, object obj) { MutableString result = toPath.Target(toPath, obj); if (result == null) { throw RubyExceptions.CreateTypeConversionError("nil", "String"); } return(result); }
/// <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 string[] /*!*/ GetLoadPathStrings() { var loadPaths = GetLoadPaths(); var result = new string[loadPaths.Length]; for (int i = 0; i < loadPaths.Length; i++) { if (loadPaths[i] == null) { throw RubyExceptions.CreateTypeConversionError("nil", "String"); } result[i] = _toStrSite.Target(_toStrSite, _context.EmptyScope, loadPaths[i]).ConvertToString(); } return(result); }
internal string[] /*!*/ GetLoadPathStrings() { var loadPaths = GetLoadPaths(); var result = new string[loadPaths.Length]; var toPath = _toStrStorage.GetSite(CompositeConversionAction.Make(_context, CompositeConversion.ToPathToStr)); for (int i = 0; i < loadPaths.Length; i++) { if (loadPaths[i] == null) { throw RubyExceptions.CreateTypeConversionError("nil", "String"); } result[i] = Protocols.CastToPath(toPath, loadPaths[i]).ConvertToString(); } return(result); }
private bool IsFileLoaded(MutableString /*!*/ path) { foreach (object file in GetLoadedFiles()) { if (file == null) { throw RubyExceptions.CreateTypeConversionError("nil", "String"); } // case sensitive comparison: if (path.Equals(_toStrSite.Target(_toStrSite, _context.EmptyScope, file))) { return(true); } } return(false); }
internal string[] /*!*/ GetLoadPathStrings() { var loadPaths = GetLoadPaths(); var result = new string[loadPaths.Length]; var toStr = _toStrStorage.GetSite(ConvertToStrAction.Make(_context)); for (int i = 0; i < loadPaths.Length; i++) { if (loadPaths[i] == null) { throw RubyExceptions.CreateTypeConversionError("nil", "String"); } result[i] = toStr.Target(toStr, loadPaths[i]).ConvertToString(); } 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); }