Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
UriNode.cs
1using System;
2using System.Text;
4
6{
10 public class UriNode : SemanticElement
11 {
12 private Uri parsed;
13 private string uri;
14 private string shortName;
15
19 public UriNode()
20 {
21 }
22
27 public UriNode(Uri Uri)
28 : this(Uri, null)
29 {
30 }
31
37 public UriNode(Uri Uri, string Short)
38 {
39 this.parsed = Uri;
40 this.uri = Uri.ToString();
41 this.shortName = Short ?? this.uri;
42 }
43
47 [IgnoreMember]
48 public Uri Uri => this.parsed;
49
53 public string ShortName
54 {
55 get => this.shortName;
56 set => this.shortName = value;
57 }
58
62 public override bool IsLiteral => false;
63
67 public bool HasShortName => !string.IsNullOrEmpty(this.shortName);
68
72 public override object AssociatedObjectValue => this.uri;
73
77 public string UriString
78 {
79 get => this.uri;
80 set
81 {
82 this.parsed = new Uri(value);
83 this.uri = value;
84 }
85 }
86
88 public override string ToString()
89 {
90 StringBuilder sb = new StringBuilder();
91
92 sb.Append('<');
93 sb.Append(this.uri);
94 sb.Append('>');
95
96 return sb.ToString();
97 }
98
100 public override bool Equals(object obj)
101 {
102 return obj is UriNode Typed &&
103 Typed.parsed.ToString() == this.parsed.ToString();
104 }
105
107 public override int GetHashCode()
108 {
109 return this.parsed.ToString().GetHashCode();
110 }
111
123 public override int CompareTo(object obj)
124 {
125 if (obj is UriNode Typed)
126 return this.parsed.ToString().CompareTo(Typed.parsed.ToString());
127 else
128 return base.CompareTo(obj);
129 }
130 }
131}
Abstract base class for semantic elements.
override object AssociatedObjectValue
Associated object value.
Definition: UriNode.cs:72
override bool IsLiteral
If element is a literal.
Definition: UriNode.cs:62
UriNode(Uri Uri, string Short)
Represents a URI
Definition: UriNode.cs:37
UriNode(Uri Uri)
Represents a URI
Definition: UriNode.cs:27
override bool Equals(object obj)
Definition: UriNode.cs:100
string ShortName
Short name, if available.
Definition: UriNode.cs:54
bool HasShortName
If URI has a short name.
Definition: UriNode.cs:67
override int CompareTo(object obj)
Compares the current instance with another object of the same type and returns an integer that indica...
Definition: UriNode.cs:123