diff --git a/src/Spring/Spring.Core/Expressions/ArrayConstructorNode.cs b/src/Spring/Spring.Core/Expressions/ArrayConstructorNode.cs
index 134be6f8..cef3f807 100644
--- a/src/Spring/Spring.Core/Expressions/ArrayConstructorNode.cs
+++ b/src/Spring/Spring.Core/Expressions/ArrayConstructorNode.cs
@@ -54,7 +54,7 @@ namespace Spring.Expressions
///
/// Context to evaluate expressions against.
/// Current expression evaluation context.
- /// Node's value.
+ /// Node's value.
protected override object Get(object context, EvaluationContext evalContext)
{
if (arrayType == null)
@@ -77,7 +77,7 @@ namespace Spring.Expressions
AST rankNode = rankRoot.getFirstChild();
while (rankNode != null)
{
- ranks[i++] = (int)((BaseNode)rankNode).GetValueInternal(context, evalContext);
+ ranks[i++] = (int)GetValue((BaseNode)rankNode, context, evalContext);
rankNode = rankNode.getNextSibling();
}
return Array.CreateInstance(arrayType, ranks);
@@ -87,7 +87,7 @@ namespace Spring.Expressions
AST valuesRoot = getFirstChild().getNextSibling();
if (valuesRoot != null)
{
- ArrayList values = (ArrayList)((BaseNode)valuesRoot).GetValueInternal(context, evalContext);
+ ArrayList values = (ArrayList)GetValue(((BaseNode)valuesRoot), context, evalContext);
return values.ToArray(arrayType);
}
}
diff --git a/src/Spring/Spring.Core/Expressions/AssignNode.cs b/src/Spring/Spring.Core/Expressions/AssignNode.cs
index fb451b2c..45c80752 100644
--- a/src/Spring/Spring.Core/Expressions/AssignNode.cs
+++ b/src/Spring/Spring.Core/Expressions/AssignNode.cs
@@ -51,7 +51,7 @@ namespace Spring.Expressions
///
/// Context to evaluate expressions against.
/// Current expression evaluation context.
- /// Node's value.
+ /// Node's value.
protected override object Get(object context, EvaluationContext evalContext)
{
AST left = getFirstChild();
@@ -69,10 +69,10 @@ namespace Spring.Expressions
}
else
{
- result = ((BaseNode)right).GetValueInternal(context, evalContext);
+ result = GetValue(((BaseNode)right), context, evalContext);
}
- ((BaseNode)left).SetValueInternal( context, evalContext, result );
+ SetValue(((BaseNode)left), context, evalContext, result );
return result;
}
diff --git a/src/Spring/Spring.Core/Expressions/BaseNode.cs b/src/Spring/Spring.Core/Expressions/BaseNode.cs
index 5bec0647..9fbb18b8 100644
--- a/src/Spring/Spring.Core/Expressions/BaseNode.cs
+++ b/src/Spring/Spring.Core/Expressions/BaseNode.cs
@@ -31,12 +31,19 @@ namespace Spring.Expressions
//[Serializable]
public abstract class BaseNode : SpringAST, IExpression
{
+ protected class ArgumentMismatchException : Exception
+ {
+ public ArgumentMismatchException(string message)
+ : base(message)
+ { }
+ }
+
#region EvaluationContext class
///
/// Holds the state during evaluating an expression.
///
- public class EvaluationContext
+ protected class EvaluationContext
{
#region Holder classes
@@ -147,7 +154,7 @@ namespace Spring.Expressions
/// Returns node's value.
///
/// Node's value.
- object IExpression.GetValue()
+ public object GetValue()
{
return GetValue(null, null);
}
@@ -157,7 +164,7 @@ namespace Spring.Expressions
///
/// Object to evaluate node against.
/// Node's value.
- object IExpression.GetValue(object context)
+ public object GetValue(object context)
{
return GetValue(context, null);
}
@@ -168,43 +175,32 @@ namespace Spring.Expressions
/// Object to evaluate node against.
/// Expression variables map.
/// Node's value.
- object IExpression.GetValue(object context, IDictionary variables)
- {
- return GetValue(context, variables);
- }
-
- ///
- /// This is the entrypoint into evaluating this expression.
- ///
public object GetValue(object context, IDictionary variables)
{
EvaluationContext evalContext = new EvaluationContext(context, variables);
return Get(context, evalContext);
}
- ///
- /// Called internally during expression evaluation
- ///
- /// Object to evaluate node against.
- /// Current expression evaluation context.
- ///
- protected internal object GetValueInternal(object context, EvaluationContext evalContext)
- {
- return Get(context, evalContext);
- }
-
///
/// Returns node's value for the given context.
///
/// Node's value.
protected abstract object Get(object context, EvaluationContext evalContext);
+ ///
+ /// Evaluates this node for the given context, switching local variables map to the ones specified in .
+ ///
+ protected virtual object Get(object context, EvaluationContext evalContext, object[] arguments)
+ {
+ throw new NotSupportedException("Node " + this.GetType() + " does not support evaluation with arguments");
+ }
+
///
/// Sets node's value for the given context.
///
/// Object to evaluate node against.
/// New value for this node.
- void IExpression.SetValue(object context, object newValue)
+ public void SetValue(object context, object newValue)
{
SetValue(context, null, newValue);
}
@@ -215,28 +211,12 @@ namespace Spring.Expressions
/// Object to evaluate node against.
/// Expression variables map.
/// New value for this node.
- void IExpression.SetValue(object context, IDictionary variables, object newValue)
- {
- SetValue( context,variables,newValue );
- }
-
- ///
- /// This is the entrypoint into evaluating this expression.
- ///
public void SetValue(object context, IDictionary variables, object newValue)
{
EvaluationContext evalContext = new EvaluationContext(context, variables);
Set(context, evalContext, newValue);
}
- ///
- /// Called internally during expression evaluation.
- ///
- protected internal void SetValueInternal(object context, EvaluationContext evalContext, object newValue)
- {
- Set(context, evalContext, newValue);
- }
-
///
/// Sets node's value for the given context.
///
@@ -263,14 +243,22 @@ namespace Spring.Expressions
return string.Format("{0}[{1}]", this.GetType().Name, base.GetHashCode());
}
- protected static object GetValueInternal(BaseNode node, object context, EvaluationContext evalContext)
+ ///
+ /// Evaluates this node, switching local variables map to the ones specified in .
+ ///
+ protected object GetValueWithArguments(BaseNode node, object context, EvaluationContext evalContext, object[] arguments)
{
- return node.GetValueInternal(context, evalContext);
+ return node.Get(context, evalContext, arguments);
}
- protected static void SetValueInternal(BaseNode node, object context, EvaluationContext evalContext, object newValue)
+ protected object GetValue(BaseNode node, object context, EvaluationContext evalContext)
{
- node.SetValueInternal(context, evalContext, newValue);
+ return node.Get(context, evalContext);
+ }
+
+ protected void SetValue(BaseNode node, object context, EvaluationContext evalContext, object newValue)
+ {
+ node.Set(context, evalContext, newValue);
}
}
}
\ No newline at end of file
diff --git a/src/Spring/Spring.Core/Expressions/BinaryOperator.cs b/src/Spring/Spring.Core/Expressions/BinaryOperator.cs
index fc2068bb..cd89b46f 100644
--- a/src/Spring/Spring.Core/Expressions/BinaryOperator.cs
+++ b/src/Spring/Spring.Core/Expressions/BinaryOperator.cs
@@ -63,6 +63,13 @@ namespace Spring.Expressions
get { return (BaseNode) this.getFirstChild(); }
}
+ ///
+ /// Evaluate the left operand
+ ///
+ protected object GetLeftValue(object context, EvaluationContext evalContext)
+ {
+ return GetValue(Left, context, evalContext);
+ }
///
/// Gets the right operand.
///
@@ -70,6 +77,14 @@ namespace Spring.Expressions
public BaseNode Right
{
get { return (BaseNode) this.getFirstChild().getNextSibling(); }
+ }
+
+ ///
+ /// Evaluate the left operand
+ ///
+ protected object GetRightValue(object context, EvaluationContext evalContext)
+ {
+ return GetValue(Right, context, evalContext);
}
}
}
\ No newline at end of file
diff --git a/src/Spring/Spring.Core/Expressions/BooleanLiteralNode.cs b/src/Spring/Spring.Core/Expressions/BooleanLiteralNode.cs
index 47f4cbaa..f55c5428 100644
--- a/src/Spring/Spring.Core/Expressions/BooleanLiteralNode.cs
+++ b/src/Spring/Spring.Core/Expressions/BooleanLiteralNode.cs
@@ -61,7 +61,7 @@ namespace Spring.Expressions
///
/// This is the entrypoint into evaluating this expression.
///
- /// Node's value.
+ /// Node's value.
protected override object Get(object context, EvaluationContext evalContext)
{
if (nodeValue == null)
diff --git a/src/Spring/Spring.Core/Expressions/ConstructorNode.cs b/src/Spring/Spring.Core/Expressions/ConstructorNode.cs
index 43170f59..ea7d4a5e 100644
--- a/src/Spring/Spring.Core/Expressions/ConstructorNode.cs
+++ b/src/Spring/Spring.Core/Expressions/ConstructorNode.cs
@@ -70,7 +70,7 @@ namespace Spring.Expressions
///
/// Context to evaluate expressions against.
/// Current expression evaluation context.
- /// Node's value.
+ /// Node's value.
protected override object Get(object context, EvaluationContext evalContext)
{
object[] argValues = ResolveArguments(evalContext);
diff --git a/src/Spring/Spring.Core/Expressions/DefaultNode.cs b/src/Spring/Spring.Core/Expressions/DefaultNode.cs
index 38b81233..62f5ba7f 100644
--- a/src/Spring/Spring.Core/Expressions/DefaultNode.cs
+++ b/src/Spring/Spring.Core/Expressions/DefaultNode.cs
@@ -50,13 +50,13 @@ namespace Spring.Expressions
///
/// Context to evaluate expressions against.
/// Current expression evaluation context.
- /// Node's value.
+ /// Node's value.
protected override object Get(object context, EvaluationContext evalContext)
- {
- object left = Left.GetValueInternal(context, evalContext);
- object right = Right.GetValueInternal(context, evalContext);
+ {
+ object leftVal = GetValue(Left, context, evalContext);
+ object rightVal = GetValue(Right, context, evalContext);
- return (left != null ? left : right);
+ return (leftVal != null ? leftVal : rightVal);
}
}
}
\ No newline at end of file
diff --git a/src/Spring/Spring.Core/Expressions/Expression.cs b/src/Spring/Spring.Core/Expressions/Expression.cs
index 286e56c8..72d772f7 100644
--- a/src/Spring/Spring.Core/Expressions/Expression.cs
+++ b/src/Spring/Spring.Core/Expressions/Expression.cs
@@ -263,7 +263,7 @@ namespace Spring.Expressions
/// Context to evaluate expressions against.
/// Current expression evaluation context.
/// Value of the last node.
- protected override object Get( object context, EvaluationContext evalContext )
+ protected override object Get(object context, EvaluationContext evalContext)
{
object result = context;
@@ -272,7 +272,7 @@ namespace Spring.Expressions
AST node = this.getFirstChild();
while (node != null)
{
- result = ((BaseNode)node).GetValueInternal( result, evalContext );
+ result = GetValue(((BaseNode)node), result, evalContext );
node = node.getNextSibling();
}
@@ -301,7 +301,7 @@ namespace Spring.Expressions
{
try
{
- target = ((BaseNode)node).GetValueInternal( target, evalContext );
+ target = GetValue(((BaseNode)node), target, evalContext);
node = node.getNextSibling();
}
catch (NotReadablePropertyException e)
@@ -309,7 +309,7 @@ namespace Spring.Expressions
throw new NotWritablePropertyException( "Cannot read the value of '" + node.getText() + "' property in the expression.", e );
}
}
- ((BaseNode)node).SetValueInternal( target, evalContext, newValue );
+ SetValue(((BaseNode)node), target, evalContext, newValue);
}
else
{
diff --git a/src/Spring/Spring.Core/Expressions/ExpressionListNode.cs b/src/Spring/Spring.Core/Expressions/ExpressionListNode.cs
index b11c2fc1..fc8a26ee 100644
--- a/src/Spring/Spring.Core/Expressions/ExpressionListNode.cs
+++ b/src/Spring/Spring.Core/Expressions/ExpressionListNode.cs
@@ -51,7 +51,7 @@ namespace Spring.Expressions
///
/// Context to evaluate expressions against.
/// Current expression evaluation context.
- /// Result of the last expression in a list
+ /// Result of the last expression in a list
protected override object Get(object context, EvaluationContext evalContext)
{
object result = context;
@@ -59,7 +59,7 @@ namespace Spring.Expressions
AST node = this.getFirstChild();
while (node != null)
{
- result = ((BaseNode) node).GetValueInternal(context, evalContext);
+ result = GetValue(((BaseNode) node), context, evalContext);
node = node.getNextSibling();
}
return result;
diff --git a/src/Spring/Spring.Core/Expressions/FunctionNode.cs b/src/Spring/Spring.Core/Expressions/FunctionNode.cs
index db2983f3..6aa89751 100644
--- a/src/Spring/Spring.Core/Expressions/FunctionNode.cs
+++ b/src/Spring/Spring.Core/Expressions/FunctionNode.cs
@@ -56,36 +56,30 @@ namespace Spring.Expressions
protected override object Get(object context, EvaluationContext evalContext)
{
string name = this.getText();
- object function = evalContext.Variables[name];
object[] argValues = ResolveArguments(evalContext);
+ object function = evalContext.Variables[name];
+
// delegate?
Delegate callback = function as Delegate;
if (callback != null)
{
- return new SafeMethod(callback.Method).Invoke(callback.Target, argValues);
+ return InvokeDelegate(callback, argValues);
}
// lambda?
LambdaExpressionNode lambda = function as LambdaExpressionNode;
if (lambda != null)
{
- string[] argNames = lambda.ArgumentNames;
-
- if (argValues.Length != argNames.Length)
+ try
{
- throw new InvalidOperationException(
- "Function '" + name + "' requires " + argNames.Length + " arguments.");
+ return GetValueWithArguments(lambda, context, evalContext, argValues);
}
-
- IDictionary arguments = new Hashtable();
- for (int i = 0; i < argValues.Length; i++)
+ catch (ArgumentMismatchException ame)
{
- arguments[argNames[i]] = argValues[i];
+ throw new InvalidOperationException( "Failed executing function " + name + ": " + ame.Message );
}
-
- return lambda.GetValueInternal(context, evalContext, arguments);
}
if (function == null)
@@ -94,5 +88,10 @@ namespace Spring.Expressions
}
throw new InvalidOperationException("Function '" + name + "' is defined but of unknown type.");
}
+
+ private object InvokeDelegate(Delegate callback, object[] arguments)
+ {
+ return new SafeMethod(callback.Method).Invoke(callback.Target, arguments);
+ }
}
}
\ No newline at end of file
diff --git a/src/Spring/Spring.Core/Expressions/HexLiteralNode.cs b/src/Spring/Spring.Core/Expressions/HexLiteralNode.cs
index f9de2fc7..626dff02 100644
--- a/src/Spring/Spring.Core/Expressions/HexLiteralNode.cs
+++ b/src/Spring/Spring.Core/Expressions/HexLiteralNode.cs
@@ -53,7 +53,7 @@ namespace Spring.Expressions
///
/// Context to evaluate expressions against.
/// Current expression evaluation context.
- /// Node's value.
+ /// Node's value.
protected override object Get(object context, EvaluationContext evalContext)
{
if (nodeValue == null)
diff --git a/src/Spring/Spring.Core/Expressions/IndexerNode.cs b/src/Spring/Spring.Core/Expressions/IndexerNode.cs
index 7bf94bec..6801bb27 100644
--- a/src/Spring/Spring.Core/Expressions/IndexerNode.cs
+++ b/src/Spring/Spring.Core/Expressions/IndexerNode.cs
@@ -62,7 +62,7 @@ namespace Spring.Expressions
///
/// Context to evaluate expressions against.
/// Current expression evaluation context.
- /// Node's value.
+ /// Node's value.
protected override object Get(object context, EvaluationContext evalContext)
{
if (context == null)
diff --git a/src/Spring/Spring.Core/Expressions/IntLiteralNode.cs b/src/Spring/Spring.Core/Expressions/IntLiteralNode.cs
index 505ab31a..0e300397 100644
--- a/src/Spring/Spring.Core/Expressions/IntLiteralNode.cs
+++ b/src/Spring/Spring.Core/Expressions/IntLiteralNode.cs
@@ -60,7 +60,7 @@ namespace Spring.Expressions
///
/// Context to evaluate expressions against.
/// Current expression evaluation context.
- /// Node's value.
+ /// Node's value.
protected override object Get(object context, EvaluationContext evalContext)
{
if (nodeValue == null)
diff --git a/src/Spring/Spring.Core/Expressions/LambdaExpressionNode.cs b/src/Spring/Spring.Core/Expressions/LambdaExpressionNode.cs
index 9142f9c1..e2355003 100644
--- a/src/Spring/Spring.Core/Expressions/LambdaExpressionNode.cs
+++ b/src/Spring/Spring.Core/Expressions/LambdaExpressionNode.cs
@@ -29,7 +29,7 @@ namespace Spring.Expressions
/// Represents lambda expression.
///
/// Aleksandar Seovic
- [Serializable]
+ [Serializable]
public class LambdaExpressionNode : BaseNode
{
///
@@ -77,34 +77,44 @@ namespace Spring.Expressions
///
/// Context to evaluate expressions against.
/// Current expression evaluation context.
- /// Node's value.
+ /// Node's value.
protected override object Get(object context, EvaluationContext evalContext)
{
if(bodyExpression == null)
{
InitializeLambda();
- }
-
- object result = bodyExpression.GetValueInternal(context, evalContext);
+ }
+
+ object result = GetValue(bodyExpression, context, evalContext);
return result;
+ }
+
+ ///
+ /// Evaluates this node, switching local variables map to the ones specified in .
+ ///
+ protected override object Get(object context, EvaluationContext evalContext, object[] argValues)
+ {
+ string[] argNames = this.ArgumentNames;
+
+ if (argValues.Length != argNames.Length)
+ {
+ throw new ArgumentMismatchException(string.Format("Invalid number of arguments - expected {0} arguments, but was called with {1}", argNames.Length, argValues.Length));
+ }
+
+ IDictionary arguments = new Hashtable();
+ for (int i = 0; i < argValues.Length; i++)
+ {
+ arguments[argNames[i]] = argValues[i];
+ }
+
+ EvaluationContext ec = (EvaluationContext)evalContext;
+ using (ec.SwitchLocalVariables(arguments))
+ {
+ object result = Get(context, ec);
+ return result;
+ }
}
- ///
- /// Returns Lambda Expression's value for the given context.
- ///
- /// Context to evaluate expressions against.
- /// Current expression evaluation context.
- /// A dictionary containing argument map for this lambda expression.
- /// Node's value.
- public object GetValueInternal(object context, EvaluationContext evalContext, IDictionary arguments)
- {
- using (evalContext.SwitchLocalVariables(arguments))
- {
- object result = base.GetValueInternal(context, evalContext);
- return result;
- }
- }
-
private void InitializeLambda()
{
lock (this)
diff --git a/src/Spring/Spring.Core/Expressions/ListInitializerNode.cs b/src/Spring/Spring.Core/Expressions/ListInitializerNode.cs
index 7c279d0d..a348205a 100644
--- a/src/Spring/Spring.Core/Expressions/ListInitializerNode.cs
+++ b/src/Spring/Spring.Core/Expressions/ListInitializerNode.cs
@@ -51,7 +51,7 @@ namespace Spring.Expressions
///
/// Context to evaluate expressions against.
/// Current expression evaluation context.
- /// Node's value.
+ /// Node's value.
protected override object Get(object context, EvaluationContext evalContext)
{
object[] values = ResolveArguments(evalContext);
diff --git a/src/Spring/Spring.Core/Expressions/LocalFunctionNode.cs b/src/Spring/Spring.Core/Expressions/LocalFunctionNode.cs
index 9253bf61..937586b1 100644
--- a/src/Spring/Spring.Core/Expressions/LocalFunctionNode.cs
+++ b/src/Spring/Spring.Core/Expressions/LocalFunctionNode.cs
@@ -51,7 +51,7 @@ namespace Spring.Expressions
///
/// Context to evaluate expressions against.
/// Current expression evaluation context.
- /// Result of the function evaluation.
+ /// Result of the function evaluation.
protected override object Get(object context, EvaluationContext evalContext)
{
string name = this.getText();
@@ -64,21 +64,15 @@ namespace Spring.Expressions
}
object[] argValues = ResolveArguments(evalContext);
- string[] argNames = lambda.ArgumentNames;
-
- if (argValues.Length != argNames.Length)
- {
- throw new InvalidOperationException(
- "Function '" + name + "' requires " + argNames.Length + " arguments.");
- }
- IDictionary arguments = new Hashtable();
- for (int i = 0; i < argValues.Length; i++)
- {
- arguments[argNames[i]] = argValues[i];
- }
-
- return lambda.GetValueInternal(context, evalContext, arguments);
+ try
+ {
+ return GetValueWithArguments(lambda, context, evalContext, argValues);
+ }
+ catch (ArgumentMismatchException ame)
+ {
+ throw new InvalidOperationException("Failed executing function '" + name + "': " + ame.Message);
+ }
}
}
}
\ No newline at end of file
diff --git a/src/Spring/Spring.Core/Expressions/LocalVariableNode.cs b/src/Spring/Spring.Core/Expressions/LocalVariableNode.cs
index cef8462d..b54158a7 100644
--- a/src/Spring/Spring.Core/Expressions/LocalVariableNode.cs
+++ b/src/Spring/Spring.Core/Expressions/LocalVariableNode.cs
@@ -53,7 +53,7 @@ namespace Spring.Expressions
///
/// Context to evaluate expressions against.
/// Current expression evaluation context.
- /// Node's value.
+ /// Node's value.
protected override object Get(object context, EvaluationContext evalContext)
{
string varName = this.getText();
diff --git a/src/Spring/Spring.Core/Expressions/MapEntryNode.cs b/src/Spring/Spring.Core/Expressions/MapEntryNode.cs
index e6c8c1ab..0e7005ed 100644
--- a/src/Spring/Spring.Core/Expressions/MapEntryNode.cs
+++ b/src/Spring/Spring.Core/Expressions/MapEntryNode.cs
@@ -50,11 +50,12 @@ namespace Spring.Expressions
///
/// Context to evaluate expressions against.
/// Current expression evaluation context.
- /// Node's value.
+ /// Node's value.
protected override object Get(object context, EvaluationContext evalContext)
- {
- object key = ((BaseNode)this.getFirstChild()).GetValueInternal(context, evalContext);
- object value = ((BaseNode)this.getFirstChild().getNextSibling()).GetValueInternal(context, evalContext);
+ {
+ BaseNode firstChild = (BaseNode)this.getFirstChild();
+ object key = GetValue(firstChild, context, evalContext);
+ object value = GetValue((BaseNode) firstChild.getNextSibling(), context, evalContext);
return new DictionaryEntry(key, value);
}
diff --git a/src/Spring/Spring.Core/Expressions/MapInitializerNode.cs b/src/Spring/Spring.Core/Expressions/MapInitializerNode.cs
index 0a4ab4e7..d65fe6b2 100644
--- a/src/Spring/Spring.Core/Expressions/MapInitializerNode.cs
+++ b/src/Spring/Spring.Core/Expressions/MapInitializerNode.cs
@@ -51,15 +51,14 @@ namespace Spring.Expressions
///
/// Context to evaluate expressions against.
/// Current expression evaluation context.
- /// Node's value.
+ /// Node's value.
protected override object Get(object context, EvaluationContext evalContext)
{
IDictionary entries = new Hashtable();
AST entryNode = this.getFirstChild();
while (entryNode != null)
{
- DictionaryEntry entry = (DictionaryEntry)
- ((MapEntryNode)entryNode).GetValueInternal( evalContext.RootContext, evalContext );
+ DictionaryEntry entry = (DictionaryEntry) GetValue(((MapEntryNode)entryNode), evalContext.RootContext, evalContext );
entries[entry.Key] = entry.Value;
entryNode = entryNode.getNextSibling();
}
diff --git a/src/Spring/Spring.Core/Expressions/NamedArgumentNode.cs b/src/Spring/Spring.Core/Expressions/NamedArgumentNode.cs
index ae1e95f0..866c2768 100644
--- a/src/Spring/Spring.Core/Expressions/NamedArgumentNode.cs
+++ b/src/Spring/Spring.Core/Expressions/NamedArgumentNode.cs
@@ -50,10 +50,10 @@ namespace Spring.Expressions
///
/// Context to evaluate expressions against.
/// Current expression evaluation context.
- /// Node's value.
+ /// Node's value.
protected override object Get(object context, EvaluationContext evalContext)
{
- return ((BaseNode) this.getFirstChild()).GetValueInternal(evalContext.RootContext, evalContext);
+ return GetValue(((BaseNode) this.getFirstChild()), evalContext.RootContext, evalContext);
}
}
}
\ No newline at end of file
diff --git a/src/Spring/Spring.Core/Expressions/NodeWithArguments.cs b/src/Spring/Spring.Core/Expressions/NodeWithArguments.cs
index deb2b12e..5b184070 100644
--- a/src/Spring/Spring.Core/Expressions/NodeWithArguments.cs
+++ b/src/Spring/Spring.Core/Expressions/NodeWithArguments.cs
@@ -72,36 +72,33 @@ namespace Spring.Expressions
///
private void InitializeNode()
{
- if (args == null)
+ lock (this)
{
- lock (this)
+ if (args == null)
{
- if (args == null)
+ ArrayList argList = new ArrayList();
+ namedArgs = new Hashtable();
+
+ AST node = this.getFirstChild();
+
+ while (node != null)
{
- ArrayList argList = new ArrayList();
- namedArgs = new Hashtable();
-
- AST node = this.getFirstChild();
-
- while (node != null)
+ if (node.getFirstChild() is LambdaExpressionNode)
{
- if (node.getFirstChild() is LambdaExpressionNode)
- {
- argList.Add(node.getFirstChild());
- }
- else if (node is NamedArgumentNode)
- {
- namedArgs.Add(node.getText(), node);
- }
- else
- {
- argList.Add(node);
- }
- node = node.getNextSibling();
+ argList.Add(node.getFirstChild());
}
-
- args = (BaseNode[])argList.ToArray(typeof(BaseNode));
+ else if (node is NamedArgumentNode)
+ {
+ namedArgs.Add(node.getText(), node);
+ }
+ else
+ {
+ argList.Add(node);
+ }
+ node = node.getNextSibling();
}
+
+ args = (BaseNode[]) argList.ToArray(typeof (BaseNode));
}
}
}
@@ -127,8 +124,12 @@ namespace Spring.Expressions
/// Current expression evaluation context.
/// An array of argument values
protected object[] ResolveArguments(EvaluationContext evalContext)
- {
- InitializeNode();
+ {
+ if (args == null)
+ {
+ InitializeNode();
+ }
+
int length = args.Length;
object[] values = new object[length];
for (int i = 0; i < length; i++)
@@ -144,8 +145,12 @@ namespace Spring.Expressions
/// Current expression evaluation context.
/// A dictionary of argument name to value mappings.
protected IDictionary ResolveNamedArguments(EvaluationContext evalContext)
- {
- InitializeNode();
+ {
+ if (args == null)
+ {
+ InitializeNode();
+ }
+
if (namedArgs.Count == 0)
{
return null;
@@ -166,8 +171,11 @@ namespace Spring.Expressions
/// Current expression evaluation context.
/// Resolved argument value.
protected object ResolveArgument(int position, EvaluationContext evalContext)
- {
- InitializeNode();
+ {
+ if (args == null)
+ {
+ InitializeNode();
+ }
return ResolveArgumentInternal(position, evalContext);
}
@@ -184,7 +192,7 @@ namespace Spring.Expressions
{
return arg;
}
- return arg.GetValueInternal(evalContext.ThisContext, evalContext);
+ return GetValue(arg, evalContext.ThisContext, evalContext);
}
///
@@ -195,7 +203,7 @@ namespace Spring.Expressions
/// Resolved named argument value.
private object ResolveNamedArgument(string name, EvaluationContext evalContext)
{
- return ((BaseNode)namedArgs[name]).GetValueInternal(evalContext.ThisContext, evalContext);
+ return GetValue(((BaseNode)namedArgs[name]), evalContext.ThisContext, evalContext);
}
}
diff --git a/src/Spring/Spring.Core/Expressions/OpADD.cs b/src/Spring/Spring.Core/Expressions/OpADD.cs
index 84fe8e56..0e28750e 100644
--- a/src/Spring/Spring.Core/Expressions/OpADD.cs
+++ b/src/Spring/Spring.Core/Expressions/OpADD.cs
@@ -53,11 +53,11 @@ namespace Spring.Expressions
///
/// Context to evaluate expressions against.
/// Current expression evaluation context.
- /// Node's value.
+ /// Node's value.
protected override object Get(object context, EvaluationContext evalContext)
{
- object left = Left.GetValueInternal(context, evalContext);
- object right = Right.GetValueInternal(context, evalContext);
+ object left = GetLeftValue(context, evalContext);
+ object right = GetRightValue(context, evalContext);
if (NumberUtils.IsNumber(left) && NumberUtils.IsNumber(right))
{
diff --git a/src/Spring/Spring.Core/Expressions/OpAND.cs b/src/Spring/Spring.Core/Expressions/OpAND.cs
index e1a13d01..2062a8e5 100644
--- a/src/Spring/Spring.Core/Expressions/OpAND.cs
+++ b/src/Spring/Spring.Core/Expressions/OpAND.cs
@@ -59,11 +59,11 @@ namespace Spring.Expressions
///
/// Context to evaluate expressions against.
/// Current expression evaluation context.
- /// Node's value.
+ /// Node's value.
protected override object Get(object context, EvaluationContext evalContext)
{
- object l = Left.GetValueInternal(context, evalContext);
- object r = Right.GetValueInternal(context, evalContext);
+ object l = GetLeftValue(context, evalContext);
+ object r = GetRightValue(context, evalContext);
if (NumberUtils.IsInteger(l) && NumberUtils.IsInteger(r))
{
diff --git a/src/Spring/Spring.Core/Expressions/OpBetween.cs b/src/Spring/Spring.Core/Expressions/OpBetween.cs
index 897e5559..970619b2 100644
--- a/src/Spring/Spring.Core/Expressions/OpBetween.cs
+++ b/src/Spring/Spring.Core/Expressions/OpBetween.cs
@@ -54,11 +54,11 @@ namespace Spring.Expressions
/// Current expression evaluation context.
///
/// true if the left operand is contained within the right operand, false otherwise.
- ///
+ ///
protected override object Get(object context, EvaluationContext evalContext)
{
- object value = Left.GetValueInternal(context, evalContext);
- IList range = Right.GetValueInternal(context, evalContext) as IList;
+ object value = GetLeftValue(context, evalContext);
+ IList range = GetRightValue(context, evalContext) as IList;
if (range == null || range.Count != 2)
{
diff --git a/src/Spring/Spring.Core/Expressions/OpDIVIDE.cs b/src/Spring/Spring.Core/Expressions/OpDIVIDE.cs
index e10e5a8c..2e93ac11 100644
--- a/src/Spring/Spring.Core/Expressions/OpDIVIDE.cs
+++ b/src/Spring/Spring.Core/Expressions/OpDIVIDE.cs
@@ -52,11 +52,11 @@ namespace Spring.Expressions
///
/// Context to evaluate expressions against.
/// Current expression evaluation context.
- /// Node's value.
+ /// Node's value.
protected override object Get(object context, EvaluationContext evalContext)
{
- object left = Left.GetValueInternal(context, evalContext);
- object right = Right.GetValueInternal(context, evalContext);
+ object left = GetLeftValue(context, evalContext);
+ object right = GetRightValue(context, evalContext);
if (NumberUtils.IsNumber(left) && NumberUtils.IsNumber(right))
{
diff --git a/src/Spring/Spring.Core/Expressions/OpEqual.cs b/src/Spring/Spring.Core/Expressions/OpEqual.cs
index 684c025f..45515f51 100644
--- a/src/Spring/Spring.Core/Expressions/OpEqual.cs
+++ b/src/Spring/Spring.Core/Expressions/OpEqual.cs
@@ -1,5 +1,5 @@
-#region License
-
+#region License
+
/*
* Copyright © 2002-2005 the original author or authors.
*
@@ -14,80 +14,80 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- */
-
-#endregion
-
-using System;
-using System.Runtime.Serialization;
-using Spring.Util;
-
-namespace Spring.Expressions
-{
- ///
- /// Represents logical equality operator.
- ///
- /// Aleksandar Seovic
- [Serializable]
- public class OpEqual : BinaryOperator
- {
- ///
- /// Create a new instance
- ///
- public OpEqual()
- {
- }
-
- ///
- /// Create a new instance from SerializationInfo
- ///
- protected OpEqual(SerializationInfo info, StreamingContext context)
- : base(info, context)
- {
- }
-
- ///
- /// Returns a value for the logical equality operator node.
- ///
- /// Context to evaluate expressions against.
- /// Current expression evaluation context.
- /// Node's value.
- protected override object Get(object context, EvaluationContext evalContext)
- {
- object left = Left.GetValueInternal( context, evalContext );
- object right = Right.GetValueInternal( context, evalContext );
-
- if (left == null)
- {
- return (right == null);
- }
- else if (right == null)
- {
- return false;
- }
- else if (left.GetType() == right.GetType())
- {
- if (left is Array)
- {
- return ArrayUtils.AreEqual(left as Array, right as Array);
- }
- else
- {
- return left.Equals(right);
- }
- }
- else if (left.GetType().IsEnum && right is string)
- {
- return left.Equals(Enum.Parse(left.GetType(), (string) right));
- }
- else if (right.GetType().IsEnum && left is string)
- {
- return right.Equals(Enum.Parse(right.GetType(), (string) left));
- }
- else
- {
- return CompareUtils.Compare(left, right) == 0;
- }
- }
- }
+ */
+
+#endregion
+
+using System;
+using System.Runtime.Serialization;
+using Spring.Util;
+
+namespace Spring.Expressions
+{
+ ///
+ /// Represents logical equality operator.
+ ///
+ /// Aleksandar Seovic
+ [Serializable]
+ public class OpEqual : BinaryOperator
+ {
+ ///
+ /// Create a new instance
+ ///
+ public OpEqual()
+ {
+ }
+
+ ///
+ /// Create a new instance from SerializationInfo
+ ///
+ protected OpEqual(SerializationInfo info, StreamingContext context)
+ : base(info, context)
+ {
+ }
+
+ ///
+ /// Returns a value for the logical equality operator node.
+ ///
+ /// Context to evaluate expressions against.
+ /// Current expression evaluation context.
+ /// Node's value.
+ protected override object Get(object context, EvaluationContext evalContext)
+ {
+ object left = GetLeftValue(context, evalContext);
+ object right = GetRightValue(context, evalContext);
+
+ if (left == null)
+ {
+ return (right == null);
+ }
+ else if (right == null)
+ {
+ return false;
+ }
+ else if (left.GetType() == right.GetType())
+ {
+ if (left is Array)
+ {
+ return ArrayUtils.AreEqual(left as Array, right as Array);
+ }
+ else
+ {
+ return left.Equals(right);
+ }
+ }
+ else if (left.GetType().IsEnum && right is string)
+ {
+ return left.Equals(Enum.Parse(left.GetType(), (string)right));
+ }
+ else if (right.GetType().IsEnum && left is string)
+ {
+ return right.Equals(Enum.Parse(right.GetType(), (string)left));
+ }
+ else
+ {
+ return CompareUtils.Compare(left, right) == 0;
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/src/Spring/Spring.Core/Expressions/OpGreater.cs b/src/Spring/Spring.Core/Expressions/OpGreater.cs
index 2b83b35d..03003596 100644
--- a/src/Spring/Spring.Core/Expressions/OpGreater.cs
+++ b/src/Spring/Spring.Core/Expressions/OpGreater.cs
@@ -51,11 +51,11 @@ namespace Spring.Expressions
///
/// Context to evaluate expressions against.
/// Current expression evaluation context.
- /// Node's value.
+ /// Node's value.
protected override object Get(object context, EvaluationContext evalContext)
{
- object left = Left.GetValueInternal(context, evalContext);
- object right = Right.GetValueInternal(context, evalContext);
+ object left = GetLeftValue(context, evalContext);
+ object right = GetRightValue(context, evalContext);
return CompareUtils.Compare(left, right) > 0;
}
diff --git a/src/Spring/Spring.Core/Expressions/OpGreaterOrEqual.cs b/src/Spring/Spring.Core/Expressions/OpGreaterOrEqual.cs
index fa74264d..3329da82 100644
--- a/src/Spring/Spring.Core/Expressions/OpGreaterOrEqual.cs
+++ b/src/Spring/Spring.Core/Expressions/OpGreaterOrEqual.cs
@@ -51,11 +51,11 @@ namespace Spring.Expressions
///
/// Context to evaluate expressions against.
/// Current expression evaluation context.
- /// Node's value.
+ /// Node's value.
protected override object Get(object context, EvaluationContext evalContext)
{
- object left = Left.GetValueInternal( context, evalContext );
- object right = Right.GetValueInternal( context, evalContext );
+ object left = GetLeftValue( context, evalContext );
+ object right = GetRightValue( context, evalContext );
return CompareUtils.Compare(left, right) >= 0;
}
diff --git a/src/Spring/Spring.Core/Expressions/OpIn.cs b/src/Spring/Spring.Core/Expressions/OpIn.cs
index 856cb157..d2d5d087 100644
--- a/src/Spring/Spring.Core/Expressions/OpIn.cs
+++ b/src/Spring/Spring.Core/Expressions/OpIn.cs
@@ -53,11 +53,11 @@ namespace Spring.Expressions
/// Current expression evaluation context.
///
/// true if the left operand is contained within the right operand, false otherwise.
- ///
+ ///
protected override object Get(object context, EvaluationContext evalContext)
{
- object left = Left.GetValueInternal( context, evalContext );
- object right = Right.GetValueInternal( context, evalContext );
+ object left = GetLeftValue( context, evalContext );
+ object right = GetRightValue( context, evalContext );
if (right == null)
{
diff --git a/src/Spring/Spring.Core/Expressions/OpIs.cs b/src/Spring/Spring.Core/Expressions/OpIs.cs
index dadf8161..2bba5a7b 100644
--- a/src/Spring/Spring.Core/Expressions/OpIs.cs
+++ b/src/Spring/Spring.Core/Expressions/OpIs.cs
@@ -52,11 +52,11 @@ namespace Spring.Expressions
/// Current expression evaluation context.
///
/// true if the left operand is contained within the right operand, false otherwise.
- ///
+ ///
protected override object Get(object context, EvaluationContext evalContext)
{
- object instance = Left.GetValueInternal( context, evalContext );
- Type type = Right.GetValueInternal( context, evalContext ) as Type;
+ object instance = GetLeftValue( context, evalContext );
+ Type type = GetRightValue( context, evalContext ) as Type;
if (instance == null || type == null)
{
diff --git a/src/Spring/Spring.Core/Expressions/OpLess.cs b/src/Spring/Spring.Core/Expressions/OpLess.cs
index 22375c72..092b9fff 100644
--- a/src/Spring/Spring.Core/Expressions/OpLess.cs
+++ b/src/Spring/Spring.Core/Expressions/OpLess.cs
@@ -51,11 +51,11 @@ namespace Spring.Expressions
///
/// Context to evaluate expressions against.
/// Current expression evaluation context.
- /// Node's value.
+ /// Node's value.
protected override object Get(object context, EvaluationContext evalContext)
{
- object left = Left.GetValueInternal( context, evalContext );
- object right = Right.GetValueInternal( context, evalContext );
+ object left = GetLeftValue( context, evalContext );
+ object right = GetRightValue( context, evalContext );
return CompareUtils.Compare(left, right) < 0;
}
diff --git a/src/Spring/Spring.Core/Expressions/OpLessOrEqual.cs b/src/Spring/Spring.Core/Expressions/OpLessOrEqual.cs
index 75a4c2ce..3b153e8b 100644
--- a/src/Spring/Spring.Core/Expressions/OpLessOrEqual.cs
+++ b/src/Spring/Spring.Core/Expressions/OpLessOrEqual.cs
@@ -52,11 +52,11 @@ namespace Spring.Expressions
///
/// Context to evaluate expressions against.
/// Current expression evaluation context.
- /// Node's value.
+ /// Node's value.
protected override object Get(object context, EvaluationContext evalContext)
{
- object left = Left.GetValueInternal( context, evalContext );
- object right = Right.GetValueInternal( context, evalContext );
+ object left = GetLeftValue( context, evalContext );
+ object right = GetRightValue( context, evalContext );
return CompareUtils.Compare(left, right) <= 0;
}
diff --git a/src/Spring/Spring.Core/Expressions/OpLike.cs b/src/Spring/Spring.Core/Expressions/OpLike.cs
index a85bd05e..f99c267e 100644
--- a/src/Spring/Spring.Core/Expressions/OpLike.cs
+++ b/src/Spring/Spring.Core/Expressions/OpLike.cs
@@ -56,12 +56,12 @@ namespace Spring.Expressions
/// Current expression evaluation context.
///
/// true if the left operand matches the right operand, false otherwise.
- ///
+ ///
protected override object Get(object context, EvaluationContext evalContext)
{
#if NET_2_0 && !MONO_2_0
- string text = Left.GetValueInternal( context, evalContext ) as string;
- string pattern = Right.GetValueInternal( context, evalContext ) as string;
+ string text = GetLeftValue( context, evalContext ) as string;
+ string pattern = GetRightValue( context, evalContext ) as string;
return LikeOperator.LikeString(text, pattern, CompareMethod.Text);
#else
diff --git a/src/Spring/Spring.Core/Expressions/OpMODULUS.cs b/src/Spring/Spring.Core/Expressions/OpMODULUS.cs
index 86a845ac..6e3e5393 100644
--- a/src/Spring/Spring.Core/Expressions/OpMODULUS.cs
+++ b/src/Spring/Spring.Core/Expressions/OpMODULUS.cs
@@ -51,22 +51,22 @@ namespace Spring.Expressions
///
/// Context to evaluate expressions against.
/// Current expression evaluation context.
- /// Node's value.
+ /// Node's value.
protected override object Get(object context, EvaluationContext evalContext)
{
- object left = Left.GetValueInternal( context, evalContext );
- object right = Right.GetValueInternal( context, evalContext );
+ object leftVal = GetLeftValue(context, evalContext );
+ object rightVal = GetRightValue(context, evalContext );
- if (NumberUtils.IsNumber(left) && NumberUtils.IsNumber(right))
+ if (NumberUtils.IsNumber(leftVal) && NumberUtils.IsNumber(rightVal))
{
- return NumberUtils.Modulus(left, right);
+ return NumberUtils.Modulus(leftVal, rightVal);
}
else
{
throw new ArgumentException("Cannot calculate modulus for instances of '"
- + left.GetType().FullName
+ + leftVal.GetType().FullName
+ "' and '"
- + right.GetType().FullName
+ + rightVal.GetType().FullName
+ "'.");
}
}
diff --git a/src/Spring/Spring.Core/Expressions/OpMULTIPLY.cs b/src/Spring/Spring.Core/Expressions/OpMULTIPLY.cs
index a117238c..f5a5df7d 100644
--- a/src/Spring/Spring.Core/Expressions/OpMULTIPLY.cs
+++ b/src/Spring/Spring.Core/Expressions/OpMULTIPLY.cs
@@ -53,11 +53,11 @@ namespace Spring.Expressions
///
/// Context to evaluate expressions against.
/// Current expression evaluation context.
- /// Node's value.
+ /// Node's value.
protected override object Get(object context, EvaluationContext evalContext)
{
- object left = Left.GetValueInternal( context, evalContext );
- object right = Right.GetValueInternal( context, evalContext );
+ object left = GetLeftValue( context, evalContext );
+ object right = GetRightValue( context, evalContext );
if (NumberUtils.IsNumber(left) && NumberUtils.IsNumber(right))
{
diff --git a/src/Spring/Spring.Core/Expressions/OpMatches.cs b/src/Spring/Spring.Core/Expressions/OpMatches.cs
index 25366b09..739128e0 100644
--- a/src/Spring/Spring.Core/Expressions/OpMatches.cs
+++ b/src/Spring/Spring.Core/Expressions/OpMatches.cs
@@ -55,7 +55,7 @@ namespace Spring.Expressions
/// Current expression evaluation context.
///
/// true if the left operand matches the right operand, false otherwise.
- ///
+ ///
protected override object Get(object context, EvaluationContext evalContext)
{
if (regex == null)
@@ -64,13 +64,13 @@ namespace Spring.Expressions
{
if (regex == null)
{
- string pattern = Right.GetValueInternal( context, evalContext ) as string;
+ string pattern = GetRightValue( context, evalContext ) as string;
regex = new Regex(pattern, RegexOptions.Compiled);
}
}
}
- string text = Left.GetValueInternal( context, evalContext ) as string;
+ string text = GetLeftValue( context, evalContext ) as string;
return regex.IsMatch(text);
}
}
diff --git a/src/Spring/Spring.Core/Expressions/OpNOT.cs b/src/Spring/Spring.Core/Expressions/OpNOT.cs
index 5203d73c..5d7dd9ad 100644
--- a/src/Spring/Spring.Core/Expressions/OpNOT.cs
+++ b/src/Spring/Spring.Core/Expressions/OpNOT.cs
@@ -59,10 +59,10 @@ namespace Spring.Expressions
///
/// Context to evaluate expressions against.
/// Current expression evaluation context.
- /// Node's value.
+ /// Node's value.
protected override object Get(object context, EvaluationContext evalContext)
{
- object operand = Operand.GetValueInternal(context, evalContext);
+ object operand = GetValue(Operand, context, evalContext);
if (NumberUtils.IsInteger(operand))
{
return NumberUtils.BitwiseNot(operand);
diff --git a/src/Spring/Spring.Core/Expressions/OpNotEqual.cs b/src/Spring/Spring.Core/Expressions/OpNotEqual.cs
index 80874b32..77ecf35a 100644
--- a/src/Spring/Spring.Core/Expressions/OpNotEqual.cs
+++ b/src/Spring/Spring.Core/Expressions/OpNotEqual.cs
@@ -51,34 +51,34 @@ namespace Spring.Expressions
///
/// Context to evaluate expressions against.
/// Current expression evaluation context.
- /// Node's value.
+ /// Node's value.
protected override object Get(object context, EvaluationContext evalContext)
{
- object left = Left.GetValueInternal( context, evalContext );
- object right = Right.GetValueInternal( context, evalContext );
+ object leftVal = GetLeftValue( context, evalContext );
+ object rightVal = GetRightValue( context, evalContext );
- if (left == null)
+ if (leftVal == null)
{
- return (right != null);
+ return (rightVal != null);
}
- else if (right == null)
+ else if (rightVal == null)
{
return true;
}
- else if (left.GetType() == right.GetType())
+ else if (leftVal.GetType() == rightVal.GetType())
{
- if (left is Array)
+ if (leftVal is Array)
{
- return !ArrayUtils.AreEqual(left as Array, right as Array);
+ return !ArrayUtils.AreEqual(leftVal as Array, rightVal as Array);
}
else
{
- return !left.Equals(right);
+ return !leftVal.Equals(rightVal);
}
}
else
{
- return CompareUtils.Compare(left, right) != 0;
+ return CompareUtils.Compare(leftVal, rightVal) != 0;
}
}
}
diff --git a/src/Spring/Spring.Core/Expressions/OpOR.cs b/src/Spring/Spring.Core/Expressions/OpOR.cs
index ca5b8929..2cd62e89 100644
--- a/src/Spring/Spring.Core/Expressions/OpOR.cs
+++ b/src/Spring/Spring.Core/Expressions/OpOR.cs
@@ -59,11 +59,11 @@ namespace Spring.Expressions
///
/// Context to evaluate expressions against.
/// Current expression evaluation context.
- /// Node's value.
+ /// Node's value.
protected override object Get(object context, EvaluationContext evalContext)
{
- object l = Left.GetValueInternal(context, evalContext);
- object r = Right.GetValueInternal(context, evalContext);
+ object l = GetLeftValue(context, evalContext);
+ object r = GetRightValue(context, evalContext);
if (NumberUtils.IsInteger(l) && NumberUtils.IsInteger(r))
{
diff --git a/src/Spring/Spring.Core/Expressions/OpPOWER.cs b/src/Spring/Spring.Core/Expressions/OpPOWER.cs
index dc8c8ed9..333ccd68 100644
--- a/src/Spring/Spring.Core/Expressions/OpPOWER.cs
+++ b/src/Spring/Spring.Core/Expressions/OpPOWER.cs
@@ -51,11 +51,11 @@ namespace Spring.Expressions
///
/// Context to evaluate expressions against.
/// Current expression evaluation context.
- /// Node's value.
+ /// Node's value.
protected override object Get(object context, EvaluationContext evalContext)
{
- object left = Left.GetValueInternal( context, evalContext );
- object right = Right.GetValueInternal( context, evalContext );
+ object left = GetLeftValue( context, evalContext );
+ object right = GetRightValue( context, evalContext );
if (NumberUtils.IsNumber(left) && NumberUtils.IsNumber(right))
{
diff --git a/src/Spring/Spring.Core/Expressions/OpSUBTRACT.cs b/src/Spring/Spring.Core/Expressions/OpSUBTRACT.cs
index 49468c93..0fbe4ee6 100644
--- a/src/Spring/Spring.Core/Expressions/OpSUBTRACT.cs
+++ b/src/Spring/Spring.Core/Expressions/OpSUBTRACT.cs
@@ -53,11 +53,11 @@ namespace Spring.Expressions
///
/// Context to evaluate expressions against.
/// Current expression evaluation context.
- /// Node's value.
+ /// Node's value.
protected override object Get(object context, EvaluationContext evalContext)
{
- object left = Left.GetValueInternal( context, evalContext );
- object right = Right.GetValueInternal( context, evalContext );
+ object left = GetLeftValue( context, evalContext );
+ object right = GetRightValue( context, evalContext );
if (NumberUtils.IsNumber(left) && NumberUtils.IsNumber(right))
{
diff --git a/src/Spring/Spring.Core/Expressions/OpUnaryMinus.cs b/src/Spring/Spring.Core/Expressions/OpUnaryMinus.cs
index 94ed5049..1d258b34 100644
--- a/src/Spring/Spring.Core/Expressions/OpUnaryMinus.cs
+++ b/src/Spring/Spring.Core/Expressions/OpUnaryMinus.cs
@@ -51,10 +51,10 @@ namespace Spring.Expressions
///
/// Context to evaluate expressions against.
/// Current expression evaluation context.
- /// Node's value.
+ /// Node's value.
protected override object Get(object context, EvaluationContext evalContext)
{
- object n = Operand.GetValueInternal( context, evalContext );
+ object n = GetValue(Operand, context, evalContext );
if (!NumberUtils.IsNumber(n))
{
diff --git a/src/Spring/Spring.Core/Expressions/OpUnaryPlus.cs b/src/Spring/Spring.Core/Expressions/OpUnaryPlus.cs
index 76ccd982..cd660229 100644
--- a/src/Spring/Spring.Core/Expressions/OpUnaryPlus.cs
+++ b/src/Spring/Spring.Core/Expressions/OpUnaryPlus.cs
@@ -51,10 +51,10 @@ namespace Spring.Expressions
///
/// Context to evaluate expressions against.
/// Current expression evaluation context.
- /// Node's value.
+ /// Node's value.
protected override object Get(object context, EvaluationContext evalContext)
- {
- object n = Operand.GetValueInternal( context, evalContext );
+ {
+ object n = GetValue(Operand, context, evalContext);
if (!NumberUtils.IsNumber(n))
{
diff --git a/src/Spring/Spring.Core/Expressions/OpXOR.cs b/src/Spring/Spring.Core/Expressions/OpXOR.cs
index 82a2c403..487455ff 100644
--- a/src/Spring/Spring.Core/Expressions/OpXOR.cs
+++ b/src/Spring/Spring.Core/Expressions/OpXOR.cs
@@ -57,11 +57,11 @@ namespace Spring.Expressions
///
/// Context to evaluate expressions against.
/// Current expression evaluation context.
- /// Node's value.
+ /// Node's value.
protected override object Get(object context, EvaluationContext evalContext)
{
- object l = Left.GetValueInternal(context, evalContext);
- object r = Right.GetValueInternal(context, evalContext);
+ object l = GetLeftValue(context, evalContext);
+ object r = GetRightValue(context, evalContext);
if (NumberUtils.IsInteger(l) && NumberUtils.IsInteger(r))
{
diff --git a/src/Spring/Spring.Core/Expressions/ProjectionNode.cs b/src/Spring/Spring.Core/Expressions/ProjectionNode.cs
index 707fe759..5d5c1635 100644
--- a/src/Spring/Spring.Core/Expressions/ProjectionNode.cs
+++ b/src/Spring/Spring.Core/Expressions/ProjectionNode.cs
@@ -52,7 +52,7 @@ namespace Spring.Expressions
///
/// Context to evaluate expressions against.
/// Current expression evaluation context.
- /// Node's value.
+ /// Node's value.
protected override object Get(object context, EvaluationContext evalContext)
{
IEnumerable enumerable = context as IEnumerable;
@@ -68,8 +68,8 @@ namespace Spring.Expressions
{
foreach(object o in enumerable)
{
- evalContext.ThisContext = o;
- projectedList.Add(expression.GetValueInternal(o, evalContext));
+ evalContext.ThisContext = o;
+ projectedList.Add(GetValue(expression, o, evalContext));
}
}
return projectedList;
diff --git a/src/Spring/Spring.Core/Expressions/PropertyOrFieldNode.cs b/src/Spring/Spring.Core/Expressions/PropertyOrFieldNode.cs
index ef8c8d3c..eef97bdc 100644
--- a/src/Spring/Spring.Core/Expressions/PropertyOrFieldNode.cs
+++ b/src/Spring/Spring.Core/Expressions/PropertyOrFieldNode.cs
@@ -211,7 +211,7 @@ namespace Spring.Expressions
///
/// Context to evaluate expressions against.
/// Current expression evaluation context.
- /// Node's value.
+ /// Node's value.
protected override object Get(object context, EvaluationContext evalContext)
{
lock (this)
diff --git a/src/Spring/Spring.Core/Expressions/RealLiteralNode.cs b/src/Spring/Spring.Core/Expressions/RealLiteralNode.cs
index cf845e95..009f5d38 100644
--- a/src/Spring/Spring.Core/Expressions/RealLiteralNode.cs
+++ b/src/Spring/Spring.Core/Expressions/RealLiteralNode.cs
@@ -53,7 +53,7 @@ namespace Spring.Expressions
///
/// Context to evaluate expressions against.
/// Current expression evaluation context.
- /// Node's value.
+ /// Node's value.
protected override object Get(object context, EvaluationContext evalContext)
{
if (nodeValue == null)
diff --git a/src/Spring/Spring.Core/Expressions/ReferenceNode.cs b/src/Spring/Spring.Core/Expressions/ReferenceNode.cs
index 8bdb98fa..f74ab233 100644
--- a/src/Spring/Spring.Core/Expressions/ReferenceNode.cs
+++ b/src/Spring/Spring.Core/Expressions/ReferenceNode.cs
@@ -52,7 +52,7 @@ namespace Spring.Context.Support
///
/// Context to evaluate expressions against.
/// Current expression evaluation context.
- /// Node's value.
+ /// Node's value.
protected override object Get(object context, EvaluationContext evalContext)
{
IApplicationContext ctx;
diff --git a/src/Spring/Spring.Core/Expressions/SelectionFirstNode.cs b/src/Spring/Spring.Core/Expressions/SelectionFirstNode.cs
index f7e0aec0..74139272 100644
--- a/src/Spring/Spring.Core/Expressions/SelectionFirstNode.cs
+++ b/src/Spring/Spring.Core/Expressions/SelectionFirstNode.cs
@@ -51,7 +51,7 @@ namespace Spring.Expressions
///
/// Context to evaluate expressions against.
/// Current expression evaluation context.
- /// Node's value.
+ /// Node's value.
protected override object Get(object context, EvaluationContext evalContext)
{
IEnumerable enumerable = context as IEnumerable;
@@ -66,8 +66,8 @@ namespace Spring.Expressions
{
foreach (object o in enumerable)
{
- evalContext.ThisContext = o;
- bool isMatch = (bool) expression.GetValueInternal(o, evalContext);
+ evalContext.ThisContext = o;
+ bool isMatch = (bool)GetValue(expression, o, evalContext);
if (isMatch)
{
return o;
diff --git a/src/Spring/Spring.Core/Expressions/SelectionLastNode.cs b/src/Spring/Spring.Core/Expressions/SelectionLastNode.cs
index 0b6af921..b38645a4 100644
--- a/src/Spring/Spring.Core/Expressions/SelectionLastNode.cs
+++ b/src/Spring/Spring.Core/Expressions/SelectionLastNode.cs
@@ -51,7 +51,7 @@ namespace Spring.Expressions
///
/// Context to evaluate expressions against.
/// Current expression evaluation context.
- /// Node's value.
+ /// Node's value.
protected override object Get(object context, EvaluationContext evalContext)
{
IList list = context as IList;
@@ -69,7 +69,7 @@ namespace Spring.Expressions
{
object listItem = list[i];
evalContext.ThisContext = listItem;
- bool isMatch = (bool)expression.GetValueInternal( listItem, evalContext );
+ bool isMatch = (bool)GetValue(expression, listItem, evalContext );
if (isMatch)
{
return listItem;
diff --git a/src/Spring/Spring.Core/Expressions/SelectionNode.cs b/src/Spring/Spring.Core/Expressions/SelectionNode.cs
index 454ce117..fe55e96e 100644
--- a/src/Spring/Spring.Core/Expressions/SelectionNode.cs
+++ b/src/Spring/Spring.Core/Expressions/SelectionNode.cs
@@ -53,7 +53,7 @@ namespace Spring.Expressions
///
/// Context to evaluate expressions against.
/// Current expression evaluation context.
- /// Node's value.
+ /// Node's value.
protected override object Get(object context, EvaluationContext evalContext)
{
IEnumerable enumerable = context as IEnumerable;
@@ -68,11 +68,11 @@ namespace Spring.Expressions
BaseNode maxIndexExpression = (minIndexExpression == null) ? null : (BaseNode)minIndexExpression.getNextSibling();
int minIndex = (int)((minIndexExpression == null)
- ? Int32.MinValue
- : minIndexExpression.GetValueInternal(context, evalContext));
+ ? Int32.MinValue
+ : GetValue(minIndexExpression, context, evalContext));
int maxIndex = (int)((maxIndexExpression == null)
- ? Int32.MaxValue
- : maxIndexExpression.GetValueInternal(context, evalContext));
+ ? Int32.MaxValue
+ : GetValue(maxIndexExpression, context, evalContext));
IList selectionList = new ArrayList();
@@ -81,8 +81,8 @@ namespace Spring.Expressions
int found = 0;
foreach (object o in enumerable)
{
- evalContext.ThisContext = o;
- bool isMatch = (bool)expression.GetValueInternal(o, evalContext);
+ evalContext.ThisContext = o;
+ bool isMatch = (bool)GetValue(expression, o, evalContext);
if (isMatch)
{
if (minIndex <= found && found <= maxIndex)
diff --git a/src/Spring/Spring.Core/Expressions/StringLiteralNode.cs b/src/Spring/Spring.Core/Expressions/StringLiteralNode.cs
index 7c9faf3c..8d3d7e06 100644
--- a/src/Spring/Spring.Core/Expressions/StringLiteralNode.cs
+++ b/src/Spring/Spring.Core/Expressions/StringLiteralNode.cs
@@ -58,7 +58,7 @@ namespace Spring.Expressions
///
/// Context to evaluate expressions against.
/// Current expression evaluation context.
- /// Node's value.
+ /// Node's value.
protected override object Get(object context, EvaluationContext evalContext)
{
return this.getText();
diff --git a/src/Spring/Spring.Core/Expressions/TernaryNode.cs b/src/Spring/Spring.Core/Expressions/TernaryNode.cs
index 3f3a58b9..8c2d2a2e 100644
--- a/src/Spring/Spring.Core/Expressions/TernaryNode.cs
+++ b/src/Spring/Spring.Core/Expressions/TernaryNode.cs
@@ -56,7 +56,7 @@ namespace Spring.Expressions
///
/// Context to evaluate expressions against.
/// Current expression evaluation context.
- /// Node's value.
+ /// Node's value.
protected override object Get(object context, EvaluationContext evalContext)
{
if (!initialized)
@@ -75,15 +75,15 @@ namespace Spring.Expressions
initialized = true;
}
}
- }
-
- if (Convert.ToBoolean(condition.GetValueInternal(context, evalContext)))
- {
- return trueExp.GetValueInternal(context, evalContext);
+ }
+
+ if (Convert.ToBoolean(GetValue(condition, context, evalContext)))
+ {
+ return GetValue(trueExp, context, evalContext);
}
else
- {
- return falseExp.GetValueInternal(context, evalContext);
+ {
+ return GetValue(falseExp, context, evalContext);
}
}
}
diff --git a/src/Spring/Spring.Core/Reflection/Dynamic/DynamicMethod.cs b/src/Spring/Spring.Core/Reflection/Dynamic/DynamicMethod.cs
index b50dbffa..36565b12 100644
--- a/src/Spring/Spring.Core/Reflection/Dynamic/DynamicMethod.cs
+++ b/src/Spring/Spring.Core/Reflection/Dynamic/DynamicMethod.cs
@@ -89,7 +89,23 @@ namespace Spring.Reflection.Dynamic
}
}
- private static readonly IDictionary stateCache = new HybridDictionary();
+ private class IdentityTable : Hashtable
+ {
+ public IdentityTable()
+ {}
+
+ protected override int GetHash(object key)
+ {
+ return key.GetHashCode();
+ }
+
+ protected override bool KeyEquals(object item, object key)
+ {
+ return ReferenceEquals(item, key);
+ }
+ }
+
+ private static readonly Hashtable stateCache = new IdentityTable();
#endregion
diff --git a/test/Spring/Spring.Core.Tests/Expressions/FunctionNodeTests.cs b/test/Spring/Spring.Core.Tests/Expressions/FunctionNodeTests.cs
index f4dd6b10..d1eaee94 100644
--- a/test/Spring/Spring.Core.Tests/Expressions/FunctionNodeTests.cs
+++ b/test/Spring/Spring.Core.Tests/Expressions/FunctionNodeTests.cs
@@ -97,27 +97,22 @@ namespace Spring.Expressions
str.Text = "theArg";
fn.addChild(str);
- IExpression exp = fn;
-
- string result = str.Text;
-// string result = string.Format("{0},{1},{2}", this.GetHashCode(), str.Text, str2.Text);
-
- int ITERATIONS = 1000000;
+ int ITERATIONS = 10000000;
StopWatch watch = new StopWatch();
-// using (watch.Start("Duration Direct: {0}"))
-// {
-// for (int i = 0; i < ITERATIONS; i++)
-// {
-// noop(str.getText());
-// }
-// }
+ using (watch.Start("Duration Direct: {0}"))
+ {
+ for (int i = 0; i < ITERATIONS; i++)
+ {
+ ((WaitCallback)vars["noop"])(str.getText());
+ }
+ }
using (watch.Start("Duration SpEL: {0}"))
{
for (int i = 0; i < ITERATIONS; i++)
{
- exp.GetValue(null, vars);
+ fn.GetValue(null, vars);
}
}
}