Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
ToIntegerLiteral.cs
1
using
System.Numerics;
2
using
Waher.Content.Semantic.Model.Literals
;
3
using
Waher.Script.Abstraction.Elements
;
4
using
Waher.Script.Model
;
5
6
namespace
Waher.Script.Persistence.SPARQL.Functions.TypeConversion
7
{
11
public
class
ToIntegerLiteral
:
SemanticConversionFunction
12
{
16
public
ToIntegerLiteral
()
17
: base()
18
{
19
}
20
28
public
ToIntegerLiteral
(
ScriptNode
Argument
,
int
Start
,
int
Length
,
Expression
Expression
)
29
: base(
Argument
,
Start
,
Length
,
Expression
)
30
{
31
}
32
41
public
override
ScriptNode
CreateFunction
(
ScriptNode
Argument
,
int
Start
,
int
Length
,
Expression
Expression
)
42
{
43
return
new
ToIntegerLiteral
(
Argument
,
Start
,
Length
,
Expression
);
44
}
45
49
public
override
string
FunctionName
=>
IntegerLiteral
.
TypeUri
;
50
56
public
override
IElement
Convert
(
object
Value)
57
{
58
if
(Value is BigInteger i)
59
return
new
IntegerLiteral
(i);
60
else
if
(Value is
double
d)
61
return
new
IntegerLiteral
((BigInteger)d);
62
else
if
(Value is
bool
b)
63
return
new
IntegerLiteral
(b ? 1 : 0);
64
else
if
(Value is
string
s)
65
{
66
if
(BigInteger.TryParse(s, out i))
67
return
new
IntegerLiteral
(i);
68
}
69
else
if
(Value is Complex z)
70
{
71
if
(z.Imaginary == 0)
72
return
new
IntegerLiteral
((BigInteger)z.Real);
73
}
74
75
long
l = System.Convert.ToInt64(Value);
76
return
new
IntegerLiteral
(l);
77
}
78
}
79
}
Waher.Content.Semantic.Model.Literals.IntegerLiteral
Represents an integer literal of undefined size.
Definition:
IntegerLiteral.cs:12
Waher.Content.Semantic.Model.Literals.IntegerLiteral.TypeUri
const string TypeUri
http://www.w3.org/2001/XMLSchema#byte
Definition:
IntegerLiteral.cs:57
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.ToIntegerLiteral
Converts a value to a integer literal.
Definition:
ToIntegerLiteral.cs:12
Waher.Script.Persistence.SPARQL.Functions.TypeConversion.ToIntegerLiteral.ToIntegerLiteral
ToIntegerLiteral(ScriptNode Argument, int Start, int Length, Expression Expression)
Converts a value to a integer literal.
Definition:
ToIntegerLiteral.cs:28
Waher.Script.Persistence.SPARQL.Functions.TypeConversion.ToIntegerLiteral.ToIntegerLiteral
ToIntegerLiteral()
Converts a value to a integer literal.
Definition:
ToIntegerLiteral.cs:16
Waher.Script.Persistence.SPARQL.Functions.TypeConversion.ToIntegerLiteral.CreateFunction
override ScriptNode CreateFunction(ScriptNode Argument, int Start, int Length, Expression Expression)
Creates a function node.
Definition:
ToIntegerLiteral.cs:41
Waher.Script.Persistence.SPARQL.Functions.TypeConversion.ToIntegerLiteral.FunctionName
override string FunctionName
Name of the function
Definition:
ToIntegerLiteral.cs:49
Waher.Script.Persistence.SPARQL.Functions.TypeConversion.ToIntegerLiteral.Convert
override IElement Convert(object Value)
Converts an object to the desired type.
Definition:
ToIntegerLiteral.cs:56
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.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
ToIntegerLiteral.cs
Generated by
1.9.5