Exemplo n.º 1
0
        public TypeReference ResolveTypeName(string typeNameString)
        {
            if (string.IsNullOrEmpty(typeNameString))
            {
                return(null);
            }

            TypeName parsedTypeName;

            try {
                parsedTypeName = TypeParser.ParseTypeName(typeNameString);
            } catch (ArgumentException) {
                return(null);
            } catch (System.IO.FileLoadException) {
                return(null);
            }

            if (parsedTypeName is AssemblyQualifiedTypeName assemblyQualifiedTypeName)
            {
                return(ResolveTypeName(null, assemblyQualifiedTypeName));
            }

            foreach (var assemblyDefinition in _context.GetReferencedAssemblies())
            {
                var foundType = ResolveTypeName(assemblyDefinition, parsedTypeName);
                if (foundType != null)
                {
                    return(foundType);
                }
            }

            return(null);
        }