Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
ToDoubleLiteral.cs
1
using
System.Numerics;
2
using
Waher.Content
;
3
using
Waher.Content.Semantic.Model.Literals
;
4
using
Waher.Script.Abstraction.Elements
;
5
using
Waher.Script.Model
;
6
7
namespace
Waher.Script.Persistence.SPARQL.Functions.TypeConversion
8
{
12
public
class
ToDoubleLiteral
:
SemanticConversionFunction
13
{
17
public
ToDoubleLiteral
()
18
: base()
19
{
20
}
21
29
public
ToDoubleLiteral
(
ScriptNode
Argument
,
int
Start
,
int
Length
,
Expression
Expression
)
30
: base(
Argument
,
Start
,
Length
,
Expression
)
31
{
32
}
33
42
public
override
ScriptNode
CreateFunction
(
ScriptNode
Argument
,
int
Start
,
int
Length
,
Expression
Expression
)
43
{
44
return
new
ToDoubleLiteral
(
Argument
,
Start
,
Length
,
Expression
);
45
}
46
50
public
override
string
FunctionName
=>
DoubleLiteral
.
TypeUri
;
51
57
public
override
IElement
Convert
(
object
Value)
58
{
59
if
(Value is
double
d)
60
return
new
DoubleLiteral
(d);
61
else
if
(Value is
bool
b)
62
return
new
DoubleLiteral
(b ? 1 : 0);
63
else
if
(Value is
string
s)
64
{
65
if
(
CommonTypes
.
TryParse
(s, out d))
66
return
new
DoubleLiteral
(d);
67
}
68
else
if
(Value is BigInteger i)
69
return
new
DoubleLiteral
((
double
)i);
70
else
if
(Value is Complex z)
71
{
72
if
(z.Imaginary == 0)
73
return
new
DoubleLiteral
(z.Real);
74
}
75
76
d = System.Convert.ToDouble(Value);
77
return
new
DoubleLiteral
(d);
78
}
79
}
80
}
Waher.Content.CommonTypes
Helps with parsing of commong data types.
Definition:
CommonTypes.cs:13
Waher.Content.CommonTypes.TryParse
static bool TryParse(string s, out double Value)
Tries to decode a string encoded double.
Definition:
CommonTypes.cs:46
Waher.Content.Semantic.Model.Literals.DoubleLiteral
Represents a double literal.
Definition:
DoubleLiteral.cs:11
Waher.Content.Semantic.Model.Literals.DoubleLiteral.TypeUri
const string TypeUri
http://www.w3.org/2001/XMLSchema#double
Definition:
DoubleLiteral.cs:52
Waher.Script.Expression
Class managing a script expression.
Definition:
Expression.cs:39
Waher.Script.Model.FunctionOneVariable.Argument
ScriptNode Argument
Function argument.
Definition:
FunctionOneVariable.cs:33
Waher.Script.Model.ScriptNode
Base class for all nodes in a parsed script tree.
Definition:
ScriptNode.cs:69
Waher.Script.Model.ScriptNode.Length
int Length
Length of expression covered by node.
Definition:
ScriptNode.cs:101
Waher.Script.Model.ScriptNode.Start
int Start
Start position in script expression.
Definition:
ScriptNode.cs:92
Waher.Script.Persistence.SPARQL.Functions.TypeConversion.SemanticConversionFunction
Abstract base class for semantic conversion functions.
Definition:
SemanticConversionFunction.cs:12
Waher.Script.Persistence.SPARQL.Functions.TypeConversion.ToDoubleLiteral
Converts a value to a double literal.
Definition:
ToDoubleLiteral.cs:13
Waher.Script.Persistence.SPARQL.Functions.TypeConversion.ToDoubleLiteral.Convert
override IElement Convert(object Value)
Converts an object to the desired type.
Definition:
ToDoubleLiteral.cs:57
Waher.Script.Persistence.SPARQL.Functions.TypeConversion.ToDoubleLiteral.ToDoubleLiteral
ToDoubleLiteral(ScriptNode Argument, int Start, int Length, Expression Expression)
Converts a value to a double literal.
Definition:
ToDoubleLiteral.cs:29
Waher.Script.Persistence.SPARQL.Functions.TypeConversion.ToDoubleLiteral.CreateFunction
override ScriptNode CreateFunction(ScriptNode Argument, int Start, int Length, Expression Expression)
Creates a function node.
Definition:
ToDoubleLiteral.cs:42
Waher.Script.Persistence.SPARQL.Functions.TypeConversion.ToDoubleLiteral.FunctionName
override string FunctionName
Name of the function
Definition:
ToDoubleLiteral.cs:50
Waher.Script.Persistence.SPARQL.Functions.TypeConversion.ToDoubleLiteral.ToDoubleLiteral
ToDoubleLiteral()
Converts a value to a double literal.
Definition:
ToDoubleLiteral.cs:17
Waher.Script.Abstraction.Elements.IElement
Basic interface for all types of elements.
Definition:
IElement.cs:20
Waher.Content.Semantic.Model.Literals
Definition:
Base64Literal.cs:6
Waher.Content
Definition:
Array.cs:6
Waher.Script.Abstraction.Elements
Definition:
AbelianGroupElement.cs:5
Waher.Script.Model
Definition:
BinaryBooleanOperator.cs:8
Waher.Script.Persistence.SPARQL.Functions.TypeConversion
Definition:
SemanticConversionFunction.cs:7
IoTGateway
Script
Waher.Script.Persistence
SPARQL
Functions
TypeConversion
ToDoubleLiteral.cs
Generated by
1.9.5