Thomas Darimont
Erfahrenes Mitglied
Hallo,
hier mal ein kleines Beispiel für die Möglichkeiten der generischen Auswertung von Ausdrücken
(Expression EValuation) in Springframework.Net ( http://springframework.net/)
Die Dokumentation zur ExpressionEvaluation findet man hier:
http://springframework.net/doc-1.1-M1/reference/html/expressions.html
Ausgabe:
Gruß Tom
hier mal ein kleines Beispiel für die Möglichkeiten der generischen Auswertung von Ausdrücken
(Expression EValuation) in Springframework.Net ( http://springframework.net/)
Die Dokumentation zur ExpressionEvaluation findet man hier:
http://springframework.net/doc-1.1-M1/reference/html/expressions.html
C#:
using System;
using System.Collections.Generic;
using System.Text;
using Spring.Expressions;
namespace De.Tutorials.Training
{
public class ExpressionEvaluationExample
{
public static void Main(string[] args)
{
Console.WriteLine(ExpressionEvaluator.GetValue(null, "21 + 4 * 3"));
AX a = new AX(new BX(new CX[] { new CX("XXX"),new CX("YYY"),new CX("ZZZ")}));
Console.WriteLine(ExpressionEvaluator.GetValue(a,"BProperty.CProperties[1].Message"));
}
}
class AX
{
private BX bProperty;
public BX BProperty
{
get { return bProperty; }
set { bProperty = value; }
}
public AX(BX b)
{
this.bProperty = b;
}
}
class BX
{
private CX[] cProperties;
public CX[] CProperties
{
get { return cProperties; }
set { cProperties = value; }
}
public BX(CX[] cs)
{
this.cProperties = cs;
}
}
class CX
{
private String message;
public String Message
{
get { return message; }
set { message = value; }
}
public CX(string message)
{
this.message = message;
}
}
}
Ausgabe:
Code:
33
YYY
Drücken Sie eine beliebige Taste . . .
Gruß Tom