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