What is the ComposableAttribute in WinRT?

谁说我不能喝 提交于 2019-12-11 03:14:12

问题


I'm trying to understand how some of the more lower-level portions of WinRT work. I came across the ComposableAttribute which may be the key to what I need. However, the documentation on it is very thin.

Indicates how a programming element is composed.

As you can tell, that doesn't actually tell me anything. Does anyone know what this attribute is used for and what it is suppose to do?


回答1:


The ComposableAttribute marks a type as being instantiable for use as a base class across the Windows Runtime ABI boundary. It is similar to the ActivatableAttribute, which marks a type as being instantiable for "activation" (i.e. for direct use, not for use not as a base class) across the ABI boundary. The Windows Runtime is based on COM and does not really support real inheritance. Instead, inheritance is faked through metadata trickery and aggregation.

You can define your own composable types, but if you do, they must derive from a composable type in the platform (this is one of the metadata rules in the Windows 8 app certification requirements). For Windows 8, this means that your composable types must "derive" directly or indirectly from Windows.UI.Xaml.DependencyObject. Finally, composable types may only be authored using IDL and WRL; neither C++/CX nor .NET can be used to define a composable type.



来源:https://stackoverflow.com/questions/12735517/what-is-the-composableattribute-in-winrt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!