Share via


IExpressionEval::CreateEvalContext Method [C++]

Use this method to create a new ExprEvalContext object and place it into the context cache. This allows evaluation of multiple expressions against the same set of profile objects in the most efficient manner possible.

Definition

[C++]

HRESULT IExpressionEval::CreateEvalContext(IDictionary*pDictObjs,
 IExprEvalContext**ppContext);

[Visual Basic]

Function CreateEvalContext(pDictObjs As Object) As Object

Parameters

  • pDictObjs[C++]
    [in] A pointer to the IDictionary interface of a Dictionary object that contains the set of profiles to be cached.
  • pDictObjs[Visual Basic]
    [in] A Dictionary object that contains the set of profiles to be cached.
  • ppContext[C++]
    [out, retval] The address of the pointer to the IExprEvalContext interface of the newly created ExprEvalContext object.

Return Values

[C++]

This method returns an HRESULT indicating whether it completed successfully. See the Error Values section for more details.

[Visual Basic]

If this method completes successfully, it returns the newly created ExprEvalContext object.

Error Values

[C++] This method returns S_OK (0x00000000) to indicate success and standard COM HRESULT error values to indicate failure. For more information about standard COM errors, see Standard COM Errors. 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.

[Visual Basic] This method sets the Number property of the global Err object to S_OK (&H00000000) to indicate success and to standard COM error values to indicate failure. For more information about standard COM errors, see Standard COM Errors. Additional information may be available using the global Err object. In particular, the Description property may contain a text description of the error.

Remarks

The CreateEvalContext method creates an ExprEvalContext object that uniquely identifies a new evaluation context and stores the object in the context cache. Use the EvalInContext method to evaluate multiple expressions within the context defined by the ExprEvalContext object. This process is more efficient than using the Eval method which generates and destroys a new context for each expression evaluated.

A context is a set of profiles containing data to evaluate expressions against. Profiles may be ProfileObject objects, Dictionary objects, or other objects that support property access through the IDispatch interface. Initially only references to the profile objects are held in the context cache. During evaluation, when property values are read from the profiles, the property values may themselves be held in the cache for faster access during subsequent evaluations.

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

[C++]

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

Ee809965.caution(en-US,CS.20).gifCaution

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

[Visual Basic]

Example

' dictUser1, dictAddress1, & dictProfiles are Dictionary objects
' create 2 profiles

dictUser1.firstName = "Joe"
dictUser1.lastName = "User"
dictAddress1.city = "Somewhere"
dictAddress1.state = "WA"

' add the profiles to the context Dictionary

dictProfiles.User = dictUser1
dictProfiles.Address = dictAddress1

' create the evaluation context

oExprEvalContext = oExpressionEval.CreateEvalContext(dictProfiles)

See Also

[C++]ExpressionEval Object

[C++]IExpressionEval::EvalInContext

[Visual Basic]ExpressionEval Object

[Visual Basic]ExpressionEval.EvalInContext

Copyright © 2005 Microsoft Corporation.
All rights reserved.