Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
NumericalParameterInfo.cs
2using System;
3using System.Windows.Controls;
4using Waher.Content;
6
8{
13 {
14 private readonly Property<decimal?> min;
15 private readonly Property<decimal?> max;
16
17 private NumericalParameter numericalParameter;
18
34 {
35 this.numericalParameter = Parameter;
36
37 this.min = new Property<decimal?>(nameof(this.Min), Parameter.Min, this);
38 this.max = new Property<decimal?>(nameof(this.Max), Parameter.Max, this);
39
40 this.MinIncluded = Parameter.MinIncluded;
41 this.MaxIncluded = Parameter.MaxIncluded;
42 }
43
47 public decimal? Min
48 {
49 get => this.min.Value;
50 set
51 {
52 this.numericalParameter.Min = value;
53 this.min.Value = value;
54 this.Revalidate();
55 }
56 }
57
61 public decimal? Max
62 {
63 get => this.max.Value;
64 set
65 {
66 this.numericalParameter.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.numericalParameter.MinIncluded = value;
79 base.MinIncluded = value;
80 }
81 }
82
84 public override bool MaxIncluded
85 {
86 get => base.MaxIncluded;
87 set
88 {
89 this.numericalParameter.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 decimal? Parse(string Value)
113 {
114 if (string.IsNullOrEmpty(Value))
115 return null;
116 else if (CommonTypes.TryParse(Value, out decimal d))
117 return d;
118 else
119 throw new ArgumentException("Invalid numerical value.", nameof(Value));
120 }
121
123 public override void ContractUpdated(Contract Contract)
124 {
125 base.ContractUpdated(Contract);
126 this.numericalParameter = this.Parameter as NumericalParameter;
127 }
128 }
129}
Helps with parsing of commong data types.
Definition: CommonTypes.cs:13
static bool TryParse(string s, out double Value)
Tries to decode a string encoded double.
Definition: CommonTypes.cs:46
Contains the definition of a contract
Definition: Contract.cs:22
Abstract base class for contractual parameters
Definition: Parameter.cs:17