2using System.Threading.Tasks;
16 private readonly
string definition;
19 private readonly
bool isExpression;
20 private bool first =
true;
29 if (
string.IsNullOrEmpty(AttributeName))
30 this.definition = Xml.InnerText;
34 this.isExpression = this.definition.StartsWith(
'{') && this.definition.EndsWith(
'}');
55 public bool IsEmpty =>
string.IsNullOrEmpty(this.definition);
74 return Task.FromResult(DefaultValue);
88 if (this.isExpression)
89 this.expression =
new Expression(this.definition[1..^1]);
91 this.constant = this.
ParseValue(this.definition);
96 if (this.isExpression)
100 if (Result is T TypedResult)
102 else if (Result is
null)
106 StringBuilder sb =
new StringBuilder();
108 sb.Append(
"Expected a value of type ");
109 sb.Append(typeof(T).FullName);
110 sb.Append(
" but got a value of type ");
111 sb.Append(Result.GetType().FullName ??
"null");
118 return this.constant;
Helps with common XML-related tasks.
static string Attribute(XmlElement E, string Name)
Gets the value of an XML attribute.
Abstract base class for report attributes.
bool IsConstant
If the attribute value is a constant.
bool IsEmpty
If the definition is empty.
Task< T > Evaluate(Variables Variables, T DefaultValue)
Evaluates the attribute, if defined, or returns the DefaultValue if attribute is not defined.
abstract T ParseValue(string s)
Parses a string representation of a value.
async Task< T > Evaluate(Variables Variables)
Evaluates the attribute
string Definition
Attribute definition
ReportAttribute(XmlElement Xml, string AttributeName)
Abstract base class for report attributes.
bool IsExpression
If the attribute value is an expression.
Script runtime exception.
Class managing a script expression.
async Task< object > EvaluateAsync(Variables Variables)
Evaluates the expression, using the variables provided in the Variables collection....