Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
ScriptPasswordParameterNode.cs
1using System.Threading.Tasks;
11using Waher.Script;
13
15{
20 {
25 : base()
26 {
27 }
28
32 [Page(2, "Script", 100)]
33 [Header(29, "Default value:")]
34 [ToolTip(30, "Default value presented to user.")]
35 [Masked]
36 [Encrypted(32)]
37 public string DefaultValue { get; set; }
38
42 public string[] EncryptedProperties => new string[] { nameof(this.DefaultValue) };
43
49 public override Task<string> GetTypeNameAsync(Language Language)
50 {
51 return Language.GetStringAsync(typeof(ScriptNode), 58, "Password-valued parameter");
52 }
53
60 public override Task PopulateForm(DataForm Parameters, Language Language, object Value)
61 {
63 new string[] { this.DefaultValue }, null, this.Description, StringDataType.Instance,
64 new BasicValidation(), string.Empty, false, false, false);
65
66 Parameters.Add(Field);
67
68 Page Page = Parameters.GetPage(this.Page);
69 Page.Add(Field);
70
71 return Task.CompletedTask;
72 }
73
83 public override async Task SetParameter(DataForm Parameters, Language Language, bool OnlySetChanged, Variables Values,
85 {
87 if (Field is null)
88 {
89 if (this.Required)
90 Result.AddError(this.ParameterName, await Language.GetStringAsync(typeof(ScriptNode), 42, "Required parameter."));
91
92 Values[this.ParameterName] = null;
93 }
94 else
95 {
96 string s = Field.ValueString;
97
98 if (string.IsNullOrEmpty(s))
99 {
100 if (this.Required)
101 Result.AddError(this.ParameterName, await Language.GetStringAsync(typeof(ScriptNode), 42, "Required parameter."));
102
103 Values[this.ParameterName] = null;
104 }
105 else
106 Values[this.ParameterName] = s;
107 }
108 }
109
110 }
111}
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
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
override async Task SetParameter(DataForm Parameters, Language Language, bool OnlySetChanged, Variables Values, SetEditableFormResult Result)
Sets the parameters of the object, based on contents in the data form.
ScriptPasswordParameterNode()
Represents a password-valued script parameter.
string[] EncryptedProperties
Array of properties that are encrypted.
override Task< string > GetTypeNameAsync(Language Language)
Gets the type name of the node.
override Task PopulateForm(DataForm Parameters, Language Language, object Value)
Populates a data form with parameters for the object.
Node defined by script.
Definition: ScriptNode.cs:19
Represents a parameter on a command.
bool Required
If parameter is required.
string Description
Parameter description.
Interface for objects containing encrypted properties. Mark the properties that are encrypted with th...