feature: update expression browser and add plugin expression extensions

This commit is contained in:
Gary Sharp
2025-01-16 12:36:01 +11:00
parent 963970feeb
commit a3e1e1d030
23 changed files with 652 additions and 555 deletions
@@ -5,9 +5,9 @@ namespace Disco.Services.Expressions
{
public class EvaluateExpressionPart : IExpressionPart
{
private Spring.Expressions.IExpression _Expression;
private RecognitionException _ExpressionParseException;
private EvaluateExpressionParseException _EvaluateParseException;
private Spring.Expressions.IExpression expression;
private RecognitionException expressionParseException;
private EvaluateExpressionParseException evaluateParseException;
public string RawSource { get; set; }
public string Source { get; set; }
@@ -18,18 +18,18 @@ namespace Disco.Services.Expressions
{
get
{
if (_ExpressionParseException == null)
if (expressionParseException == null)
return null;
else
if (_EvaluateParseException == null)
_EvaluateParseException = EvaluateExpressionParseException.FromRecognitionException(_ExpressionParseException, Source);
return _EvaluateParseException;
if (evaluateParseException == null)
evaluateParseException = EvaluateExpressionParseException.FromRecognitionException(expressionParseException, Source);
return evaluateParseException;
}
}
public bool ParseError
{
get { return (_ExpressionParseException != null); }
get { return (expressionParseException != null); }
}
public string ParseErrorMessage
{
@@ -61,21 +61,21 @@ namespace Disco.Services.Expressions
}
try
{
_Expression = Spring.Expressions.Expression.Parse(this.Source);
expression = Spring.Expressions.Expression.Parse(this.Source);
}
catch (RecognitionException ex)
{
_ExpressionParseException = ex;
expressionParseException = ex;
}
}
object IExpressionPart.Evaluate(object ExpressionContext, IDictionary Variables)
{
if (_ExpressionParseException == null)
if (expressionParseException == null)
{
return _Expression.GetValue(ExpressionContext, Variables);
return expression.GetValue(ExpressionContext, Variables);
}
throw _ExpressionParseException;
throw expressionParseException;
}
}
-5
View File
@@ -73,11 +73,6 @@ namespace Disco.Services.Expressions
return result;
}
internal static IExpression Parse(string source)
{
throw new NotImplementedException();
}
public Tuple<string, bool, object> Evaluate(object ExpressionContext, IDictionary Variables)
{
if (Count == 0)
@@ -11,7 +11,7 @@ namespace Disco.Services.Expressions
public string Name { get; set; }
public List<ExpressionTypeMemberDescriptor> Members { get; set; }
public static ExpressionTypeDescriptor Build(Type t, bool StaticDeclaredMembersOnly = true)
public static ExpressionTypeDescriptor Build(Type t, bool staticMembersOnly = true)
{
ExpressionTypeDescriptor i = new ExpressionTypeDescriptor
{
@@ -21,7 +21,7 @@ namespace Disco.Services.Expressions
i.Members = new List<ExpressionTypeMemberDescriptor>();
MemberInfo[] members;
if (StaticDeclaredMembersOnly)
if (staticMembersOnly)
members = t.GetMembers(BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly);
else
members = t.GetMembers(BindingFlags.Public | BindingFlags.Instance);
@@ -46,10 +46,7 @@ namespace Disco.Services.Expressions
}
}
}
i.Members = (
from mi in i.Members
orderby mi.Name
select mi).ToList();
i.Members = i.Members.OrderBy(m => m.Name).ToList();
return i;
}
}