Ejemplo n.º 1
0
        public UserType Resolve(string tname, bool errors)
        {
            if (tname.IndexOf('.') >= 0)
            {
                return(driver.LookupFQN(tname, !errors));
            }

            // Not fully-qualified. Spelunk namespaces.

            UserType ut = null;

            //Console.WriteLine ("Trying to look up {0}", tname);

            foreach (string ns in AllUsings)
            {
                string   full = ns + "." + tname;
                UserType hit  = driver.LookupFQN(full, !errors);

                //Console.WriteLine ("       {0} -> {1}", full, hit);

                if (hit == null)
                {
                    continue;
                }

                if (errors && ut != null && !ut.Equals(hit))
                {
                    string s = String.Format("Ambiguous type name {0}: could be {1} " +
                                             "or {2}", tname, ut, hit);
                    throw new Exception(s);
                }

                ut = hit;
            }

            if (errors && ut == null)
            {
                throw new Exception("Could not resolve the type name " + tname);
            }

            return(ut);
        }