Type FindType(string name) { foreach (string use in usings) { name = (use != "" ? use + "." : "") + name; if (name.Contains('.')) { name += "."; int i = 0; i = name.IndexOf('.'); string first = name.Substring(0, i); Type t = null; while ((t = Type.GetType(name.Substring(0, i))) == null) { i = name.IndexOf('.', i + 1); } return t; } else { Type t = Type.GetType(name); if (t != null) return t; } } throw new Exception("Type not found: " + name); }