Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
EnumAttribute.cs
1using System;
2using System.Xml;
3using Waher.Script;
4
6{
10 public class EnumAttribute<TEnum> : Attribute<TEnum>
11 where TEnum : struct
12 {
19 public EnumAttribute(string AttributeName, TEnum Value, Layout2DDocument Document)
20 : base(AttributeName, Value, Document)
21 {
22 }
23
30 public EnumAttribute(XmlElement E, string AttributeName, Layout2DDocument Document)
31 : base(E, AttributeName, true, Document)
32 {
33 }
34
41 public EnumAttribute(string AttributeName, Expression Expression, Layout2DDocument Document)
42 : base(AttributeName, Expression, Document)
43 {
44 }
45
52 public override bool TryParse(string StringValue, out TEnum Value)
53 {
54 return Enum.TryParse(StringValue, out Value);
55 }
56
62 public override string ToString(TEnum Value)
63 {
64 return Value.ToString();
65 }
66
74 {
75 if (this.HasPresetValue)
76 return this;
77 else
78 return new EnumAttribute<TEnum>(this.Name, this.Expression, ForDocument);
79 }
80
81 }
82}
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
EnumAttribute(string AttributeName, TEnum Value, Layout2DDocument Document)
Enumeration attribute
override bool TryParse(string StringValue, out TEnum Value)
Tries to parse a string value
EnumAttribute(string AttributeName, Expression Expression, Layout2DDocument Document)
Enumeration attribute
EnumAttribute(XmlElement E, string AttributeName, Layout2DDocument Document)
Enumeration attribute
override string ToString(TEnum Value)
Converts a value to a string.
EnumAttribute< TEnum > CopyIfNotPreset(Layout2DDocument ForDocument)
Copies the attribute object if undefined, or defined by an expression. Returns a reference to itself,...
Class managing a script expression.
Definition: Expression.cs:39