Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
SemanticLiteral.cs
1using System;
2using System.Text;
7
9{
14 {
15 private object value;
16 private Type valueType;
17 private IComparable comparable;
18
23 {
24 }
25
31 public SemanticLiteral(object Value, string StringValue)
32 {
33 this.value = Value;
34 this.valueType = null;
35 this.comparable = null;
36
37 this.StringValue = StringValue;
38 }
39
43 public override bool IsLiteral => true;
44
48 public object Value
49 {
50 get => this.value;
51 set
52 {
53 this.value = value;
54 this.valueType = null;
55 this.comparable = null;
56 }
57 }
58
62 public override object AssociatedObjectValue => this.value;
63
67 public abstract string StringType { get; }
68
72 public string StringValue { get; set; }
73
78
83
88
93
98
104 public virtual Grade Supports(string DataType)
105 {
106 return DataType == this.StringType ? Grade.Ok : Grade.NotAtAll;
107 }
108
114 public abstract Grade Supports(Type ValueType);
115
123 public abstract ISemanticLiteral Parse(string Value, string DataType, string Language);
124
130 public abstract ISemanticLiteral Encapsulate(object Value);
131
133 public override string ToString()
134 {
135 return CustomLiteral.ToString(this.StringValue, null, this.StringType);
136 }
137
149 public override int CompareTo(object obj)
150 {
151 if (obj is SemanticLiteral Typed)
152 {
153 if (this.valueType is null)
154 {
155 this.valueType = this.value?.GetType() ?? typeof(object);
156 this.comparable = this.value as IComparable;
157 }
158
159 if (Typed.valueType is null)
160 {
161 Typed.valueType = Typed.value?.GetType() ?? typeof(object);
162 Typed.comparable = Typed.value as IComparable;
163 }
164
165 if (this.valueType == Typed.valueType && !(this.comparable is null))
166 return this.comparable.CompareTo(Typed.value);
167 }
168
169 return base.CompareTo(obj);
170 }
171
178 {
179 return null;
180 }
181
188 {
189 return null;
190 }
191
196 public virtual IRingElement Invert()
197 {
198 return null;
199 }
200
207 {
208 if (this.AddRight(Element) is IAbelianGroupElement Result)
209 return Result;
210
211 if (Element.AddLeft(this) is IAbelianGroupElement Result2)
212 return Result2;
213
214 return null;
215 }
216
221 public virtual IGroupElement Negate()
222 {
223 return null;
224 }
225
232 {
233 return null;
234 }
235
242 {
243 return null;
244 }
245 }
246}
Abstract base class for semantic elements.
Abstract base class for semantic literal values.
virtual IRing AssociatedRing
Associated Ring.
override int CompareTo(object obj)
Compares the current instance with another object of the same type and returns an integer that indica...
virtual ISemiGroup AssociatedSemiGroup
Associated Semi-Group.
abstract ISemanticLiteral Encapsulate(object Value)
Encapsulates an object value as a semantic literal value.
override bool IsLiteral
If element is a literal.
virtual Grade Supports(string DataType)
How well the type supports a given data type.
virtual IAbelianGroupElement Zero
Returns the zero element of the group.
virtual IAbelianGroup AssociatedAbelianGroup
Associated Abelian Group.
abstract string StringType
Type name (or null if literal value is a string)
virtual IRingElement MultiplyLeft(IRingElement Element)
Tries to multiply an element to the current element, from the left.
SemanticLiteral()
Abstract base class for semantic literal values.
abstract ISemanticLiteral Parse(string Value, string DataType, string Language)
Tries to parse a string value of the type supported by the class..
virtual IRingElement Invert()
Inverts the element, if possible.
SemanticLiteral(object Value, string StringValue)
Abstract base class for semantic literal values.
virtual IAbelianGroupElement Add(IAbelianGroupElement Element)
Tries to add an element to the current element.
virtual ISemiGroupElement AddLeft(ISemiGroupElement Element)
Tries to add an element to the current element, from the left.
override object AssociatedObjectValue
Associated object value.
virtual IRingElement MultiplyRight(IRingElement Element)
Tries to multiply an element to the current element, from the right.
string StringValue
String representation of value.
virtual IGroup AssociatedGroup
Associated Group.
virtual ISemiGroupElement AddRight(ISemiGroupElement Element)
Tries to add an element to the current element, from the right.
virtual IGroupElement Negate()
Negates the element.
abstract Grade Supports(Type ValueType)
How well the type supports a given value type.
static readonly SemanticLiterals Instance
Instance reference to the set of semantic literals.
override IAbelianGroupElement Zero
Returns the zero element of the group.
Base class for all types of elements.
Definition: Element.cs:14
Interface for semantic literals.
Basic interface for all types of abelian group elements.
Basic interface for all types of group elements.
Definition: IGroupElement.cs:9
Basic interface for all types of ring elements.
Definition: IRingElement.cs:10
Basic interface for all types of semigroup elements.
Basic interface for all types of abelian groups.
Basic interface for all types of groups.
Definition: IGroup.cs:10
Basic interface for all types of rings.
Definition: IRing.cs:10
Basic interface for all types of semigroups.
Definition: ISemiGroup.cs:10
Grade
Grade enumeration
Definition: Grade.cs:7