Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
BooleanAttribute.cs
1using System.Xml;
2using Waher.Content;
3using Waher.Script;
4
6{
10 public class BooleanAttribute : Attribute<bool>
11 {
18 public BooleanAttribute(string AttributeName, bool Value, Layout2DDocument Document)
19 : base(AttributeName, Value, Document)
20 {
21 }
22
29 public BooleanAttribute(XmlElement E, string AttributeName, Layout2DDocument Document)
30 : base(E, AttributeName, true, Document)
31 {
32 }
33
40 public BooleanAttribute(string AttributeName, Expression Expression, Layout2DDocument Document)
41 : base(AttributeName, Expression, Document)
42 {
43 }
44
51 public override bool TryParse(string StringValue, out bool Value)
52 {
53 return CommonTypes.TryParse(StringValue, out Value);
54 }
55
61 public override string ToString(bool Value)
62 {
63 return CommonTypes.Encode(Value);
64 }
65
73 {
74 if (this.HasPresetValue)
75 return this;
76 else
77 return new BooleanAttribute(this.Name, this.Expression, ForDocument);
78 }
79
80 }
81}
Helps with parsing of commong data types.
Definition: CommonTypes.cs:13
static string Encode(bool x)
Encodes a Boolean for use in XML and other formats.
Definition: CommonTypes.cs:594
static bool TryParse(string s, out double Value)
Tries to decode a string encoded double.
Definition: CommonTypes.cs:46
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
BooleanAttribute(XmlElement E, string AttributeName, Layout2DDocument Document)
Boolean attribute
override bool TryParse(string StringValue, out bool Value)
Tries to parse a string value
BooleanAttribute CopyIfNotPreset(Layout2DDocument ForDocument)
Copies the attribute object if undefined, or defined by an expression. Returns a reference to itself,...
BooleanAttribute(string AttributeName, Expression Expression, Layout2DDocument Document)
Boolean attribute
BooleanAttribute(string AttributeName, bool Value, Layout2DDocument Document)
Boolean attribute
override string ToString(bool Value)
Converts a value to a string.
Class managing a script expression.
Definition: Expression.cs:39