Condividi tramite


Metodo IDebugHostEvaluator2::AssignTo (dbgmodel.h)

Il metodo AssignTo esegue l'assegnazione in base alla semantica del linguaggio sottoposto a debug.

Sintassi

HRESULT AssignTo(
  IModelObject                *assignmentReference,
  IModelObject                *assignmentValue,
  _COM_Errorptr_ IModelObject **assignmentResult,
  IKeyStore                   **assignmentMetadata
);

Parametri

assignmentReference

Riferimento all'oggetto assegnato. Anche se può trattarsi di un riferimento basato su modello (ad esempio, ObjectTargetObjectReference) o di un riferimento al linguaggio (ad esempio, un &C++), deve essere un tipo di riferimento (un LVALUE).

assignmentValue

Valore assegnato a ciò a cui viene fatto riferimento tramite l'argomento assignmentReference. Si noti che questo valore può essere coercito o convertito in base alle regole della lingua prima di essere assegnato.

assignmentResult

Risultato dell'assegnazione, se riuscito. In caso contrario, facoltativamente, un oggetto errore esteso che indica il motivo per cui l'assegnazione non è riuscita. Si noti che il risultato dell'assegnazione in questo caso è ciò che la lingua definisce come risultato di un'operazione di assegnazione. Per C++, si tratta di un riferimento al linguaggio assegnato.

assignmentMetadata

Tutti i metadati facoltativi associati al risultato dell'assegnazione vengono restituiti qui.

Valore restituito

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

Osservazioni

esempio di codice

ComPtr<IDebugHost> spHost;           /* get the host */
ComPtr<IDataModelManager> spManager; /* get the data model manager */
ComPtr<IModelObject> spObject;       /* get an object; for an example - consider a
                                        'class MyClass' with an integer value 
                                        m_intVal */

ComPtr<IDebugHostEvaluator2> spEval2;
if (SUCCEEDED(spHost.As(&spEval2)))
{
    // Get a reference to the m_intVal field
    ComPtr<IModelObject> spIntValRef;
    if (SUCCEEDED(spObject->GetRawReference(SymbolField, 
                                            L"m_intVal", 
                                            RawSearchNone, 
                                            &spIntValRef)))
    {
        // Box some value we want to assign.
        VARIANT vtVal;
        vtVal.vt = VT_UI8;
        vtVal.ullVal = 123456;

        ComPtr<IModelObject> spAssignmentValue;
        if (SUCCEEDED(spManager->CreateIntrinsicObject(ObjectIntrinsic, 
                                                       &vtVal, 
                                                       &spAssignmentValue)))
        {
            ComPtr<IModelObject> spAssignmentResult;
            if (SUCCEEDED(spEval2->AssignTo(spIntValRef.Get(), 
                                            spAssignmentValue.Get(),
                                            &spAssignmentResult, 
                                            nullptr)))
            {
                // The (unsigned __int64)123456 was assigned to m_intVal with
                // the set of coercions defined by the language (C++)
                // spAssignmentResult has the language meaning of operator=() 
                // in this case.  This would be a MyClass&.
            }
        }
    }
}

Fabbisogno

Requisito Valore
intestazione dbgmodel.h

Vedere anche

interfaccia IDebugHostEvaluator2