Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
ReportEnumAttribute.cs
1using System;
2using System.Text;
3using System.Xml;
4
6{
11 where T : Enum
12 {
18 public ReportEnumAttribute(XmlElement Xml, string AttributeName)
19 : base(Xml, AttributeName)
20 {
21 }
22
28 public override T ParseValue(string s)
29 {
30 if (Enum.TryParse(typeof(T), s, true, out object Result) && Result is T TypedResult)
31 return TypedResult;
32 else
33 {
34 StringBuilder sb = new StringBuilder();
35
36 sb.Append("Expected a value of type ");
37 sb.Append(typeof(T).FullName);
38 sb.Append(". Invalid enumerated value: ");
39 sb.Append(s);
40
41 throw new ArgumentException(sb.ToString(), nameof(s));
42 }
43 }
44 }
45}
Abstract base class for report attributes.
ReportEnumAttribute(XmlElement Xml, string AttributeName)
Report enumerated attribute.
override T ParseValue(string s)
Parses a string representation of a value.