Class LiteralExtensions
Provides extension methods for converting primitive types into appropriately typed Literal Nodes.
Inherited Members
Namespace: VDS.RDF
Assembly: dotNetRdf.dll
Syntax
public static class LiteralExtensions
Methods
| Edit this page View SourceToLiteral(bool, INodeFactory)
Creates a new Boolean typed literal.
Declaration
public static ILiteralNode ToLiteral(this bool b, INodeFactory factory)
Parameters
Type | Name | Description |
---|---|---|
bool | b | Boolean. |
INodeFactory | factory | Node Factory to use for Node creation. |
Returns
Type | Description |
---|---|
ILiteralNode | Literal representing the boolean. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if the Factory argument is null. |
ToLiteral(byte, INodeFactory)
Creates a new Byte typed literal.
Declaration
public static ILiteralNode ToLiteral(this byte b, INodeFactory factory)
Parameters
Type | Name | Description |
---|---|---|
byte | b | Byte. |
INodeFactory | factory | Node Factory to use for Node creation. |
Returns
Type | Description |
---|---|
ILiteralNode | Literal representing the byte. |
Remarks
Byte in .Net is actually equivalent to Unsigned Byte in XML Schema so depending on the value of the Byte the type will either be xsd:byte if it fits or xsd:usignedByte.
ToLiteral(DateTime, INodeFactory)
Creates a new Date Time typed literal.
Declaration
public static ILiteralNode ToLiteral(this DateTime dt, INodeFactory factory)
Parameters
Type | Name | Description |
---|---|---|
DateTime | dt | Date Time. |
INodeFactory | factory | Node Factory to use for Node creation. |
Returns
Type | Description |
---|---|
ILiteralNode | Literal representing the date time. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if the Factory argument is null. |
ToLiteral(DateTime, INodeFactory, bool)
Creates a new Date Time typed literal.
Declaration
public static ILiteralNode ToLiteral(this DateTime dt, INodeFactory factory, bool precise)
Parameters
Type | Name | Description |
---|---|---|
DateTime | dt | Date Time. |
INodeFactory | factory | Node Factory to use for Node creation. |
bool | precise | Whether to preserve precisely i.e. include fractional seconds. |
Returns
Type | Description |
---|---|
ILiteralNode | Literal representing the date time. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if the Factory argument is null. |
ToLiteral(DateTimeOffset, INodeFactory)
Creates a new Date Time typed literal.
Declaration
public static ILiteralNode ToLiteral(this DateTimeOffset dt, INodeFactory factory)
Parameters
Type | Name | Description |
---|---|---|
DateTimeOffset | dt | Date Time. |
INodeFactory | factory | Node Factory to use for Node creation. |
Returns
Type | Description |
---|---|
ILiteralNode | Literal representing the date time. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if the Factory argument is null. |
ToLiteral(DateTimeOffset, INodeFactory, bool)
Creates a new Date Time typed literal.
Declaration
public static ILiteralNode ToLiteral(this DateTimeOffset dt, INodeFactory factory, bool precise)
Parameters
Type | Name | Description |
---|---|---|
DateTimeOffset | dt | Date Time. |
INodeFactory | factory | Node Factory to use for Node creation. |
bool | precise | Whether to preserve precisely i.e. include fractional seconds. |
Returns
Type | Description |
---|---|
ILiteralNode | Literal representing the date time. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if the Factory argument is null. |
ToLiteral(decimal, INodeFactory)
Creates a new Decimal typed literal.
Declaration
public static ILiteralNode ToLiteral(this decimal d, INodeFactory factory)
Parameters
Type | Name | Description |
---|---|---|
decimal | d | Decimal. |
INodeFactory | factory | Node Factory to use for Node creation. |
Returns
Type | Description |
---|---|
ILiteralNode | Literal representing the decimal. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if the Factory argument is null. |
ToLiteral(double, INodeFactory)
Creates a new Double typed literal.
Declaration
public static ILiteralNode ToLiteral(this double d, INodeFactory factory)
Parameters
Type | Name | Description |
---|---|---|
double | d | Double. |
INodeFactory | factory | Node Factory to use for Node creation. |
Returns
Type | Description |
---|---|
ILiteralNode | Literal representing the double. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if the Factory argument is null. |
ToLiteral(short, INodeFactory)
Creates a new Integer typed literal.
Declaration
public static ILiteralNode ToLiteral(this short i, INodeFactory factory)
Parameters
Type | Name | Description |
---|---|---|
short | i | Integer. |
INodeFactory | factory | Node Factory to use for Node creation. |
Returns
Type | Description |
---|---|
ILiteralNode | Literal representing the short. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if the Factory argument is null. |
ToLiteral(int, INodeFactory)
Creates a new Integer typed literal.
Declaration
public static ILiteralNode ToLiteral(this int i, INodeFactory factory)
Parameters
Type | Name | Description |
---|---|---|
int | i | Integer. |
INodeFactory | factory | Node Factory to use for Node creation. |
Returns
Type | Description |
---|---|
ILiteralNode | Literal representing the integer. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if the Factory argument is null. |
ToLiteral(long, INodeFactory)
Creates a new Integer typed literal.
Declaration
public static ILiteralNode ToLiteral(this long l, INodeFactory factory)
Parameters
Type | Name | Description |
---|---|---|
long | l | Integer. |
INodeFactory | factory | Node Factory to use for Node creation. |
Returns
Type | Description |
---|---|
ILiteralNode | Literal representing the integer. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if the Factory argument is null. |
ToLiteral(sbyte, INodeFactory)
Creates a new Byte typed literal.
Declaration
public static ILiteralNode ToLiteral(this sbyte b, INodeFactory factory)
Parameters
Type | Name | Description |
---|---|---|
sbyte | b | Byte. |
INodeFactory | factory | Node Factory to use for Node creation. |
Returns
Type | Description |
---|---|
ILiteralNode | Literal representing the signed bytes. |
Remarks
SByte in .Net is directly equivalent to Byte in XML Schema so the type will always be xsd:byte.
ToLiteral(float, INodeFactory)
Creates a new Float typed literal.
Declaration
public static ILiteralNode ToLiteral(this float f, INodeFactory factory)
Parameters
Type | Name | Description |
---|---|---|
float | f | Float. |
INodeFactory | factory | Node Factory to use for Node creation. |
Returns
Type | Description |
---|---|
ILiteralNode | Literal representing the float. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if the Factory argument is null. |
ToLiteral(string, INodeFactory)
Creates a new String typed literal.
Declaration
public static ILiteralNode ToLiteral(this string s, INodeFactory factory)
Parameters
Type | Name | Description |
---|---|---|
string | s | String. |
INodeFactory | factory | Node Factory to use for Node creation. |
Returns
Type | Description |
---|---|
ILiteralNode | Literal representing the string. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if the Graph/String argument is null. |
ToLiteral(TimeSpan, INodeFactory)
Creates a new duration typed literal.
Declaration
public static ILiteralNode ToLiteral(this TimeSpan t, INodeFactory factory)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | t | Time Span. |
INodeFactory | factory | Node Factory to use for Node creation. |
Returns
Type | Description |
---|---|
ILiteralNode | Literal representing the time span. |
ToLiteralDate(DateTime, INodeFactory)
Creates a new Date typed literal.
Declaration
public static ILiteralNode ToLiteralDate(this DateTime dt, INodeFactory factory)
Parameters
Type | Name | Description |
---|---|---|
DateTime | dt | Date Time. |
INodeFactory | factory | Node Factory to use for Node creation. |
Returns
Type | Description |
---|---|
ILiteralNode |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if the Factory argument is null. |
ToLiteralDate(DateTimeOffset, INodeFactory)
Creates a new Date typed literal.
Declaration
public static ILiteralNode ToLiteralDate(this DateTimeOffset dt, INodeFactory factory)
Parameters
Type | Name | Description |
---|---|---|
DateTimeOffset | dt | Date Time. |
INodeFactory | factory | Node Factory to use for Node creation. |
Returns
Type | Description |
---|---|
ILiteralNode |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if the Factory argument is null. |
ToLiteralTime(DateTime, INodeFactory)
Creates a new Time typed literal.
Declaration
public static ILiteralNode ToLiteralTime(this DateTime dt, INodeFactory factory)
Parameters
Type | Name | Description |
---|---|---|
DateTime | dt | Date Time. |
INodeFactory | factory | Node Factory to use for Node creation. |
Returns
Type | Description |
---|---|
ILiteralNode | Literal representing the time. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if the Factory argument is null. |
ToLiteralTime(DateTime, INodeFactory, bool)
Creates a new Time typed literal.
Declaration
public static ILiteralNode ToLiteralTime(this DateTime dt, INodeFactory factory, bool precise)
Parameters
Type | Name | Description |
---|---|---|
DateTime | dt | Date Time. |
INodeFactory | factory | Node Factory to use for Node creation. |
bool | precise | Whether to preserve precisely i.e. include fractional seconds. |
Returns
Type | Description |
---|---|
ILiteralNode | Literal representing the time. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if the Factory argument is null. |
ToLiteralTime(DateTimeOffset, INodeFactory)
Creates a new Time typed literal.
Declaration
public static ILiteralNode ToLiteralTime(this DateTimeOffset dt, INodeFactory factory)
Parameters
Type | Name | Description |
---|---|---|
DateTimeOffset | dt | Date Time. |
INodeFactory | factory | Node Factory to use for Node creation. |
Returns
Type | Description |
---|---|
ILiteralNode | Literal representing the time. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if the Factory argument is null. |
ToLiteralTime(DateTimeOffset, INodeFactory, bool)
Creates a new Time typed literal.
Declaration
public static ILiteralNode ToLiteralTime(this DateTimeOffset dt, INodeFactory factory, bool precise)
Parameters
Type | Name | Description |
---|---|---|
DateTimeOffset | dt | Date Time. |
INodeFactory | factory | Node Factory to use for Node creation. |
bool | precise | Whether to preserve precisely i.e. include fractional seconds. |
Returns
Type | Description |
---|---|
ILiteralNode | Literal representing the time. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if the Factory argument is null. |
ToTripleCollection(IEnumerable<Triple>, bool)
Creates BaseTripleCollection from an enumeration of triples.
Declaration
public static BaseTripleCollection ToTripleCollection(this IEnumerable<Triple> triples, bool indexed = true)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<Triple> | triples | The triples to add to the collection. |
bool | indexed | True to create an indexed collection, false to create an un-indexed collection. |
Returns
Type | Description |
---|---|
BaseTripleCollection |