RegisterExtensionForTypeSignature 方法类似于 RegisterModelForTypeSignature 方法,但有一个关键差异。 传递给此方法的数据模型不是任何类型的规范可视化工具,它不会接管该类型的本机/语言视图的显示。 传递给此方法的数据模型将自动作为父级添加到与提供的类型签名匹配的任何具体类型。
与 RegisterModelForTypeSignature 方法不同,对于作为给定类型(或类型集)的扩展注册的相同或不明确类型签名没有限制。 类型签名与给定的具体类型实例匹配的每个扩展都将导致通过此方法注册的数据模型自动附加到新创建的对象作为父模型。 实际上,这允许任意数量的客户端使用新的字段或功能扩展类型(或类型集)。
语法
HRESULT RegisterExtensionForTypeSignature(
IDebugHostTypeSignature *typeSignature,
IModelObject *dataModel
);
参数
typeSignature
提供的数据模型将为其注册为扩展的类型签名。 每个具体类型与此签名匹配的本机/语言对象都会自动将给定的数据模型附加为父模型。
dataModel
数据模型,该模型将自动作为父模型添加到每个本机/语言对象,其具体类型与所提供的类型签名匹配。
返回值
此方法返回指示成功或失败的 HRESULT。
言论
示例代码
ComPtr<IDataModelManager> spManager; /* get the data model manager */
ComPtr<IDebugHost> spHost; /* get the debug host */
ComPtr<IModelObject> spDataModel; /* create a data model (see
CreateDataModelObject) */
ComPtr<IDebugHostSymbols> spSym;
if (SUCCEEDED(spHost.As(&spSym)))
{
// Create a signature to match MyType<*>
ComPtr<IDebugHostTypeSignature> spTypeSignature;
if (SUCCEEDED(spSym->CreateTypeSignature(L"MyType<*>", nullptr, &spTypeSignature)))
{
// Register the model for std::vector<*>
if (SUCCEEDED(spManager->RegisterExtensionForTypeSignature(
spTypeSignature.Get(),
spDataModel.Get())
)
{
// Every instance matching MyType<*> will now have spDataModel
// attached as the parent. This data model is considered an "extension"
// (adding properties). It will not be counted as a visualizer and
// will not "take over" the display of the type
}
}
}
要求
| 要求 | 价值 |
|---|---|
| 标头 | dbgmodel.h |