本文整理汇总了C#中IExpression.GetValue方法的典型用法代码示例。如果您正苦于以下问题:C# IExpression.GetValue方法的具体用法?C# IExpression.GetValue怎么用?C# IExpression.GetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IExpression
的用法示例。
在下文中一共展示了IExpression.GetValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPropertyValue
/// <summary>Gets the value of a property.</summary>
/// <param name="propertyExpression">
/// The property expression that should be used to retrieve the property value.
/// </param>
/// <returns>The value of the property.</returns>
/// <exception cref="Spring.Objects.FatalObjectException">
/// If there is no such property, if the property isn't readable, or
/// if getting the property value throws an exception.
/// </exception>
public virtual object GetPropertyValue(IExpression propertyExpression)
{
return propertyExpression.GetValue(this.wrappedObject);
}
示例2: EvalCondition
/// <summary>
/// Evaluates a SpEL expression as a boolean value.
/// </summary>
/// <param name="condition">
/// The expression string that should be evaluated.
/// </param>
/// <param name="conditionExpression">
/// The SpEL expression instance that should be evaluated.
/// </param>
/// <param name="context">
/// The object to evaluate expression against.
/// </param>
/// <param name="variables">
/// The expression variables dictionary.
/// </param>
/// <returns>
/// The evaluated boolean.
/// </returns>
/// <exception cref="System.InvalidOperationException">
/// If the SpEL expression could not be successfuly resolved to a boolean.
/// </exception>
protected static bool EvalCondition(string condition,
IExpression conditionExpression, object context, IDictionary<string, object> variables)
{
if (conditionExpression == null)
{
return true;
}
else
{
object value = conditionExpression.GetValue(context, variables);
if (value is bool)
{
return (bool)value;
}
else
{
throw new InvalidOperationException(String.Format(
"The SpEL expression '{0}' could not be successfuly resolved to a boolean.",
condition));
}
}
}