3using System.Threading.Tasks;
41 public override void Serialize(StringBuilder Xml,
bool UsingTemplate)
43 Xml.Append(
"<numericalParameter");
47 if (!
string.IsNullOrEmpty(this.Expression))
49 Xml.Append(
" exp=\"");
50 Xml.Append(
XML.
Encode(
this.Expression.Normalize(NormalizationForm.FormC)));
54 if (!
string.IsNullOrEmpty(this.Guide))
56 Xml.Append(
" guide=\"");
57 Xml.Append(
XML.
Encode(
this.Guide.Normalize(NormalizationForm.FormC)));
61 if (this.
Max.HasValue)
63 Xml.Append(
" max=\"");
65 Xml.Append(
"\" maxIncluded=\"");
70 if (this.
Min.HasValue)
72 Xml.Append(
" min=\"");
74 Xml.Append(
"\" minIncluded=\"");
80 Xml.Append(
" name=\"");
84 if (this.CanSerializeProtectedValue)
86 Xml.Append(
" protected=\"");
87 Xml.Append(Convert.ToBase64String(
this.ProtectedValue));
93 Xml.Append(
" protection=\"");
94 Xml.Append(this.Protection.ToString());
98 if (this.
Value.HasValue &&
this.CanSerializeValue)
100 Xml.Append(
" value=\"");
105 if (UsingTemplate || this.Descriptions is
null || this.Descriptions.Length == 0)
112 Description.
Serialize(Xml,
"description",
null);
114 Xml.Append(
"</numericalParameter>");
136 if (
Value is
double d)
138 else if (
Value is
float f)
140 else if (
Value is decimal dec)
142 else if (
Value is
int i)
144 else if (
Value is
long l)
146 else if (
Value is
short s)
148 else if (
Value is sbyte sb)
150 else if (
Value is uint ui)
152 else if (
Value is ulong ul)
154 else if (
Value is ushort us)
156 else if (
Value is
byte ub)
161 throw new ArgumentException(
"Invalid parameter type.", nameof(
Value));
173 if (Inclusive.HasValue)
174 this.MinIncluded = Inclusive.Value;
186 if (Inclusive.HasValue)
187 this.MaxIncluded = Inclusive.Value;
195 public override Task<bool>
Import(XmlElement Xml)
197 this.Value = Xml.HasAttribute(
"value") ?
XML.
Attribute(Xml,
"value", 0.0m) : (decimal?)
null;
198 this.Min = Xml.HasAttribute(
"min") ?
XML.
Attribute(Xml,
"min", 0.0m) : (decimal?)
null;
199 this.MinIncluded =
XML.
Attribute(Xml,
"minIncluded",
true);
200 this.Max = Xml.HasAttribute(
"max") ?
XML.
Attribute(Xml,
"max", 0.0m) : (decimal?)
null;
201 this.MaxIncluded =
XML.
Attribute(Xml,
"maxIncluded",
true);
203 return base.Import(Xml);
Helps with parsing of commong data types.
static string Encode(bool x)
Encodes a Boolean for use in XML and other formats.
static bool TryParse(string s, out double Value)
Tries to decode a string encoded double.
Helps with common XML-related tasks.
static string Attribute(XmlElement E, string Name)
Gets the value of an XML attribute.
static string Encode(string s)
Encodes a string for use in XML.
Class representing human-readable text.
override void Serialize(StringBuilder Xml)
Serializes the element in normalized form.
Numerical contractual parameter
override void SetValue(object Value)
Sets the parameter value.
override Task< bool > Import(XmlElement Xml)
Imports parameter values from its XML definition.
override string ParameterType
Parameter type name, corresponding to the local name of the parameter element in XML.
override void SetMinValue(object Value, bool? Inclusive)
Sets the minimum value allowed by the parameter.
override string StringValue
String representation of value.
override void SetMaxValue(object Value, bool? Inclusive)
Sets the maximum value allowed by the parameter.
override void Serialize(StringBuilder Xml, bool UsingTemplate)
Serializes the parameter, in normalized form.
static decimal ToDecimal(object Value)
Converts an object value to a System.Decimal value.
Numerical contractual parameter
T? Min
Optional minimum value.
T? Max
Optional maximum value.
ProtectionLevel
Parameter protection levels