本文介绍了WinRT反射(C ++/CX)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在C ++/CX中内省一个对象?我知道如何获取其类名(使用IInspectable),但是如果我只有方法名(字符串),就无法弄清楚如何获取其属性列表或如何调用方法.我在这里和Google上搜索了答案,但发现与WinRT的.NET层有关(System.Reflection命名空间似乎在C ++/CX中不可用).

how can I introspect an object in C++/CX? I known how to get its class name (using IInspectable) but I wasn't able to figure out how to get a list of its properties or how to invoke methods if I have just a name of the method (string). I searched for an answer here and at Google but what I found is related to the .NET layer of WinRT (the System.Reflection namespace doesn't seem to be available in C++/CX).

推荐答案

C ++不提供任何特定的API来反映WinRT类型,这些类型在符合CX的元数据文件中完全定义,您可以使用CLR本机元数据API阅读它们的定义.在

C++ doesn't provide any specific APIs to reflect on WinRT types, these types are fully defined in CX compliant metadata files and you can use the CLR native metadata APIs to read their definition. There is a snippet at

http: //social.msdn.microsoft.com/Forums/windowsapps/zh-CN/211ef583-db11-4e55-926b-6d9ab53dbdb4/ccx-reflection

James McNellis去年为CX反射发布了完整的C ++库

James McNellis released a full C++ library for CX reflection last year

http://seaplusplus.com /2012/04/26/cxxreflect-native-reflection-for-the-windows-runtime/

这篇关于WinRT反射(C ++/CX)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-21 12:54