NamespaceEntry GetNamespace (string name, bool createIfNotExtist)
		{
			NamespaceEntry result;
			if (!subEntries.TryGetValue (name, out result)) {
				if (!createIfNotExtist)
					return null;
				result = new NamespaceEntry (name);
				subEntries.Add (name, result);
			}
			return result;
		}
        public override IType GetType(string typeName, IList <IReturnType> genericArguments, bool deepSearchReferences, bool caseSensitive)
        {
            int genericArgumentCount = ExtractGenericArgCount(ref typeName);

            if (genericArguments != null)
            {
                genericArgumentCount = genericArguments.Count;
            }
            string decoratedTypeName = NamespaceEntry.GetDecoratedName(typeName, genericArgumentCount);
            //Console.WriteLine ("Get Type: >" + typeName+"< " + genericArgumentCount + " in " + this.Uri +  " deep refs:" + deepSearchReferences + " type count:" + Types.Count ());

            NamespaceEntry entry = rootNamespace.FindNamespace(decoratedTypeName, false);
            //Console.WriteLine ("found entry:" + entry);
            IType searchType;

            if (entry.ContainingTypes.TryGetValue(decoratedTypeName, out searchType))
            {
                IType result = CreateInstantiatedGenericType(searchType, genericArguments);
                //Console.WriteLine ("found type:" + result);
                return(result);
            }
            // may be inner type
            foreach (IType type in entry.ContainingTypes.Values)
            {
                string name = NamespaceEntry.GetDecoratedName(type);
                if (decoratedTypeName.StartsWith(name))
                {
                    string innerClassName = decoratedTypeName.Substring(name.Length + 1);
                    //Console.WriteLine ("icn:" + innerClassName);
                    IType inner = SearchInnerType(type, innerClassName, genericArgumentCount, caseSensitive);
                    if (inner != null)
                    {
                        //Console.WriteLine ("found inner:" + inner);
                        return(CreateInstantiatedGenericType(inner, genericArguments));
                    }
                }
            }

            /*
             * if (deepSearchReferences) {
             *      foreach (string uri in this.OnGetReferences ()) {
             *              ProjectDom dom = ProjectDomService.GetDomForUri (uri);
             *              if (dom != null) {
             *                      IType result = dom.GetType (typeName, genericArguments, false, caseSensitive);
             *                      if (result != null) {
             *                              //Console.WriteLine ("found in :" + uri + " : " + result);
             *                              return result;
             *                      }
             *              }
             *      }
             * }*/
            return(null);
        }
        NamespaceEntry GetNamespace(string name, bool createIfNotExtist)
        {
            NamespaceEntry result;

            if (!subEntries.TryGetValue(name, out result))
            {
                if (!createIfNotExtist)
                {
                    return(null);
                }
                result = new NamespaceEntry(name);
                subEntries.Add(name, result);
            }
            return(result);
        }
        internal List <IType> ResolveTypeParameters(IEnumerable <IType> types)
        {
            List <IType> result = new List <IType> ();

            foreach (IType type in types)
            {
                if (type.TypeParameters.Count == 0)
                {
                    result.Add(type);
                    continue;
                }
                GenericTypeInstanceResolver resolver = new GenericTypeInstanceResolver();
                string typeName = NamespaceEntry.GetDecoratedName(type);
                foreach (TypeParameter par in type.TypeParameters)
                {
                    resolver.Add(par.Name, new DomReturnType(NamespaceEntry.ConcatNamespaces(typeName, par.Name)));
                }
                resolver.Visit(type, type);
                result.Add((IType)type.AcceptVisitor(resolver, type));
            }
            return(result);
        }
        public NamespaceEntry FindNamespace(string ns, bool createIfNotExists, bool exactMatch)
        {
            //	if (string.IsNullOrEmpty (ns))
            //		return this;
            string[]       path = ns.Split('.');
            int            i    = 0;
            NamespaceEntry cur  = this;

            while (i < path.Length)
            {
                string nsName = path[i];
                if (!string.IsNullOrEmpty(nsName))
                {
                    NamespaceEntry next = cur.GetNamespace(nsName, createIfNotExists);
                    if (next == null)
                    {
                        return(exactMatch ? null : cur);
                    }
                    cur = next;
                }
                i++;
            }
            return(cur);
        }
 public virtual void Dispose()
 {
     units         = null;
     rootNamespace = null;
 }
 public override IType GetType(string typeName, int genericArgumentsCount, bool deepSearchReferences, bool caseSensitive)
 {
     return(GetType(NamespaceEntry.GetDecoratedName(typeName, genericArgumentsCount), null, deepSearchReferences, caseSensitive));
 }