IExpressionEval::EvalInContext

Ee799159.c++_off(en-US,CS.10).gifEe799159.vb_on(en-US,CS.10).gif

Use this method to evaluate an expression against a pre-established context stored in the context cache.

Definition

HRESULT IExpressionEval::EvalInContext(longnExprID,IExprEvalContext*pContext,VARIANT* pvResult);

Parameters

nExprID

[in] A long that contains the unique identification of the expression in the expression store.

pContext

[in] A pointer to an IExprEvalContext interface of an ExprEvalContext object that identifies the specific context for this evaluation.

pvResult

[out, retval] A pointer to a VARIANT indicating the result of the expression evaluated in the specified context.

Return Values

This method returns an HRESULT indicating whether it completed successfully. See the Error Values section for more details. The result of evaluating the expression is contained in the pvResult parameter. This result may be TRUE, FALSE, or NULL. NULL indicates the expression could not be evaluated.

Error Values

This method returns S_OK (0x00000000) to indicate success and either standard or custom COM HRESULT error values to indicate failure. For more information about standard COM errors, see Standard COM Errors.

The following table shows the custom COM errors, and the standard COM errors with special meanings, that this method can return.

Constant Value Description
E_EXPR_BADCONNECTION 0x8110001F Invalid connection
E_EXPR_BADEXPRID 0x8110000A Invalid expression ID specified
E_EXPR_NOCONNECTIONSTRING 0x8110000D No connection string specified
E_EXPR_MISSINGPROP 0x8110001D Invalid ExprEvalContext object
E_EXPR_NOTFOUND 0x81100012 Could not find the specified expression ID, nExprID, in the expression store

Additional information may be available using the global Err object, which can be accessed using the API function GetErrorInfo. In particular, the GetDescription method of the IErrorInfo interface may return a text description of the error.

Remarks

The Eval method creates and discards an evaluation context for every evaluation. Evaluating against a stored context optimizes performance when multiple expressions need to be evaluated in the same context. Create the context for evaluation using the CreateEvalContext method.

Expression results are also stored in the context cache. If the result of a particular expression is requested multiple times from the same ExprEvalContext object using the EvalInContext method, the result is retrieved from the cache rather than by re-evaluating the expression, further increasing efficiency.

Ee799159.caution(en-US,CS.10).gifCaution

  • The state of the profile objects that comprise the context should not be externally changed during the lifetime of the ExprEvalContext object; doing so leads to non-deterministic evaluation results.

The Connect method must be called before using the EvalInContext method.

For more information about memory ownership issues related to COM property and method parameters, see Managing COM Parameter Memory.

The pvResult parameter contains valid data only if the method completes successfully.

See Also

ExpressionEval Object

IExpressionEval::Connect

IExpressionEval::CreateEvalContext

IExpressionEval::Eval

IExpressionEval::LoadExpr


All rights reserved.