Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
BooleanLiteral.cs
1using System;
4
6{
11 {
16 : base()
17 {
18 }
19
24 public BooleanLiteral(bool Value)
25 : base(Value, CommonTypes.Encode(Value))
26 {
27 }
28
34 public BooleanLiteral(bool Value, string StringValue)
35 : base(Value, StringValue)
36 {
37 }
38
42 public const string TypeUri = XmlSchema.Namespace + "boolean";
43
47 public override string StringType => TypeUri;
48
54 public override Grade Supports(Type ValueType)
55 {
56 return ValueType == typeof(bool) ? Grade.Ok : Grade.NotAtAll;
57 }
58
66 public override ISemanticLiteral Parse(string Value, string DataType, string Language)
67 {
68 if (CommonTypes.TryParse(Value, out bool b))
69 return new BooleanLiteral(b, Value);
70 else
71 return new CustomLiteral(Value, DataType, Language);
72 }
73
79 public override ISemanticLiteral Encapsulate(object Value)
80 {
81 if (Value is bool Typed)
82 return new BooleanLiteral(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 BooleanLiteral Typed &&
91 Typed.StringValue == this.StringValue;
92 }
93
95 public override int GetHashCode()
96 {
97 return this.Value.GetHashCode();
98 }
99 }
100}
Helps with parsing of commong data types.
Definition: CommonTypes.cs:13
static bool TryParse(string s, out double Value)
Tries to decode a string encoded double.
Definition: CommonTypes.cs:46
BooleanLiteral(bool Value)
Represents a bool literal.
BooleanLiteral(bool Value, string StringValue)
Represents a bool literal.
override Grade Supports(Type ValueType)
How well the type supports a given value type.
override ISemanticLiteral Encapsulate(object Value)
Encapsulates an object value as a semantic literal value.
const string TypeUri
http://www.w3.org/2001/XMLSchema#boolean
override ISemanticLiteral Parse(string Value, string DataType, string Language)
Tries to parse a string value of the type supported by the class..
Abstract base class for semantic literal values.
string StringValue
String representation of value.
Interface for semantic literals.
Grade
Grade enumeration
Definition: Grade.cs:7