find() публичный статический Метод

public static find ( string sig ) : Type
sig string
Результат Type
Пример #1
0
        public static UriScheme find(string scheme, bool check)
        {
            // check cache
            lock (m_cache)
            {
                UriScheme cached = (UriScheme)m_cache[scheme];
                if (cached != null)
                {
                    return(cached);
                }
            }

            try
            {
                // lookup scheme type (avoid building index for common types)
                Type t = null;
                if (scheme == "fan")
                {
                    t = Sys.FanSchemeType;
                }
                if (scheme == "file")
                {
                    t = Sys.FileSchemeType;
                }
                if (t == null)
                {
                    string qname = (string)Env.cur().index("sys.uriScheme." + scheme).first();
                    if (qname == null)
                    {
                        throw UnresolvedErr.make().val;
                    }
                    t = Type.find(qname);
                }

                // allocate instance
                UriScheme s = (UriScheme)t.make();
                s.m_scheme = scheme;

                // add to cache
                lock (m_cache)
                {
                    UriScheme cached = (UriScheme)m_cache[scheme];
                    if (cached != null)
                    {
                        return(cached);
                    }
                    m_cache[scheme] = s;
                }

                return(s);
            }
            catch (UnresolvedErr.Val) {}
            catch (System.Exception e) { Err.dumpStack(e); }

            if (!check)
            {
                return(null);
            }
            throw UnresolvedErr.make("Unknown scheme: " + scheme).val;
        }
Пример #2
0
        int executeType(string target)
        {
            if (target.IndexOf("::") < 0)
            {
                target += "::Main.main";
            }
            else if (target.IndexOf('.') < 0)
            {
                target += ".main";
            }

            try
            {
                int    dot  = target.IndexOf('.');
                Type   type = Type.find(target.Substring(0, dot), true);
                Method main = type.method(target.Substring(dot + 1), true);
                return(callMain(type, main));
            }
            catch (Exception e)
            {
                if (e is Err.Val)
                {
                    ((Err.Val)e).err().trace();
                }
                else
                {
                    Err.dumpStack(e);
                }
                return(-1);
            }
        }
Пример #3
0
        //////////////////////////////////////////////////////////////////////////
        // Obj
        //////////////////////////////////////////////////////////////////////////

        public override Type @typeof()
        {
            if (m_type == null)
            {
                m_type = Type.find("concurrent::Future");
            }
            return(m_type);
        }
Пример #4
0
        //////////////////////////////////////////////////////////////////////////
        // Init Env
        //////////////////////////////////////////////////////////////////////////

        private static bool initEnv()
        {
            try
            {
                string var = (string)Env.cur().vars().get("FAN_ENV");
                if (var == null)
                {
                    return(true);
                }
                m_curEnv = (Env)Type.find(var).make();
            }
            catch (Exception e)
            {
                initWarn("curEnv", e);
            }
            return(true);
        }
Пример #5
0
        public static Slot find(string qname, bool check)
        {
            string typeName, slotName;

            try
            {
                int dot = qname.IndexOf('.');
                typeName = qname.Substring(0, dot);
                slotName = qname.Substring(dot + 1);
            }
            catch (Exception)
            {
                throw Err.make("Invalid slot qname \"" + qname + "\", use <pod>::<type>.<slot>").val;
            }
            Type type = Type.find(typeName, check);

            if (type == null)
            {
                return(null);
            }
            return(type.slot(slotName, check));
        }