Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
DurationParameterInfo.cs
2using System;
3using System.Windows.Controls;
4using Waher.Content;
6
8{
13 {
14 private readonly Property<Duration?> min;
15 private readonly Property<Duration?> max;
16
17 private DurationParameter durationParameter;
18
34 {
35 this.durationParameter = Parameter;
36
37 this.min = new Property<Duration?>(nameof(this.Min), Parameter.Min, this);
38 this.max = new Property<Duration?>(nameof(this.Max), Parameter.Max, this);
39
40 this.MinIncluded = Parameter.MinIncluded;
41 this.MaxIncluded = Parameter.MaxIncluded;
42 }
43
47 public Duration? Min
48 {
49 get => this.min.Value;
50 set
51 {
52 this.durationParameter.Min = value;
53 this.min.Value = value;
54 this.Revalidate();
55 }
56 }
57
61 public Duration? Max
62 {
63 get => this.max.Value;
64 set
65 {
66 this.durationParameter.Max = value;
67 this.max.Value = value;
68 this.Revalidate();
69 }
70 }
71
73 public override bool MinIncluded
74 {
75 get => base.MinIncluded;
76 set
77 {
78 this.durationParameter.MinIncluded = value;
79 base.MinIncluded = value;
80 }
81 }
82
84 public override bool MaxIncluded
85 {
86 get => base.MaxIncluded;
87 set
88 {
89 this.durationParameter.MaxIncluded = value;
90 base.MaxIncluded = value;
91 }
92 }
93
95 public override void SetMax(string Value)
96 {
97 this.Max = Parse(Value);
98 }
99
101 public override void SetMin(string Value)
102 {
103 this.Min = Parse(Value);
104 }
105
107 public override void SetValue(string Value)
108 {
109 this.Value = Parse(Value);
110 }
111
112 private static Duration? Parse(string Value)
113 {
114 if (string.IsNullOrEmpty(Value))
115 return null;
116 else if (Duration.TryParse(Value, out Duration Dr))
117 return Dr;
118 else
119 throw new ArgumentException("Invalid duration value.", nameof(Value));
120 }
121
123 public override void ContractUpdated(Contract Contract)
124 {
125 base.ContractUpdated(Contract);
126 this.durationParameter = this.Parameter as DurationParameter;
127 }
128 }
129}
Contains the definition of a contract
Definition: Contract.cs:22
Abstract base class for contractual parameters
Definition: Parameter.cs:17
Represents a duration value, as defined by the xsd:duration data type: http://www....
Definition: Duration.cs:13
static bool TryParse(string s, out Duration Result)
Tries to parse a duration value.
Definition: Duration.cs:85