Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
PositiveIntegerAttribute.cs
1using System.Xml;
2using Waher.Script;
3
5{
10 {
17 public PositiveIntegerAttribute(string AttributeName, int Value, Layout2DDocument Document)
18 : base(AttributeName, Value, Document)
19 {
20 }
21
28 public PositiveIntegerAttribute(XmlElement E, string AttributeName, Layout2DDocument Document)
29 : base(E, AttributeName, true, Document)
30 {
31 }
32
39 public PositiveIntegerAttribute(string AttributeName, Expression Expression, Layout2DDocument Document)
40 : base(AttributeName, Expression, Document)
41 {
42 }
43
50 public override bool TryConvert(object Result, out int Value)
51 {
52 if (Result is double d)
53 {
54 Value = (int)(d + 0.5);
55 return true;
56 }
57 else
58 return base.TryConvert(Result, out Value);
59 }
60
67 public override bool TryParse(string StringValue, out int Value)
68 {
69 if (int.TryParse(StringValue, out Value))
70 return Value > 0;
71 else
72 return false;
73 }
74
80 public override string ToString(int Value)
81 {
82 return Value.ToString();
83 }
84
92 {
93 if (this.HasPresetValue)
94 return this;
95 else
96 return new PositiveIntegerAttribute(this.Name, this.Expression, ForDocument);
97 }
98
99 }
100}
Contains a 2D layout document.
Manages an attribute value or expression.
Definition: Attribute.cs:14
bool HasPresetValue
If the attribute has a preset value.
Definition: Attribute.cs:129
override bool TryConvert(object Result, out int Value)
Tries to convert script result to a value of type float.
PositiveIntegerAttribute(string AttributeName, int Value, Layout2DDocument Document)
Positive integer attribute
PositiveIntegerAttribute CopyIfNotPreset(Layout2DDocument ForDocument)
Copies the attribute object if undefined, or defined by an expression. Returns a reference to itself,...
override bool TryParse(string StringValue, out int Value)
Tries to parse a string value
override string ToString(int Value)
Converts a value to a string.
PositiveIntegerAttribute(string AttributeName, Expression Expression, Layout2DDocument Document)
Positive integer attribute
PositiveIntegerAttribute(XmlElement E, string AttributeName, Layout2DDocument Document)
Positive integer attribute
Class managing a script expression.
Definition: Expression.cs:39