Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
DayTimeDurationLiteral.cs
1using System;
4
6{
11 {
16 : base()
17 {
18 }
19
25 : base(Value, Value.ToString())
26 {
27 }
28
35 : base(Value, StringValue)
36 {
37 }
38
42 public const string TypeUri = XmlSchema.Namespace + "dayTimeDuration";
43
47 public override string StringType => TypeUri;
48
54 public override Grade Supports(Type ValueType)
55 {
56 return ValueType == typeof(Duration) ? Grade.Barely : Grade.NotAtAll;
57 }
58
66 public override ISemanticLiteral Parse(string Value, string DataType, string Language)
67 {
68 if (Duration.TryParse(Value, out Duration d))
69 return new DayTimeDurationLiteral(d, Value);
70 else
71 return new CustomLiteral(Value, DataType, Language);
72 }
73
79 public override ISemanticLiteral Encapsulate(object Value)
80 {
81 if (Value is Duration Typed)
82 return new DayTimeDurationLiteral(Typed);
83 else
84 return new StringLiteral(Value?.ToString() ?? string.Empty);
85 }
86
88 public override bool Equals(object obj)
89 {
90 return obj is DayTimeDurationLiteral Typed &&
91 Typed.StringValue == this.StringValue;
92 }
93
95 public override int GetHashCode()
96 {
97 return this.StringValue.GetHashCode();
98 }
99 }
100}
DayTimeDurationLiteral(Duration Value)
Represents a DayTimeDuration literal.
override ISemanticLiteral Encapsulate(object Value)
Encapsulates an object value as a semantic literal value.
override ISemanticLiteral Parse(string Value, string DataType, string Language)
Tries to parse a string value of the type supported by the class..
const string TypeUri
http://www.w3.org/2001/XMLSchema#dayTimeDuration
DayTimeDurationLiteral(Duration Value, string StringValue)
Represents a DayTimeDuration literal.
override Grade Supports(Type ValueType)
How well the type supports a given value type.
Abstract base class for semantic literal values.
string StringValue
String representation of value.
Interface for semantic literals.
Grade
Grade enumeration
Definition: Grade.cs:7
Represents a duration value, as defined by the xsd:duration data type: http://www....
Definition: Duration.cs:13
static bool TryParse(string s, out Duration Result)
Tries to parse a duration value.
Definition: Duration.cs:85