Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
RoleReferenceParameterInfo.cs
2using System;
3using System.Threading.Tasks;
4using System.Windows.Controls;
6
8{
13 {
14 private readonly Property<string> role;
15 private readonly Property<string> property;
16 private readonly Property<int> index;
17 private readonly Property<bool> required;
18
28 : base(Contract, Parameter, Control, DesignModel, Parameters)
29 {
30 this.role = new Property<string>(nameof(this.Role), Parameter.Role, this);
31 this.property = new Property<string>(nameof(this.Property), Parameter.Property, this);
32 this.index = new Property<int>(nameof(this.Index), Parameter.Index, this);
33 this.required = new Property<bool>(nameof(this.Required), Parameter.Required, this);
34
35 if (this.designModel is not null)
36 this.designModel.PropertyChanged += this.DesignModel_PropertyChanged;
37 }
38
42 public string Role
43 {
44 get => this.role.Value;
45 set => this.role.Value = value;
46 }
47
51 public int Index
52 {
53 get => this.index.Value;
54 set
55 {
56 if (value <= 0)
57 throw new ArgumentOutOfRangeException(nameof(this.Index), "Role index must be positive.");
58
59 this.index.Value = value;
60 }
61 }
62
66 public string Property
67 {
68 get => this.property.Value;
69 set
70 {
71 if (string.IsNullOrEmpty(value))
72 throw new ArgumentOutOfRangeException(nameof(this.Property), "The property reference cannot be empty.");
73
74 this.property.Value = value;
75 }
76 }
77
81 public bool Required
82 {
83 get => this.required.Value;
84 set => this.required.Value = value;
85 }
86
90 public string[] Roles => this.designModel.RoleNames;
91
92 private void DesignModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
93 {
94 if (e.PropertyName == nameof(this.Roles))
95 this.RaisePropertyChanged(nameof(this.Roles));
96 }
97
99 public override void SetValue(string Value)
100 {
101 throw new Exception("Role reference parameter cannot be set.");
102 }
103
107 public override Task ExecuteRemoveParameter()
108 {
109 this.designModel?.RemoveRoleReferenceParameter(this);
110 return Task.CompletedTask;
111 }
112 }
113}
Contains the definition of a contract
Definition: Contract.cs:22
Abstract base class for contractual parameters
Definition: Parameter.cs:17
Class defining a role
Definition: Role.cs:7
Role-reference contractual parameter
int Index
1-based Role index. 1=First signatory having the rolw, 2=second, etc.
bool Required
If parameter is required to exist for contract to be valid.