BindProperty 函数 (get_lambda,set_lambda) (dbgmodel.h)

将两个 lambda 转换为读/写属性访问器的绑定器。 lambda 必须保留通过值捕获引用的外部对象的引用。

用法:BindProperty (get_lambda,set_lambda)

语法

Microsoft::WRL::ComPtr<IModelPropertyAccessor> BindProperty(
  const TGet & getFunctor,
  const TSet & setFunctor
);

参数

getFunctor

签名 (PCWSTR、 IModelObject *、 IModelObject **) ,它将充当新创建的属性访问器的 getter。

setFunctor

签名的函子 (PCWSTR、 IModelObject *、 IModelObject *) ,它将充当新创建的属性访问器的 setter。

返回值

此函数返回 Microsoft::WRL::ComPtr<IModelPropertyAccessor>。

注解

此示例代码显示使用情况。

// Define a native type that we wish to project into the data model
struct MyNativeType
{
    std::wstring Name;
    int Id;
    int WriteableValue;
};

// Declare a type factory for the type
class MyNativeTypeFactory : public TypedInstanceModel<MyNativeType>
{
public:
    MyNativeTypeFactory()
    {
        BindReadOnlyProperty(L"Name", &MyNativeType::Name);
        BindReadOnlyProperty(L"Id", &MyNativeType::Id);
        BindProperty(L"WriteableValue", &MyNativeType::WriteableValue);
    }
};

// Create the type factory and make an instance
MyNativeTypeFactory factory;
Object instance = factory.CreateInstance(MyNativeType { L"Foo", 42, 37 });

// There are "Name/Id" read-only properties on instance and a "WriteableValue" property.

要求

要求
Header dbgmodel.h

另请参阅

调试器数据模型 C++ 概述