CreateTypeConversionError() 공개 정적인 메소드

public static CreateTypeConversionError ( string fromType, string toType ) : Exception
fromType string
toType string
리턴 System.Exception
예제 #1
0
        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);
        }
예제 #2
0
        /// <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);
        }
예제 #3
0
        /// <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);
        }
예제 #4
0
        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);
        }
예제 #5
0
파일: Loader.cs 프로젝트: ife/IronLanguages
        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);
        }
예제 #6
0
        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);
        }
예제 #7
0
파일: Loader.cs 프로젝트: rudimk/dlr-dotnet
        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);
        }
예제 #8
0
파일: Loader.cs 프로젝트: rudimk/dlr-dotnet
        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);
        }
예제 #9
0
파일: Loader.cs 프로젝트: ife/IronLanguages
        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);
        }