Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
ControlParameter.cs
1using System.Threading.Tasks;
2using System.Xml;
3
5{
9 public abstract class ControlParameter
10 {
11 private readonly string name;
12 private readonly string page;
13 private readonly string label;
14 private readonly string description;
15
23 public ControlParameter(string Name, string Page, string Label, string Description)
24 {
25 this.name = Name;
26 this.page = Page;
27 this.label = Label;
28 this.description = Description;
29 }
30
34 public string Name => this.name;
35
39 public string Page => this.page;
40
44 public string Label => this.label;
45
49 public string Description => this.description;
50
57 public abstract Task<bool> SetStringValue(IThingReference Node, string StringValue);
58
64 public abstract Task<string> GetStringValue(IThingReference Node);
65
67 public override bool Equals(object obj)
68 {
69 return
70 this.GetType() == obj.GetType() &&
71 this.name == ((ControlParameter)obj).name;
72 }
73
75 public override int GetHashCode()
76 {
77 return this.name.GetHashCode();
78 }
79
85 public virtual async Task ExportToForm(XmlWriter Output, IThingReference Node)
86 {
87 string StringValue = await this.GetStringValue(Node);
88
89 Output.WriteStartElement("field");
90 Output.WriteAttributeString("var", this.name);
91 Output.WriteAttributeString("type", this.FormFieldType);
92 Output.WriteAttributeString("label", this.label);
93
94 Output.WriteElementString("desc", this.description);
95 Output.WriteElementString("value", StringValue ?? string.Empty);
96
97 await this.ExportValidationRules(Output, Node);
98
99 Output.WriteElementString("xdd", "notSame", null, string.Empty);
100 Output.WriteEndElement();
101 }
102
106 public virtual string FormFieldType
107 {
108 get { return "text-single"; }
109 }
110
116 public abstract Task ExportValidationRules(XmlWriter Output, IThingReference Node);
117
118 }
119}
Abstract base class for control parameters.
virtual async Task ExportToForm(XmlWriter Output, IThingReference Node)
Exports the field to a data form.
abstract Task< bool > SetStringValue(IThingReference Node, string StringValue)
Sets the value of the control parameter.
string Description
Description for parameter.
string Page
On which page in the control dialog the parameter should appear.
abstract Task ExportValidationRules(XmlWriter Output, IThingReference Node)
Exports form validation rules for the parameter.
abstract Task< string > GetStringValue(IThingReference Node)
Gets the string value of the control parameter.
virtual string FormFieldType
Data form field type.
ControlParameter(string Name, string Page, string Label, string Description)
Abstract base class for control parameters.
Interface for thing references.