Share via


ExpressionEvaluator.CreateEvalContext Method (PIA)

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

[Visual Basic .NET]

Imports Microsoft.CommerceServer.Interop.Targeting
…
Public Function CreateEvalContext(pDictObjs As Object) As Object

[C#]

using Microsoft.CommerceServer.Interop.Targeting;
using Microsoft.CommerceServer.Interop;      //For IDictionary
…
public IExprEvalContext CreateEvalContext(IDictionarypDictObjs);

Parameters

[Visual Basic .NET]

  • pDictObjs
    A Dictionary object that contains the set of profiles to be cached.

[C#]

  • pDictObjs
    The IDictionary interface of a Dictionary object that contains the set of profiles to be cached.

Return Values

[Visual Basic .NET] If this method completes successfully, it returns the newly created ExprEvalContext object.

[C#] This method returns the IExprEvalContext interface of the newly created ExprEvalContext object

Exceptions

This method may throw one of many mapped exceptions or an exception of type COMException. See Standard COM Errors for additional details.

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 or Dictionary objects. 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.

Ee810303.caution(en-US,CS.20).gif Caution

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

[Visual Basic .NET]

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)

Requirements

Namespace: Microsoft.CommerceServer.Interop.Targeting

Platforms: Windows 2000, Windows Server 2003

Assembly: exprarchlib (in exprarchlib.dll)

See Also

ExpressionEvaluatorClass

ExpressionEvaluator.EvalInContext

Copyright © 2005 Microsoft Corporation.
All rights reserved.