Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
ContractReferenceParameterInfo.cs
3using System;
4using System.Threading.Tasks;
5using System.Windows.Controls;
9
11{
16 {
17 private readonly Property<object> label;
18 private readonly Property<string> labelAsMarkdown;
19 private readonly Property<string> contractId;
20 private readonly Property<string> localName;
21 private readonly Property<string> @namespace;
22 private readonly Property<string> templateId;
23 private readonly Property<string> provider;
24 private readonly Property<string> creatorRole;
25 private readonly Property<bool> required;
26
36 : base(Contract, Parameter, Control, DesignModel, Parameters)
37 {
38 string Language = DesignModel?.Language ?? Contract.DefaultLanguage;
39
40 this.label = new Property<object>(nameof(this.Label), Parameter.ToSimpleXAML(Language, Contract).Result, this);
41 this.labelAsMarkdown = new Property<string>(nameof(this.LabelAsMarkdown), Parameter.ToMarkdown(Language, Contract, MarkdownType.ForEditing).Result.Trim(), this);
42 this.contractId = new Property<string>(nameof(this.Value), Parameter.Value?.Value, this);
43 this.localName = new Property<string>(nameof(this.LocalName), Parameter.LocalName, this);
44 this.@namespace = new Property<string>(nameof(this.Namespace), Parameter.Namespace, this);
45 this.templateId = new Property<string>(nameof(this.TemplateId), Parameter.TemplateId, this);
46 this.provider = new Property<string>(nameof(this.Provider), Parameter.Provider, this);
47 this.creatorRole = new Property<string>(nameof(this.CreatorRole), Parameter.CreatorRole, this);
48 this.required = new Property<bool>(nameof(this.Required), Parameter.Required, this);
49 }
50
54 public object Label
55 {
56 get => this.label.Value;
57 set => this.label.Value = value;
58 }
59
63 public string LabelAsMarkdown
64 {
65 get => this.labelAsMarkdown.Value;
66 set
67 {
68 string Language = this.designModel?.Language ?? this.Contract.DefaultLanguage;
69 Waher.Networking.XMPP.Contracts.HumanReadable.Label Label = value.ToHumanReadableLabel(Language).Result;
71
72 if (Label is null)
73 ContractReferenceParameter.Labels = ContractReferenceParameter.Labels.Remove(Language);
74 else
75 ContractReferenceParameter.Labels = ContractReferenceParameter.Labels.Append(Label);
76
77 this.labelAsMarkdown.Value = value;
78 this.label.Value = value.ToSimpleXAML(this.Contract, Language).Result;
79 }
80 }
81
85 public string ContractId
86 {
87 get => this.contractId.Value;
88 set
89 {
90 if (string.IsNullOrEmpty(value))
91 this.contractId.Value = string.Empty;
92 else if (!XmppClient.BareJidRegEx.IsMatch(value))
93 throw new Exception("Invalid contract reference.");
94 else
95 {
96 this.Parameter.SetValue(value);
97 this.contractId.Value = value;
98 }
99 }
100 }
101
105 public string LocalName
106 {
107 get => this.localName.Value;
108 set => this.localName.Value = value;
109 }
110
114 public string Namespace
115 {
116 get => this.@namespace.Value;
117 set => this.@namespace.Value = value;
118 }
119
123 public string TemplateId
124 {
125 get => this.templateId.Value;
126 set => this.templateId.Value = value;
127 }
128
132 public string Provider
133 {
134 get => this.provider.Value;
135 set => this.provider.Value = value;
136 }
137
141 public string CreatorRole
142 {
143 get => this.creatorRole.Value;
144 set => this.creatorRole.Value = value;
145 }
146
150 public bool Required
151 {
152 get => this.required.Value;
153 set => this.required.Value = value;
154 }
155
157 public override void SetValue(string Value)
158 {
159 this.ContractId = Value;
160 }
161
165 public override Task ExecuteRemoveParameter()
166 {
167 this.designModel?.RemoveContractReferenceParameter(this);
168 return Task.CompletedTask;
169 }
170 }
171}
Contains the definition of a contract
Definition: Contract.cs:22
string DefaultLanguage
Default language for contract.
Definition: Contract.cs:1884
override void SetValue(object Value)
Sets the parameter value.
CaseInsensitiveString Value
The value of the parameter, containing the ID of the contract that is being referenced.
Label[] Labels
Human-readable label to be shown in stead of a reference, in contract text, in different languages.
string LocalName
Restriction on the local name of the machine-readable part of the referenced contract.
Task< string > ToMarkdown(string Language, Contract Contract)
Creates a human-readable Markdown document for the contract.
Abstract base class for contractual parameters
Definition: Parameter.cs:17
Manages an XMPP client connection. Implements XMPP, as defined in https://tools.ietf....
Definition: XmppClient.cs:59
static readonly Regex BareJidRegEx
Regular expression for Bare JIDs
Definition: XmppClient.cs:188