Class Token
Represents a special or lazily-evaluated value.
public class Token : DeputyBase
- Inheritance
-
Token
Remarks
Can be used to delay evaluation of a certain value in case, for example, that it requires some context or late-bound data. Can also be used to mark values that need special processing at document rendering time.
Tokens can be embedded into strings while retaining their original semantics.
Methods
AsAny(object)
Return a resolvable representation of the given value.
public static IResolvable AsAny(object value)
Parameters
value
object
Returns
AsList(object, IEncodingOptions?)
Return a reversible list representation of this token.
public static string[] AsList(object value, IEncodingOptions? options = null)
Parameters
value
objectoptions
IEncodingOptions
Returns
- string[]
AsNumber(object)
Return a reversible number representation of this token.
public static double AsNumber(object value)
Parameters
value
object
Returns
AsString(object, IEncodingOptions?)
Return a reversible string representation of this token.
public static string AsString(object value, IEncodingOptions? options = null)
Parameters
value
objectoptions
IEncodingOptions
Returns
Remarks
If the Token is initialized with a literal, the stringified value of the literal is returned. Otherwise, a special quoted string representation of the Token is returned that can be embedded into other strings.
Strings with quoted Tokens in them can be restored back into
complex values with the Tokens restored by calling resolve()
on the string.
CompareStrings(string, string)
Compare two strings that might contain Tokens with each other.
public static TokenComparison CompareStrings(string possibleToken1, string possibleToken2)
Parameters
Returns
IsUnresolved(object)
Returns true if obj represents an unresolved value.
public static bool IsUnresolved(object obj)
Parameters
obj
objectThe object to test.
Returns
Remarks
One of these must be true:
This does NOT recurse into lists or objects to see if they containing resolvables.