Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
PasswordParameter.cs
1using System;
2using System.Threading.Tasks;
3using System.Xml;
12using Waher.Script;
13
15{
20 {
21 private readonly ReportStringAttribute defaultValue;
22
27 public PasswordParameter(XmlElement Xml)
28 : base(Xml)
29 {
30 this.defaultValue = new ReportStringAttribute(Xml, "default");
31 }
32
40 {
41 ReportParameterAttributes Attributes = await this.GetReportParameterAttributes(Variables);
42 string Default = this.defaultValue.IsEmpty ? null : await this.defaultValue.Evaluate(Variables);
43 string[] DefaultValue;
44
45 if (!(Default is null))
46 DefaultValue = new string[] { Default };
47 else
48 DefaultValue = Array.Empty<string>();
49
50 TextPrivateField Field = new TextPrivateField(Parameters, Attributes.Name, Attributes.Label, Attributes.Required,
51 DefaultValue, null, Attributes.Description, StringDataType.Instance,
52 new BasicValidation(), string.Empty, false, false, false);
53
54 Parameters.Add(Field);
55
56 Page Page = Parameters.GetPage(Attributes.Page);
57 Page.Add(Field);
58 }
59
70 public override async Task SetParameter(DataForm Parameters, Language Language, bool OnlySetChanged, Variables Variables,
72 {
73 string Name = await this.GetName(Variables);
74 bool Required = await this.IsRequired(Variables);
75 Field Field = Parameters[Name];
76
77 if (Field is null)
78 {
79 if (Required)
80 Result.AddError(Name, await Language.GetStringAsync(typeof(ReportFileNode), 1, "Required parameter."));
81
82 Variables[Name] = null;
83 }
84 else
85 {
86 string s = Field.ValueString;
87
88 if (string.IsNullOrEmpty(s))
89 {
90 if (Required)
91 Result.AddError(Name, await Language.GetStringAsync(typeof(ReportFileNode), 1, "Required parameter."));
92
93 Variables[Name] = null;
94 }
95 else
96 Variables[Name] = s;
97 }
98 }
99
100 }
101}
Static class managing editable parameters in objects. Editable parameters are defined by using the at...
Definition: Parameters.cs:26
void AddError(string Key, string Value)
Adds an error to the list of errors.
Implements support for data forms. Data Forms are defined in the following XEPs:
Definition: DataForm.cs:42
static readonly StringDataType Instance
Public instance of data type.
Base class for form fields
Definition: Field.cs:17
string ValueString
Value as a single string. If field contains multiple values, they will be concatenated into a single ...
Definition: Field.cs:102
Class managing a page in a data form layout.
Definition: Page.cs:11
void Add(LayoutElement Element)
Adds a layout element.
Definition: Section.cs:135
override async Task PopulateForm(DataForm Parameters, Language Language, Variables Variables)
Populates a data form with parameters for the object.
PasswordParameter(XmlElement Xml)
Represents a password-valued parameter.
override async Task SetParameter(DataForm Parameters, Language Language, bool OnlySetChanged, Variables Variables, SetEditableFormResult Result)
Sets the parameters of the object, based on contents in the data form.
Abstract base class for report parameters.
async Task< ReportParameterAttributes > GetReportParameterAttributes(Variables Variables)
Evaluates the attributes of the report parameter.
Task< string > GetName(Variables Variables)
Name of the parameter.
Task< bool > IsRequired(Variables Variables)
If parameter is required.
Report node based on the contents of a report file.
Contains information about a language.
Definition: Language.cs:17
Task< string > GetStringAsync(Type Type, int Id, string Default)
Gets the string value of a string ID. If no such string exists, a string is created with the default ...
Definition: Language.cs:209
Collection of variables.
Definition: Variables.cs:25