ExpressionEditor::EvaluateExpression Method
Evaluates an expression string and provides the design-time value for a control property.
Assembly: System.Design (in System.Design.dll)
public: virtual Object^ EvaluateExpression( String^ expression, Object^ parseTimeData, Type^ propertyType, IServiceProvider^ serviceProvider ) abstract
Parameters
- expression
- Type: System::String
An expression string to evaluate. The expression does not include the expression prefix.
- parseTimeData
- Type: System::Object
An object containing additional parsing information for evaluating expression. This typically is provided by the expression builder.
- propertyType
- Type: System::Type
The type of the control property to which expression is bound.
- serviceProvider
- Type: System::IServiceProvider
A service provider implementation supplied by the designer host, used to obtain additional design-time services.
Return Value
Type: System::ObjectThe object referenced by the evaluated expression string, if the expression evaluation succeeded; otherwise, nullptr.
The visual designer host uses the EvaluateExpression method to evaluate an expression and provide the design-time value for an associated control property.
The visual designer uses the ExpressionBuilder::ParseExpression method to parse the expression string at design time, and then calls the EvaluateExpression method with the parsed expression data. The visual designer uses the evaluated expression result to assign control property values that are rendered on the design surface.
Notes to Inheritors:Classes deriving from the ExpressionEditor class must override the EvaluateExpression method to evaluate the custom expression type at design time.
At a minimum, an EvaluateExpression implementation must use the following steps:
Evaluate the expression string and determine the object that is referenced by the expression.
Return nullptr, if the expression string cannot be evaluated.
Use the IsAssignableFrom method on propertyType to determine whether the referenced object can be assigned directly to the control property type, and then, depending on the result, complete one of the following actions:
If the referenced object can be assigned directly to the control property, return the referenced object for the expression.
If the referenced object is a simple type, such as a string, return the referenced object.
Otherwise, determine whether the referenced object can be assigned to or converted to the property type.
Use the CanConvertFrom method on the TypeConverter object for propertyType to determine whether the referenced object can be converted to the control property type, and then, depending on the result, complete one of the following actions:
If the object can be converted to the control property type, return the converted object using the ConvertFrom method.
If the referenced object cannot be assigned or converted to propertyType, return the referenced object.
Optionally, the EvaluateExpression implementation can use the parseTimeData object that is supplied by the ExpressionBuilder::ParseExpression implementation to optimize or help in the evaluation of the input expression string.
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.