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-11-23 16:51:58 发布
本文介绍了一个跨域查找类型的实现方法,该方法能够在不同程序集或Silverlight部署部分中搜索指定类型的名称,并返回相应的Type对象。根据环境的不同,分别采用了针对Silverlight和非Silverlight的实现策略。
278

被折叠的 条评论
为什么被折叠?



