Metodo IModelObject::EnumerateKeyValues (dbgmodel.h)

Il metodo EnumerateKeyValues è il primo metodo a cui un client si rivolge per enumerare tutte le chiavi in un oggetto (incluse tutte le chiavi implementate in qualsiasi punto dell'albero dei modelli padre). È importante notare che EnumerateKeyValues enumera tutte le chiavi definite dai nomi duplicati nell'albero degli oggetti; tuttavia, i metodi come GetKeyValue e SetKeyValue modificano solo la prima istanza di una chiave con il nome specificato come individuato dall'attraversamento depth-first-traversal.

Sintassi

HRESULT EnumerateKeyValues(
  IKeyEnumerator **enumerator
);

Parametri

enumerator

In questo argomento viene restituito un enumeratore per tutte le chiavi nell'oggetto (e tutti i relativi modelli padre) e i relativi valori e metadati come IKeyEnumerator.

Valore restituito

Questo metodo restituisce HRESULT che indica l'esito positivo o negativo.

Commenti

Codice di esempio

ComPtr<IModelObject> spObject; /* get the object you want to enumerate */

ComPtr<IKeyEnumerator> spEnum;
if (SUCCEEDED(spObject->EnumerateKeyValues(&spEnum)))
{
    HRESULT hr = S_OK;
    while (SUCCEEDED(hr))
    {
        BSTR keyName;
        ComPtr<IModelObject> spKeyValue;
        hr = spEnum->GetNext(&keyName, &spKeyValue, nullptr);
        if (SUCCEEDED(hr))
        {
            // keyName contains the name of the key
            // spKeyValue contains the value of the key

            SysFreeString(keyName);
        }
    }

    // hr == E_BOUNDS  : We hit the end of the enumerator
    // hr == E_ABORT   : User is requesting interruption of the 
    // operation / stop immediately and flow the error
}

Requisiti

Requisito Valore
Intestazione dbgmodel.h

Vedi anche

Interfaccia IModelObject