Пример #1
0
        /// <remarks>
        /// use the usings and the name of the namespace to find a class
        /// </remarks>
        public IClass SearchType(string name, ICompilationUnit unit)
        {
//			Console.WriteLine("Searching Type " + name);
            if (name == null || name == String.Empty)
            {
//				Console.WriteLine("No Name!");
                return(null);
            }
            IClass c;

            c = parserService.GetClass(name);
            if (c != null)
            {
//				Console.WriteLine("Found!");
                return(c);
            }
//			Console.WriteLine("No FullName");
            if (unit != null)
            {
//				Console.WriteLine(unit.Usings.Count + " Usings");
                foreach (IUsing u in unit.Usings)
                {
                    if (u != null && (u.Region == null || u.Region.IsInside(caretLine, caretColumn)))
                    {
//						Console.WriteLine("In UsingRegion");
                        c = u.SearchType(name);
                        if (c != null)
                        {
//							Console.WriteLine("SearchType Successfull!!!");
                            return(c);
                        }
                    }
                }
            }
            if (callingClass == null)
            {
                return(null);
            }
            string fullname = callingClass.FullyQualifiedName;

            string[] namespaces   = fullname.Split(new char[] { '.' });
            string   curnamespace = namespaces[0] + '.';

            for (int i = 1; i < namespaces.Length; ++i)
            {
                c = parserService.GetClass(curnamespace + name);
                if (c != null)
                {
                    return(c);
                }
                curnamespace += namespaces[i] + '.';
            }
            return(null);
        }