Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
TimeParameterInfo.cs
2using System;
3using System.Windows.Controls;
5
7{
12 {
13 private readonly Property<TimeSpan?> min;
14 private readonly Property<TimeSpan?> max;
15
16 private TimeParameter timeParameter;
17
33 {
34 this.timeParameter = Parameter;
35
36 this.min = new Property<TimeSpan?>(nameof(this.Min), Parameter.Min, this);
37 this.max = new Property<TimeSpan?>(nameof(this.Max), Parameter.Max, this);
38
39 this.MinIncluded = Parameter.MinIncluded;
40 this.MaxIncluded = Parameter.MaxIncluded;
41 }
42
46 public TimeSpan? Min
47 {
48 get => this.min.Value;
49 set
50 {
51 this.timeParameter.Min = value;
52 this.min.Value = value;
53 this.Revalidate();
54 }
55 }
56
60 public TimeSpan? Max
61 {
62 get => this.max.Value;
63 set
64 {
65 this.timeParameter.Max = value;
66 this.max.Value = value;
67 this.Revalidate();
68 }
69 }
70
72 public override bool MinIncluded
73 {
74 get => base.MinIncluded;
75 set
76 {
77 this.timeParameter.MinIncluded = value;
78 base.MinIncluded = value;
79 }
80 }
81
83 public override bool MaxIncluded
84 {
85 get => base.MaxIncluded;
86 set
87 {
88 this.timeParameter.MaxIncluded = value;
89 base.MaxIncluded = value;
90 }
91 }
92
94 public override void SetMax(string Value)
95 {
96 this.Max = Parse(Value);
97 }
98
100 public override void SetMin(string Value)
101 {
102 this.Min = Parse(Value);
103 }
104
106 public override void SetValue(string Value)
107 {
108 this.Value = Parse(Value);
109 }
110
111 private static TimeSpan? Parse(string Value)
112 {
113 if (string.IsNullOrEmpty(Value))
114 return null;
115 else if (TimeSpan.TryParse(Value, out TimeSpan TS))
116 return TS;
117 else
118 throw new ArgumentException("Invalid time value.", nameof(Value));
119 }
120
122 public override void ContractUpdated(Contract Contract)
123 {
124 base.ContractUpdated(Contract);
125 this.timeParameter = this.Parameter as TimeParameter;
126 }
127 }
128}
Contains the definition of a contract
Definition: Contract.cs:22
Abstract base class for contractual parameters
Definition: Parameter.cs:17