3using System.Threading.Tasks;
21 private decimal? value;
22 private decimal? min =
null;
23 private decimal? max =
null;
24 private bool minIncluded =
true;
25 private bool maxIncluded =
true;
36 this.ProtectedValue =
null;
47 set => this.min = value;
57 set => this.max = value;
66 get => this.minIncluded;
67 set => this.minIncluded = value;
76 get => this.maxIncluded;
77 set => this.maxIncluded = value;
105 this.@value =
default;
116 return Task.CompletedTask;
125 Xml.Append(
"<numericalParameter");
129 Xml.Append(
" exp=\"");
130 Xml.Append(
XML.
Encode(
this.Expression.Normalize(NormalizationForm.FormC)));
134 if (!
string.IsNullOrEmpty(this.
Guide))
136 Xml.Append(
" guide=\"");
137 Xml.Append(
XML.
Encode(
this.Guide.Normalize(NormalizationForm.FormC)));
141 if (this.max.HasValue)
143 Xml.Append(
" max=\"");
145 Xml.Append(
"\" maxIncluded=\"");
150 if (this.min.HasValue)
152 Xml.Append(
" min=\"");
154 Xml.Append(
"\" minIncluded=\"");
159 Xml.Append(
" name=\"");
160 Xml.Append(
XML.
Encode(
this.Name.Value.Normalize(NormalizationForm.FormC)));
165 Xml.Append(
" protected=\"");
166 Xml.Append(Convert.ToBase64String(
this.ProtectedValue));
172 Xml.Append(
" protection=\"");
177 if (this.@value.HasValue &&
this.CanSerializeValue)
179 Xml.Append(
" value=\"");
191 Description.
Serialize(Xml,
"description",
null);
193 Xml.Append(
"</numericalParameter>");
209 if (!this.@value.HasValue)
210 return Task.FromResult(
"Value missing.");
212 if (this.min.HasValue)
214 Diff = this.@value.Value - this.min.Value;
216 if (Diff < 0 || (Diff == 0 && !this.minIncluded))
217 return Task.FromResult(
"Value below minimum permitted.");
220 if (this.max.HasValue)
222 Diff = this.@value.Value - this.max.Value;
224 if (Diff > 0 || (Diff == 0 && !this.maxIncluded))
225 return Task.FromResult(
"Value above maximum permitted.");
249 this.min != UpdatedNumericalParameter.min ||
250 this.max != UpdatedNumericalParameter.max ||
251 this.minIncluded != UpdatedNumericalParameter.minIncluded ||
252 this.maxIncluded != UpdatedNumericalParameter.maxIncluded ||
253 base.UpdateRequiresReview(UpdatedParameter);
263 if (!(NewValue is decimal D))
265 if (NewValue is
double Dbl)
267 else if (NewValue is
float F)
269 else if (NewValue is sbyte i8)
271 else if (NewValue is
short i16)
273 else if (NewValue is
int i32)
275 else if (NewValue is
long i64)
277 else if (NewValue is
byte ui8)
279 else if (NewValue is ushort ui16)
281 else if (NewValue is uint ui32)
283 else if (NewValue is ulong ui64)
291 if (this.min.HasValue && (D <
this.min.Value || D ==
this.min.Value && !
this.minIncluded))
294 if (this.max.HasValue && (D >
this.max.Value || D ==
this.max.Value && !
this.maxIncluded))
317 public override Task<bool>
Import(XmlElement Xml)
319 this.Value = Xml.HasAttribute(
"value") ?
XML.
Attribute(Xml,
"value", 0.0m) : (decimal?)
null;
320 this.Min = Xml.HasAttribute(
"min") ?
XML.
Attribute(Xml,
"min", 0.0m) : (decimal?)
null;
321 this.MinIncluded =
XML.
Attribute(Xml,
"minIncluded",
true);
322 this.Max = Xml.HasAttribute(
"max") ?
XML.
Attribute(Xml,
"max", 0.0m) : (decimal?)
null;
323 this.MaxIncluded =
XML.
Attribute(Xml,
"maxIncluded",
true);
325 return base.Import(Xml);
343 this.min = Typed.min;
344 this.max = Typed.max;
345 this.minIncluded = Typed.minIncluded;
346 this.maxIncluded = Typed.maxIncluded;
348 return base.CopyValidationRules(From);
359 base.ClearValidationRules();
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.
Contains a markdown document. This markdown document class supports original markdown,...
static string Encode(string s)
Encodes all special characters in a string so that it can be included in a markdown document without ...
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 that keeps track of events and timing.
Class that keeps track of events and timing for one thread.
Class managing a script expression.
State of the Markdown output generator.
Numerical contractual parameter
override void ClearValidationRules()
Clears validation rules form the parameter.
override bool CopyValidationRules(Parameter From)
Copies validation rules from another parameter.
override void Populate(Variables Variables, ProfilerThread Profiler)
Populates a variable collection with the value of the parameter.
override Task< string > IsParameterValid(Variables Variables, LegalComponent Legal, ProfilerThread Profiler)
Checks if the parameter value is valid.
decimal? Max
Optional maximum value.
override Task< bool > Import(XmlElement Xml)
Imports parameter values from its XML definition.
override TextAlignment CellAlignment
Alignment of the cell in a table, if the parameter is to be displayed in a table.
bool MaxIncluded
If the optional maximum value is included in the allowed range.
bool MinIncluded
If the optional minimum value is included in the allowed range.
decimal? Value
Parameter value
decimal? Min
Optional minimum value.
override bool UpdateRequiresReview(Parameter UpdatedParameter)
Checks if an updated parameter requires review.
override Parameter TryCreateNew(object NewValue)
Clones the parameter with a new value.
override Task ToMarkdown(MarkdownOutput Markdown, MarkdownOutputState State)
Exports the value to Markdown.
override string StringValue
String representation of value.
override void Serialize(StringBuilder Xml)
Serializes the parameter, in normalized form.
override void ClearValue()
Clears the value, without resetting the protected value.
override object ObjectValue
Parameter value.
Abstract base class for contractual parameters
bool CanSerializeProtectedValue
If the protected value van be serialized.
CaseInsensitiveString Name
Parameter name
string Expression
Parameter validation script expression.
HumanReadableText[] Descriptions
Discriptions of the role, in different languages.
string Guide
Parameter guide text
ProtectionLevel Protection
Level of confidentiality of the information provided by the parameter.
Class representing human-readable text.
override void Serialize(StringBuilder Xml)
Serializes the element in normalized form.
void Append(string s)
Appends text to the Markdown output.
Legal (digital identities, smart contracts) service component.
TextAlignment
Text alignment of contents.
ProtectionLevel
Parameter protection levels