ExpressionEval.CreateEvalContext

Ee825871.c++_on(en-US,CS.10).gifEe825871.vb_off(en-US,CS.10).gif

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

Function CreateEvalContext(pDictObjs As Object) As Object

Parameters

pDictObjs

[in] A Dictionary object that contains the set of profiles to be cached.

Return Values

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

Error Values

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.

Ee825871.caution(en-US,CS.10).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.

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

ExpressionEval Object

ExpressionEval.EvalInContext


All rights reserved.