private Type GetTypeCore(string typeName) { #if SILVERLIGHT Assembly a = typeof(System.Action).Assembly; Type type = a.GetType(typeName, false); if (type != null) return type; foreach (System.Windows.AssemblyPart ap in System.Windows.Deployment.Current.Parts) { System.Windows.Resources.StreamResourceInfo sri = System.Windows.Application.GetResourceStream(new Uri(ap.Source, UriKind.Relative)); Assembly assembly = new System.Windows.AssemblyPart().Load(sri.Stream); type = assembly.GetType(typeName, false); if (type != null) return type; } #else // First - try all loaded types foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()) { Type type = assembly.GetType(typeName, false, true); if (type != null) return type; } #endif return type; }
根据类型名称获取类型的对象
最新推荐文章于 2023-03-15 19:07:59 发布