TPropertyBag.GetPropertyByName(const ce::wstring&) (Compact 2013)

3/28/2014

This method returns an iXRPropertyBinding-derived object that is associated with the specified property name.

Syntax

iXRPropertyBinding* GetPropertyByName(
const ce::wstring& PropertyName)

Parameters

  • PropertyName
    [in] Name of the property.

Return Value

Returns an iXRPropertyBinding-derived object if the method succeeds.

Returns NULL if the method is unable to find an iXRPropertyBinding-derived object in m_PropertiesMap by using the name in the PropertyName parameter.

Remarks

The property in the PropertyName parameter must be registered. For more information, see TPropertyBag.RegisterBoundProperty(const ce.wstring&,iXRPropertyBinding &).

Example

The following example code uses the GetPropertyByName method to obtain a TBoundProperty<PropertyType> object by providing a property name. The code works only if you already defined a custom class named IntegerPropertyBag that inherits from TPropertyBag<Derived>, and if you initialized an instance of the class in the variable m_DataSourceObject.

Important

For readability, the following code example does not contain security checking or error handling. Do not use the following code in a production environment.

#include "stdafx.h"
#include "XRPropertyBag.h"

XRPtr<IntegerPropertyBag>  m_DataSourceObject;
void GetProperty()
{
   // Define object variables for the property.
   TBoundProperty<int>* IntProp;
   iXRPropertyBinding* pProperty = NULL; 

   // Call GetPropertyByName to obtain a pointer to an iXRPropertyBinding object.
   pProperty = m_DataSourceObject->GetPropertyByName(L"IntegerData1");  

   // Convert the iXRPropertyBinding pointer to a TBoundProperty<int> type.
   IntProp = (TBoundProperty<int>*)pProperty;
}

Requirements

Header

XRPropertyBag.h

See Also

Reference

TPropertyBag<Derived>
TPropertyBag.GetPropertyName(iXRPropertyBinding *)
TPropertyBag.GetValue(const WCHAR *,XRValue *)