Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
UInt8Literal.cs
1using System;
4
6{
11 {
15 public UInt8Literal()
16 : base()
17 {
18 }
19
24 public UInt8Literal(byte Value)
25 : base(Value, Value.ToString())
26 {
27 }
28
34 public UInt8Literal(byte Value, string StringValue)
35 : base(Value, StringValue)
36 {
37 }
38
42 public const string TypeUri = XmlSchema.Namespace + "unsignedByte";
43
47 public override string StringType => TypeUri;
48
54 public override Grade Supports(Type ValueType)
55 {
56 return ValueType == typeof(byte) ? Grade.Ok : Grade.NotAtAll;
57 }
58
64 public override ISemanticLiteral Encapsulate(object Value)
65 {
66 if (Value is byte Typed)
67 return new UInt8Literal(Typed);
68 else
69 return new StringLiteral(Value?.ToString() ?? string.Empty);
70 }
71
75 public override double ComparableValue => (byte)this.Value;
76
84 public override ISemanticLiteral Parse(string Value, string DataType, string Language)
85 {
86 if (byte.TryParse(Value, out byte i))
87 return new UInt8Literal(i, Value);
88 else
89 return new CustomLiteral(Value, DataType, Language);
90 }
91
93 public override bool Equals(object obj)
94 {
95 return obj is UInt8Literal Typed &&
96 Typed.StringValue == this.StringValue;
97 }
98
100 public override int GetHashCode()
101 {
102 return this.StringValue.GetHashCode();
103 }
104 }
105}
Represents a 8-bit unsigned integer literal.
Definition: UInt8Literal.cs:11
UInt8Literal(byte Value, string StringValue)
Represents a 8-bit unsigned integer literal.
Definition: UInt8Literal.cs:34
override ISemanticLiteral Parse(string Value, string DataType, string Language)
Tries to parse a string value of the type supported by the class..
Definition: UInt8Literal.cs:84
override ISemanticLiteral Encapsulate(object Value)
Encapsulates an object value as a semantic literal value.
Definition: UInt8Literal.cs:64
override double ComparableValue
Comparable numeric value.
Definition: UInt8Literal.cs:75
override Grade Supports(Type ValueType)
How well the type supports a given value type.
Definition: UInt8Literal.cs:54
UInt8Literal()
Represents a 8-bit unsigned integer literal.
Definition: UInt8Literal.cs:15
const string TypeUri
http://www.w3.org/2001/XMLSchema#unsignedByte
Definition: UInt8Literal.cs:42
UInt8Literal(byte Value)
Represents a 8-bit unsigned integer literal.
Definition: UInt8Literal.cs:24
string StringValue
String representation of value.
Abstract base class for semantic literal numeric values.
Interface for semantic literals.
Grade
Grade enumeration
Definition: Grade.cs:7