|
@@ -8,6 +8,7 @@ using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Text;
|
|
using System.Text.RegularExpressions;
|
|
using System.Text.RegularExpressions;
|
|
|
|
+using Expressive.Exceptions;
|
|
|
|
|
|
namespace InABox.Core
|
|
namespace InABox.Core
|
|
{
|
|
{
|
|
@@ -118,7 +119,9 @@ namespace InABox.Core
|
|
|
|
|
|
public static List<string> GetModelVariables(Type modelType)
|
|
public static List<string> GetModelVariables(Type modelType)
|
|
{
|
|
{
|
|
- return CoreUtils.PropertyList(modelType, x => true).Select(x => x.Name).ToList();
|
|
|
|
|
|
+ var props = DatabaseSchema.Properties(modelType).Select(x => x.Name).ToList();
|
|
|
|
+ props.Sort();
|
|
|
|
+ return props;
|
|
}
|
|
}
|
|
public static List<string> GetModelVariables<TModel>() where TModel : IExpressionModel
|
|
public static List<string> GetModelVariables<TModel>() where TModel : IExpressionModel
|
|
=> GetModelVariables(typeof(TModel));
|
|
=> GetModelVariables(typeof(TModel));
|
|
@@ -162,8 +165,8 @@ namespace InABox.Core
|
|
}
|
|
}
|
|
return default;
|
|
return default;
|
|
}
|
|
}
|
|
- [return: MaybeNull]
|
|
|
|
- public TReturn Evaluate(TModel model)
|
|
|
|
|
|
+
|
|
|
|
+ public Result<TReturn, Exception> Evaluate(TModel model)
|
|
{
|
|
{
|
|
var values = new Dictionary<string, object?>();
|
|
var values = new Dictionary<string, object?>();
|
|
foreach(var variable in ReferencedVariables)
|
|
foreach(var variable in ReferencedVariables)
|
|
@@ -171,12 +174,19 @@ namespace InABox.Core
|
|
values[variable] = CoreUtils.GetPropertyValue(model, variable);
|
|
values[variable] = CoreUtils.GetPropertyValue(model, variable);
|
|
}
|
|
}
|
|
|
|
|
|
- var result = base.Evaluate(values);
|
|
|
|
- if(result is TReturn ret)
|
|
|
|
|
|
+ try
|
|
{
|
|
{
|
|
- return ret;
|
|
|
|
|
|
+ var result = base.Evaluate(values);
|
|
|
|
+ if(result is TReturn ret)
|
|
|
|
+ {
|
|
|
|
+ return Result.Ok(ret);
|
|
|
|
+ }
|
|
|
|
+ return Result.Ok<TReturn>(default);
|
|
|
|
+ }
|
|
|
|
+ catch (Exception e)
|
|
|
|
+ {
|
|
|
|
+ return Result.Error(e);
|
|
}
|
|
}
|
|
- return default;
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|