/// <summary> /// Provides the type associated to the name /// </summary> /// <param name="nameSpace">the namespace in which the name should be found</param> /// <param name="name"></param> /// <returns></returns> public Type FindType(Types.NameSpace nameSpace, string name) { Type retVal = null; if (name != null) { if (nameSpace != null) { if (!_cache.ContainsKey(nameSpace)) { _cache[nameSpace] = new Dictionary<string, Type>(); } Dictionary<string, Type> subCache = _cache[nameSpace]; if (!subCache.ContainsKey(name)) { Type tmp = null; if (!Utils.Util.isEmpty(name)) { tmp = nameSpace.findTypeByName(name); if (tmp == null) { if (DefinedTypes.ContainsKey(name)) { tmp = DefinedTypes[name]; } } if (tmp == null && DefinedTypes.ContainsKey("Default." + name)) { tmp = DefinedTypes["Default." + name]; } } subCache[name] = tmp; } retVal = subCache[name]; } else { if (DefinedTypes.ContainsKey(name)) { retVal = DefinedTypes[name]; } else if (DefinedTypes.ContainsKey("Default." + name)) { retVal = DefinedTypes["Default." + name]; } } } return retVal; }
/// <summary> /// Provides the type associated to the name /// </summary> /// <param name="nameSpace">the namespace in which the name should be found</param> /// <param name="name"></param> /// <returns></returns> public Type FindType(Types.NameSpace nameSpace, string name) { Type retVal = null; Dictionary<string, Type> definedTypes = DefinedTypes; if (name != null) { if (nameSpace != null) { CriticalSection.WaitOne(); try { if (!_cache.ContainsKey(nameSpace)) { _cache[nameSpace] = new Dictionary<string, Type>(); } Dictionary<string, Type> subCache = _cache[nameSpace]; if (!subCache.ContainsKey(name)) { Type tmp = null; if (!Utils.Util.isEmpty(name)) { tmp = nameSpace.findTypeByName(name); if (tmp == null) { if (definedTypes.ContainsKey(name)) { tmp = definedTypes[name]; } } if (tmp == null && definedTypes.ContainsKey("Default." + name)) { tmp = definedTypes["Default." + name]; } } subCache[name] = tmp; } retVal = subCache[name]; } finally { CriticalSection.ReleaseMutex(); } } else { if (definedTypes.ContainsKey(name)) { retVal = definedTypes[name]; } else if (definedTypes.ContainsKey("Default." + name)) { retVal = definedTypes["Default." + name]; } } } return retVal; }