2using System.Threading.Tasks;
14 private readonly
string name;
15 private readonly
string value;
16 private readonly
double parsed;
17 private readonly
bool hasEmbeddedScript;
18 private readonly
bool isOnlyScript;
29 this.hasEmbeddedScript =
false;
30 this.isOnlyScript =
false;
31 this.expression =
null;
33 int i =
Value.IndexOf(
'{');
36 int j =
Value.IndexOf(
'}', i + 1);
37 this.hasEmbeddedScript = j > i;
38 this.isOnlyScript = this.hasEmbeddedScript && i == 0 && j == Value.Length - 1;
39 if (this.isOnlyScript)
44 throw new Exception(
"Invalid double value: " +
Value);
50 public string Name => this.name;
55 public double Value => this.parsed;
64 if (!this.hasEmbeddedScript)
67 if (this.isOnlyScript)
69 object Obj = await this.expression.EvaluateAsync(
Variables);
77 throw new Exception(
"Invalid double value: " + s);
91 if (d < byte.MinValue || d >
byte.MaxValue)
92 throw new ArgumentOutOfRangeException(this.name, d,
"Out of byte range.");
105 if (d < ushort.MinValue || d > ushort.MaxValue)
106 throw new ArgumentOutOfRangeException(this.name, d,
"Out of ushort range.");
119 if (d < uint.MinValue || d > uint.MaxValue)
120 throw new ArgumentOutOfRangeException(this.name, d,
"Out of uint range.");
133 if (d < ulong.MinValue || d > ulong.MaxValue)
134 throw new ArgumentOutOfRangeException(this.name, d,
"Out of ulong range.");
147 if (d < sbyte.MinValue || d > sbyte.MaxValue)
148 throw new ArgumentOutOfRangeException(this.name, d,
"Out of sbyte range.");
161 if (d < short.MinValue || d >
short.MaxValue)
162 throw new ArgumentOutOfRangeException(this.name, d,
"Out of short range.");
175 if (d < int.MinValue || d >
int.MaxValue)
176 throw new ArgumentOutOfRangeException(this.name, d,
"Out of int range.");
189 if (d < long.MinValue || d >
long.MaxValue)
190 throw new ArgumentOutOfRangeException(this.name, d,
"Out of long range.");
Contains the value of a double attribute, possibly with embedded script.
async Task< ushort > GetUInt16ValueAsync(Variables Variables)
Gets the value of the attribute, as an unsigned 16-bit integer.
async Task< double > GetValueAsync(Variables Variables)
Gets the value of the attribute.
async Task< byte > GetUInt8ValueAsync(Variables Variables)
Gets the value of the attribute, as an unsigned 8-bit integer.
async Task< int > GetInt32ValueAsync(Variables Variables)
Gets the value of the attribute, as a signed 32-bit integer.
DoubleAttribute(string Name, string Value)
Contains the value of a string attribute, possibly with embedded script.
async Task< uint > GetUInt32ValueAsync(Variables Variables)
Gets the value of the attribute, as an unsigned 32-bit integer.
async Task< long > GetInt64ValueAsync(Variables Variables)
Gets the value of the attribute, as a signed 64-bit integer.
async Task< sbyte > GetInt8ValueAsync(Variables Variables)
Gets the value of the attribute, as a signed 8-bit integer.
async Task< ulong > GetUInt64ValueAsync(Variables Variables)
Gets the value of the attribute, as an unsigned 64-bit integer.
string Name
Name of attribute.
double Value
Double value, from definition
async Task< short > GetInt16ValueAsync(Variables Variables)
Gets the value of the attribute, as a signed 16-bit integer.
Helps with parsing of commong data types.
static bool TryParse(string s, out double Value)
Tries to decode a string encoded double.
Class managing a script expression.
static double ToDouble(object Object)
Converts an object to a double value.
static Task< string > TransformAsync(string s, string StartDelimiter, string StopDelimiter, Variables Variables)
Transforms a string by executing embedded script.