【发布时间】:2013-12-13 22:58:48
【问题描述】:
我目前正在尝试将 Xamarin.iOS 应用程序库转换为 PCL(配置文件 78)。我有这段代码无法编译:
public static void RegisterAllCommandHandlers(IEnumerable<Assembly> assemblies) {
// Get all types that are concrete classes which implement ICommandHandler
var commandHandlerOpenGenericType = typeof(ICommandHandler<>);
var types = new List<Type>();
foreach (var assembly in assemblies) {
types.AddRange(assembly.GetTypes()
.Where(x => x.IsClass && !x.IsAbstract && x.GetInterfaces().Any(i => i.IsGenericType && i.GetGenericTypeDefinition() == commandHandlerOpenGenericType)));
}
}
这是编译器错误的图像:
如何使用新的反射 API 做同样的事情?
【问题讨论】:
-
您在 PCL 中针对哪些平台?
-
@Markus Profile 78(Xamarin.IOS、Xamarin.Android、.net 4.5、windows store、windows phone 8
-
你得到什么编译器错误? (图片未显示编译器错误)。
-
@elgonzo “无法解析符号”为每个红色项目
标签: c# reflection portable-class-library