ParksComputing.Xfer.Lang API Documentation
API documentation for ParksComputing.Xfer.Lang version 0.15.0.0
Namespace: ParksComputing.Xfer.Lang
Enum: DateTimeHandling
Specifies how DateTime values should be handled during serialization and deserialization. Controls time zone information and formatting in the resulting XferLang output.
Members
Name | Value | Description |
---|---|---|
Local |
1 |
Serialize with local time zone information. |
RoundTrip |
3 |
Serialize preserving the original DateTimeOffset information for round-trip fidelity. |
Unspecified |
0 |
Serialize without time zone information using ISO format. |
Utc |
2 |
Serialize with UTC time zone information. |
Enum: Formatting
Specifies formatting options for XferLang document serialization. These options control how the output text is structured and formatted.
Members
Name | Value | Description |
---|---|---|
Indented |
1 |
Apply indentation to nested elements for improved readability. |
None |
0 |
No special formatting applied. Output is compact with minimal whitespace. |
Pretty |
17 |
Combines indented and spaced formatting for maximum readability. Equivalent to | . |
Spaced |
16 |
Add spacing between elements for better visual separation. |
Class: ParseError
Represents an error encountered during XferLang document parsing. Parse errors indicate syntax or structural problems that prevent successful parsing.
Properties
Name | Type | Description |
---|---|---|
Column |
int |
Gets or sets the column number where the error occurred (1-based). |
Context |
string |
Gets or sets additional context information related to the error, if available. |
Message |
string |
Gets or sets the error message describing the issue. |
Row |
int |
Gets or sets the row number where the error occurred (1-based). |
Methods
Constructor
ParseError(string message, int row, int column, string context)
Initializes a new instance of the class.
Parameters
Name | Type | Description |
---|---|---|
message |
string |
The error message. |
row |
int |
The row number where the error occurred (1-based). |
column |
int |
The column number where the error occurred (1-based). |
context |
string |
Optional additional context information. |
ToString
string ToString()
Returns a string representation of the error including location information.
Returns
A formatted string describing the error and its location.
Class: ParseWarning
Represents a warning encountered during XferLang document parsing. Warnings indicate potential issues that don't prevent parsing but may affect document interpretation.
Properties
Name | Type | Description |
---|---|---|
Column |
int |
Gets or sets the column number where the warning occurred (1-based). |
Context |
string |
Gets or sets additional context information related to the warning, if available. |
Message |
string |
Gets or sets the warning message describing the issue. |
Row |
int |
Gets or sets the row number where the warning occurred (1-based). |
Type |
WarningType |
Gets or sets the type of warning that occurred. |
Methods
Constructor
ParseWarning(WarningType type, string message, int row, int column, string context)
Initializes a new instance of the class.
Parameters
Name | Type | Description |
---|---|---|
type |
WarningType |
The type of warning. |
message |
string |
The warning message. |
row |
int |
The row number where the warning occurred (1-based). |
column |
int |
The column number where the warning occurred (1-based). |
context |
string |
Optional additional context information. |
ToString
string ToString()
Returns a string representation of the warning including location information.
Returns
A formatted string describing the warning and its location.
Enum: WarningType
Specifies the types of warnings that can occur during XferLang parsing.
Members
Name | Value | Description |
---|---|---|
CharacterResolutionFailure |
0 |
A character name could not be resolved to a valid character code point. |
EmptyCharacterElement |
3 |
A character element was empty and a replacement character was used. |
InvalidCharacterValue |
4 |
A character value was invalid and a fallback was used. |
NumericPrecisionLoss |
1 |
Precision may be lost during numeric conversion. |
Trace |
7 |
Non-problem diagnostic trace emitted during parsing (informational only). |
UnknownConditionalOperator |
5 |
An if processing instruction referenced an unknown/unregistered operator (condition treated as false). |
UnregisteredProcessingInstruction |
2 |
An unregistered processing instruction was encountered. |
UnresolvedReference |
6 |
A reference element referenced a name that has not been bound via a let binding. |
Class: XferConvert
Provides static methods for converting between .NET objects and XferLang elements or text. This class serves as the primary entry point for serialization and deserialization operations, similar to JsonConvert in Newtonsoft.Json.
Methods
Constructor
XferConvert()
Deserialize
T Deserialize(string xfer)
Deserializes a XferLang string to an object of type T using default settings.
Parameters
Name | Type | Description |
---|---|---|
xfer |
string |
The XferLang string to deserialize. |
Returns
An object of type T, or default(T) if the string is null or empty.
Deserialize
T Deserialize(string xfer, XferSerializerSettings settings)
Deserializes a XferLang string to an object of type T using custom settings.
Parameters
Name | Type | Description |
---|---|---|
xfer |
string |
The XferLang string to deserialize. |
settings |
XferSerializerSettings |
Serializer settings to control deserialization behavior. |
Returns
An object of type T, or default(T) if the string is null or empty.
Deserialize
T Deserialize(XferDocument document)
Deserializes a XferDocument to an object of type T using default settings.
Parameters
Name | Type | Description |
---|---|---|
document |
XferDocument |
The XferDocument to deserialize. |
Returns
An object of type T, or default(T) if the document has no elements.
Deserialize
T Deserialize(XferDocument document, XferSerializerSettings settings)
Deserializes a XferDocument to an object of type T using custom settings.
Parameters
Name | Type | Description |
---|---|---|
document |
XferDocument |
The XferDocument to deserialize. |
settings |
XferSerializerSettings |
Serializer settings to control deserialization behavior. |
Returns
An object of type T, or default(T) if the document has no elements.
Deserialize
Object Deserialize(XferDocument document, Type targetType)
Deserializes a XferDocument to an object of the specified type using default settings.
Parameters
Name | Type | Description |
---|---|---|
document |
XferDocument |
The XferDocument to deserialize. |
targetType |
Type |
The target type to deserialize to. |
Returns
An object of the target type, or null if the document has no elements.
Deserialize
Object Deserialize(XferDocument document, Type targetType, XferSerializerSettings settings)
Deserializes a XferDocument to an object of the specified type using custom settings.
Parameters
Name | Type | Description |
---|---|---|
document |
XferDocument |
The XferDocument to deserialize. |
targetType |
Type |
The target type to deserialize to. |
settings |
XferSerializerSettings |
Serializer settings to control deserialization behavior. |
Returns
An object of the target type, or null if the document has no elements.
Deserialize
Object Deserialize(string xfer, Type targetType)
Deserializes a XferLang string to an object of the specified type using default settings.
Parameters
Name | Type | Description |
---|---|---|
xfer |
string |
The XferLang string to deserialize. |
targetType |
Type |
The target type to deserialize to. |
Returns
An object of the target type, or null if the string is null, empty, or invalid.
Deserialize
Object Deserialize(string xfer, Type targetType, XferSerializerSettings settings)
Deserializes a XferLang string to an object of the specified type using custom settings.
Parameters
Name | Type | Description |
---|---|---|
xfer |
string |
The XferLang string to deserialize. |
targetType |
Type |
The target type to deserialize to. |
settings |
XferSerializerSettings |
Serializer settings to control deserialization behavior. |
Returns
An object of the target type, or null if the string is null, empty, or invalid.
Deserialize
T Deserialize(Element element)
Deserializes a XferLang Element to an object of type T using default settings.
Parameters
Name | Type | Description |
---|---|---|
element |
Element |
The XferLang Element to deserialize. |
Returns
An object of type T.
Deserialize
T Deserialize(Element element, XferSerializerSettings settings)
Deserializes a XferLang Element to an object of type T using custom settings.
Parameters
Name | Type | Description |
---|---|---|
element |
Element |
The XferLang Element to deserialize. |
settings |
XferSerializerSettings |
Serializer settings to control deserialization behavior. |
Returns
An object of type T.
DeserializeAsync
Task<T> DeserializeAsync(TextReader reader, CancellationToken cancellationToken)
Asynchronously deserializes XferLang content from a TextReader to an object of type T using default settings.
Parameters
Name | Type | Description |
---|---|---|
reader |
TextReader |
The TextReader to read from. |
cancellationToken |
CancellationToken |
Token to monitor for cancellation requests. |
Returns
A task that represents the asynchronous read operation. The task result contains the deserialized object.
DeserializeAsync
Task<T> DeserializeAsync(TextReader reader, XferSerializerSettings settings, CancellationToken cancellationToken)
Asynchronously deserializes XferLang content from a TextReader to an object of type T using custom settings.
Parameters
Name | Type | Description |
---|---|---|
reader |
TextReader |
The TextReader to read from. |
settings |
XferSerializerSettings |
Serializer settings to control deserialization behavior. |
cancellationToken |
CancellationToken |
Token to monitor for cancellation requests. |
Returns
A task that represents the asynchronous read operation. The task result contains the deserialized object.
DeserializeFromFileAsync
Task<T> DeserializeFromFileAsync(string filePath, CancellationToken cancellationToken)
Asynchronously deserializes a XferLang file to an object of type T using default settings.
Parameters
Name | Type | Description |
---|---|---|
filePath |
string |
The path to the file to read. |
cancellationToken |
CancellationToken |
Token to monitor for cancellation requests. |
Returns
A task that represents the asynchronous read operation. The task result contains the deserialized object.
DeserializeFromFileAsync
Task<T> DeserializeFromFileAsync(string filePath, XferSerializerSettings settings, CancellationToken cancellationToken)
Asynchronously deserializes a XferLang file to an object of type T using custom settings.
Parameters
Name | Type | Description |
---|---|---|
filePath |
string |
The path to the file to read. |
settings |
XferSerializerSettings |
Serializer settings to control deserialization behavior. |
cancellationToken |
CancellationToken |
Token to monitor for cancellation requests. |
Returns
A task that represents the asynchronous read operation. The task result contains the deserialized object.
DeserializeFromStreamAsync
Task<T> DeserializeFromStreamAsync(Stream stream, CancellationToken cancellationToken)
Asynchronously deserializes XferLang content from a Stream to an object of type T using default settings. Assumes UTF-8 encoding.
Parameters
Name | Type | Description |
---|---|---|
stream |
Stream |
The Stream to read from. |
cancellationToken |
CancellationToken |
Token to monitor for cancellation requests. |
Returns
A task that represents the asynchronous read operation. The task result contains the deserialized object.
DeserializeFromStreamAsync
Task<T> DeserializeFromStreamAsync(Stream stream, XferSerializerSettings settings, CancellationToken cancellationToken)
Asynchronously deserializes XferLang content from a Stream to an object of type T using custom settings. Assumes UTF-8 encoding.
Parameters
Name | Type | Description |
---|---|---|
stream |
Stream |
The Stream to read from. |
settings |
XferSerializerSettings |
Serializer settings to control deserialization behavior. |
cancellationToken |
CancellationToken |
Token to monitor for cancellation requests. |
Returns
A task that represents the asynchronous read operation. The task result contains the deserialized object.
FromObject
ObjectElement FromObject(Object o, XferSerializerSettings settings)
Creates an ObjectElement from a POCO, similar to JObject.FromObject.
Serialize
string Serialize(Object o, Formatting formatting, Char indentChar, int indentation, int depth)
Serializes an object to a XferLang string with formatting options. Uses default serializer settings.
Parameters
Name | Type | Description |
---|---|---|
o |
Object |
The object to serialize. |
formatting |
Formatting |
Controls indentation and formatting of the output. |
indentChar |
Char |
Character to use for indentation (default: space). |
indentation |
int |
Number of indent characters per level (default: 2). |
depth |
int |
Starting depth level for indentation (default: 0). |
Returns
XferLang string representation of the object.
Serialize
string Serialize(Object o, XferSerializerSettings settings, Formatting formatting, Char indentChar, int indentation, int depth)
Serializes an object to a XferLang string with custom settings and formatting options.
Parameters
Name | Type | Description |
---|---|---|
o |
Object |
The object to serialize. |
settings |
XferSerializerSettings |
Serializer settings to control conversion behavior. |
formatting |
Formatting |
Controls indentation and formatting of the output. |
indentChar |
Char |
Character to use for indentation (default: space). |
indentation |
int |
Number of indent characters per level (default: 2). |
depth |
int |
Starting depth level for indentation (default: 0). |
Returns
XferLang string representation of the object.
SerializeAsync
Task SerializeAsync(T value, TextWriter writer, CancellationToken cancellationToken)
Asynchronously serializes an object to a TextWriter with default settings.
Parameters
Name | Type | Description |
---|---|---|
value |
T |
The object to serialize. |
writer |
TextWriter |
The TextWriter to write to. |
cancellationToken |
CancellationToken |
Token to monitor for cancellation requests. |
Returns
A task that represents the asynchronous write operation.
SerializeAsync
Task SerializeAsync(T value, TextWriter writer, Formatting formatting, CancellationToken cancellationToken)
Asynchronously serializes an object to a TextWriter with formatting.
Parameters
Name | Type | Description |
---|---|---|
value |
T |
The object to serialize. |
writer |
TextWriter |
The TextWriter to write to. |
formatting |
Formatting |
Controls indentation and formatting of the output. |
cancellationToken |
CancellationToken |
Token to monitor for cancellation requests. |
Returns
A task that represents the asynchronous write operation.
SerializeAsync
Task SerializeAsync(T value, TextWriter writer, XferSerializerSettings settings, Formatting formatting, CancellationToken cancellationToken)
Asynchronously serializes an object to a TextWriter with custom settings and formatting.
Parameters
Name | Type | Description |
---|---|---|
value |
T |
The object to serialize. |
writer |
TextWriter |
The TextWriter to write to. |
settings |
XferSerializerSettings |
Serializer settings to control serialization behavior. |
formatting |
Formatting |
Controls indentation and formatting of the output. |
cancellationToken |
CancellationToken |
Token to monitor for cancellation requests. |
Returns
A task that represents the asynchronous write operation.
SerializeToFileAsync
Task SerializeToFileAsync(T value, string filePath, CancellationToken cancellationToken)
Asynchronously serializes an object to a XferLang file with default settings.
Parameters
Name | Type | Description |
---|---|---|
value |
T |
The object to serialize. |
filePath |
string |
The path to the file to write. |
cancellationToken |
CancellationToken |
Token to monitor for cancellation requests. |
Returns
A task that represents the asynchronous write operation.
SerializeToFileAsync
Task SerializeToFileAsync(T value, string filePath, Formatting formatting, CancellationToken cancellationToken)
Asynchronously serializes an object to a XferLang file with formatting.
Parameters
Name | Type | Description |
---|---|---|
value |
T |
The object to serialize. |
filePath |
string |
The path to the file to write. |
formatting |
Formatting |
Controls indentation and formatting of the output. |
cancellationToken |
CancellationToken |
Token to monitor for cancellation requests. |
Returns
A task that represents the asynchronous write operation.
SerializeToFileAsync
Task SerializeToFileAsync(T value, string filePath, XferSerializerSettings settings, Formatting formatting, CancellationToken cancellationToken)
Asynchronously serializes an object to a XferLang file with custom settings and formatting.
Parameters
Name | Type | Description |
---|---|---|
value |
T |
The object to serialize. |
filePath |
string |
The path to the file to write. |
settings |
XferSerializerSettings |
Serializer settings to control serialization behavior. |
formatting |
Formatting |
Controls indentation and formatting of the output. |
cancellationToken |
CancellationToken |
Token to monitor for cancellation requests. |
Returns
A task that represents the asynchronous write operation.
SerializeToStreamAsync
Task SerializeToStreamAsync(T value, Stream stream, CancellationToken cancellationToken)
Asynchronously serializes an object to a Stream with UTF-8 encoding using default settings.
Parameters
Name | Type | Description |
---|---|---|
value |
T |
The object to serialize. |
stream |
Stream |
The Stream to write to. |
cancellationToken |
CancellationToken |
Token to monitor for cancellation requests. |
Returns
A task that represents the asynchronous write operation.
SerializeToStreamAsync
Task SerializeToStreamAsync(T value, Stream stream, Formatting formatting, CancellationToken cancellationToken)
Asynchronously serializes an object to a Stream with UTF-8 encoding and formatting.
Parameters
Name | Type | Description |
---|---|---|
value |
T |
The object to serialize. |
stream |
Stream |
The Stream to write to. |
formatting |
Formatting |
Controls indentation and formatting of the output. |
cancellationToken |
CancellationToken |
Token to monitor for cancellation requests. |
Returns
A task that represents the asynchronous write operation.
SerializeToStreamAsync
Task SerializeToStreamAsync(T value, Stream stream, XferSerializerSettings settings, Formatting formatting, CancellationToken cancellationToken)
Asynchronously serializes an object to a Stream with UTF-8 encoding, custom settings and formatting.
Parameters
Name | Type | Description |
---|---|---|
value |
T |
The object to serialize. |
stream |
Stream |
The Stream to write to. |
settings |
XferSerializerSettings |
Serializer settings to control serialization behavior. |
formatting |
Formatting |
Controls indentation and formatting of the output. |
cancellationToken |
CancellationToken |
Token to monitor for cancellation requests. |
Returns
A task that represents the asynchronous write operation.
SerializeValue
Element SerializeValue(Object value)
Converts an object to a XferLang Element using default settings.
Parameters
Name | Type | Description |
---|---|---|
value |
Object |
The object to convert. |
Returns
The XferLang Element representation of the object.
SerializeValue
Element SerializeValue(Object value, XferSerializerSettings settings)
Converts an object to a XferLang Element using custom serializer settings. Applies custom converters first, then falls back to built-in type conversion logic.
Parameters
Name | Type | Description |
---|---|---|
value |
Object |
The object to convert. |
settings |
XferSerializerSettings |
Serializer settings to control conversion behavior. |
Returns
The XferLang Element representation of the object.
ToObject
T ToObject(ObjectElement element, XferSerializerSettings settings)
Deserializes an ObjectElement to a POCO of type T.
TryDeserializeAsync
Task<ValueTuple<bool, T>> TryDeserializeAsync(TextReader reader, CancellationToken cancellationToken)
Attempts to asynchronously deserialize XferLang content from a TextReader to an object of type T. Returns result with success status without throwing exceptions.
Parameters
Name | Type | Description |
---|---|---|
reader |
TextReader |
The TextReader to read from. |
cancellationToken |
CancellationToken |
Token to monitor for cancellation requests. |
Returns
A task that represents the asynchronous operation. The task result contains the success status and the deserialized object if successful.
TryDeserializeFromFileAsync
Task<ValueTuple<bool, T>> TryDeserializeFromFileAsync(string filePath, CancellationToken cancellationToken)
Attempts to asynchronously deserialize a file to an object of type T. Returns result with success status without throwing exceptions.
Parameters
Name | Type | Description |
---|---|---|
filePath |
string |
The path to the file to read. |
cancellationToken |
CancellationToken |
Token to monitor for cancellation requests. |
Returns
A task that represents the asynchronous operation. The task result contains the success status and the deserialized object if successful.
TryFromObject
bool TryFromObject(Object o, ObjectElement& result, XferSerializerSettings settings)
TrySerializeAsync
Task<bool> TrySerializeAsync(T value, TextWriter writer, CancellationToken cancellationToken)
Attempts to asynchronously serialize an object to a TextWriter. Returns success status without throwing exceptions.
Parameters
Name | Type | Description |
---|---|---|
value |
T |
The object to serialize. |
writer |
TextWriter |
The TextWriter to write to. |
cancellationToken |
CancellationToken |
Token to monitor for cancellation requests. |
Returns
A task that represents the asynchronous operation. The task result indicates success or failure.
TrySerializeToFileAsync
Task<bool> TrySerializeToFileAsync(T value, string filePath, CancellationToken cancellationToken)
Attempts to asynchronously serialize an object to a file. Returns success status without throwing exceptions.
Parameters
Name | Type | Description |
---|---|---|
value |
T |
The object to serialize. |
filePath |
string |
The path to the file to write. |
cancellationToken |
CancellationToken |
Token to monitor for cancellation requests. |
Returns
A task that represents the asynchronous operation. The task result indicates success or failure.
TryToObject
bool TryToObject(ObjectElement element, T& result, XferSerializerSettings settings)
Class: XferDocument
Represents a complete XferLang document with its root element, metadata, processing instructions, and any parsing errors or warnings. This is the primary object model for working with XferLang content.
Properties
Name | Type | Description |
---|---|---|
Error |
ParseError |
The first fatal error encountered during parsing, if any. When an error is present, parsing stops and the document may be incomplete. |
HasError |
bool |
Gets a value indicating whether the document has a fatal error. |
HasWarnings |
bool |
Gets a value indicating whether the document has any warnings. |
IsValid |
bool |
Gets a value indicating whether the document is valid (no fatal errors). Note: A document can be valid but still have warnings. |
Metadata |
XferMetadata |
Gets or sets the document metadata, if specified via document processing instructions. Contains information about the XferLang version, document version, and custom metadata. |
ProcessingInstructions |
List<ProcessingInstruction> |
Document-level Processing Instructions that appear outside the root element. These are conceptually siblings to the root element. |
Root |
CollectionElement |
Gets or sets the root element of the document. Defaults to an empty tuple element. All document content is contained within this root element. |
Warnings |
List<ParseWarning> |
Collection of non-fatal warnings encountered during parsing. Warnings indicate potential issues but don't prevent successful parsing. |
Methods
Constructor
XferDocument()
Initializes a new XferDocument with an empty root collection.
Constructor
XferDocument(CollectionElement root)
Initializes a new XferDocument with the specified root collection.
Parameters
Name | Type | Description |
---|---|---|
root |
CollectionElement |
The root collection element for the document. |
Add
void Add(Element value)
Adds an element to the document's root collection.
Parameters
Name | Type | Description |
---|---|---|
value |
Element |
The element to add to the document. |
ContainsElementId
bool ContainsElementId(string id)
Checks if an element with the specified ID exists in the document.
Parameters
Name | Type | Description |
---|---|---|
id |
string |
The ID to check for. |
Returns
True if an element with the specified ID exists; otherwise, false.
ContainsTag
bool ContainsTag(string tag)
Checks if any elements in the document have the specified tag.
Parameters
Name | Type | Description |
---|---|---|
tag |
string |
The tag to check for. |
Returns
True if any elements have the specified tag; otherwise, false.
FindElementById
Element FindElementById(string id)
Finds an element by its ID using the original tree traversal method. This method is provided for compatibility and verification purposes. Generally, GetElementById should be used instead for better performance.
Parameters
Name | Type | Description |
---|---|---|
id |
string |
The ID of the element to find. |
Returns
The first element that matches the given ID; otherwise, null.
GetAllElementsWithIds
IReadOnlyDictionary<string, Element> GetAllElementsWithIds()
Gets all elements in the document that have IDs assigned.
Returns
A read-only collection of all elements with IDs.
GetAllTags
IReadOnlyCollection<string> GetAllTags()
Gets all unique tags used in the document.
Returns
A read-only collection of all tags in the document.
GetElementById
Element GetElementById(string id)
Finds an element by its ID within the document using fast O(1) lookup.
Parameters
Name | Type | Description |
---|---|---|
id |
string |
The ID of the element to find. |
Returns
The first element that matches the given ID; otherwise, null.
GetElementsByAllTags
IReadOnlyCollection<Element> GetElementsByAllTags(String[] tags)
Gets all elements in the document that have all of the specified tags.
Parameters
Name | Type | Description |
---|---|---|
tags |
String[] |
The tags that elements must have. |
Returns
A read-only collection of elements that have all of the specified tags.
GetElementsByAnyTag
IReadOnlyCollection<Element> GetElementsByAnyTag(String[] tags)
Gets all elements in the document that have any of the specified tags.
Parameters
Name | Type | Description |
---|---|---|
tags |
String[] |
The tags to search for. |
Returns
A read-only collection of elements that have at least one of the specified tags.
GetElementsByTag
IReadOnlyCollection<Element> GetElementsByTag(string tag)
Gets all elements in the document that have the specified tag.
Parameters
Name | Type | Description |
---|---|---|
tag |
string |
The tag to search for. |
Returns
A read-only collection of elements with the specified tag.
GetElementsByType
IReadOnlyCollection<T> GetElementsByType()
Gets all elements of the specified type in the document.
Returns
A collection of elements of the specified type.
GetElementsByType
IReadOnlyCollection<Element> GetElementsByType(Type elementType)
Gets all elements of the specified type in the document.
Parameters
Name | Type | Description |
---|---|---|
elementType |
Type |
The element type to search for. |
Returns
A collection of elements of the specified type.
GetTagElementCount
int GetTagElementCount(string tag)
Gets the count of elements that have the specified tag.
Parameters
Name | Type | Description |
---|---|---|
tag |
string |
The tag to count elements for. |
Returns
The number of elements with the specified tag.
ToByteArray
Byte[] ToByteArray()
Converts the document to a UTF-8 encoded byte array.
Returns
A byte array containing the UTF-8 encoded XferLang representation.
ToString
string ToString()
Returns a string representation of the document using default formatting.
Returns
A XferLang string representation of the document.
ToXfer
string ToXfer()
Converts the document to a XferLang string representation without formatting.
Returns
A compact XferLang string representation of the document.
ToXfer
string ToXfer(Formatting formatting, Char indentChar, int indentation, int depth)
Converts the document to a XferLang string representation with formatting options.
Parameters
Name | Type | Description |
---|---|---|
formatting |
Formatting |
Controls indentation and formatting of the output. |
indentChar |
Char |
Character to use for indentation (default: space). |
indentation |
int |
Number of indent characters per level (default: 2). |
depth |
int |
Starting depth level for indentation (default: 0). |
Returns
A formatted XferLang string representation of the document.
Class: XferMetadata
Represents metadata information for an XferLang document. Contains standard metadata fields and supports extensible custom metadata.
Properties
Name | Type | Description |
---|---|---|
Extensions |
Dictionary<string, Object> |
Gets a dictionary containing user-defined or unknown metadata keys and their values. This allows for extensible metadata beyond the standard fields. |
Version |
string |
Gets or sets the document version specified by the author. |
Xfer |
string |
Gets or sets the XferLang parser version used to create this document. Defaults to the current parser version. |
Methods
Constructor
XferMetadata()
Class: XferParser
Provides static convenience methods for parsing XferLang content into document objects. This is a simplified interface to the underlying Parser class for common parsing scenarios.
Methods
Constructor
XferParser()
Parse
XferDocument Parse(Byte[] input)
Parses XferLang content from a byte array using a new parser instance.
Parameters
Name | Type | Description |
---|---|---|
input |
Byte[] |
The byte array containing XferLang content to parse. |
Returns
An XferDocument representing the parsed content.
Parse
XferDocument Parse(string input)
Parses XferLang content from a string using a new parser instance.
Parameters
Name | Type | Description |
---|---|---|
input |
string |
The string containing XferLang content to parse. |
Returns
An XferDocument representing the parsed content.
ParseFileAsync
Task<XferDocument> ParseFileAsync(string filePath, CancellationToken cancellationToken)
Asynchronously parses XferLang content from a file using a new parser instance.
Parameters
Name | Type | Description |
---|---|---|
filePath |
string |
The path to the file containing XferLang content to parse. |
cancellationToken |
CancellationToken |
Token to monitor for cancellation requests. |
Returns
A task that represents the asynchronous parse operation. The task result contains an XferDocument representing the parsed content.
ParseStreamAsync
Task<XferDocument> ParseStreamAsync(Stream stream, CancellationToken cancellationToken)
Asynchronously parses XferLang content from a stream using a new parser instance. Assumes UTF-8 encoding.
Parameters
Name | Type | Description |
---|---|---|
stream |
Stream |
The stream containing XferLang content to parse. |
cancellationToken |
CancellationToken |
Token to monitor for cancellation requests. |
Returns
A task that represents the asynchronous parse operation. The task result contains an XferDocument representing the parsed content.
ParseTextReaderAsync
Task<XferDocument> ParseTextReaderAsync(TextReader reader, CancellationToken cancellationToken)
Asynchronously parses XferLang content from a TextReader using a new parser instance.
Parameters
Name | Type | Description |
---|---|---|
reader |
TextReader |
The TextReader containing XferLang content to parse. |
cancellationToken |
CancellationToken |
Token to monitor for cancellation requests. |
Returns
A task that represents the asynchronous parse operation. The task result contains an XferDocument representing the parsed content.
Namespace: ParksComputing.Xfer.Lang.Attributes
Class: XferCaptureIdAttribute
Apply this to the ID TARGET property to capture the ID from another property during deserialization. The attribute references the SOURCE property that carries the Xfer key/value pair.
Properties
Name | Type | Description |
---|---|---|
TargetPropertyName |
string |
The SOURCE identifier: either the CLR property name on the same type, or the exact document key. The decorated target property's type should be string (nullable allowed). |
Methods
Constructor
XferCaptureIdAttribute(string sourceName)
Initializes a new instance of the class.
Parameters
Name | Type | Description |
---|---|---|
sourceName |
string |
The SOURCE identifier to capture from: either a CLR property name on the same type (case-insensitive, honoring any [XferProperty] rename) or the exact document key. |
Class: XferCaptureTagAttribute
Apply this to the TAG TARGET property to capture tag(s) from another property during deserialization. The attribute references the SOURCE property that carries the Xfer key/value pair.
Properties
Name | Type | Description |
---|---|---|
TargetPropertyName |
string |
The SOURCE identifier: either the CLR property name on the same type, or the exact document key. The decorated target property's type should be string, List |
Methods
Constructor
XferCaptureTagAttribute(string sourceName)
Initializes a new instance of the class.
Parameters
Name | Type | Description |
---|---|---|
sourceName |
string |
The SOURCE identifier to capture from: either a CLR property name on the same type (case-insensitive, honoring any [XferProperty] rename) or the exact document key. |
Class: XferDecimalPrecisionAttribute
Specifies the maximum number of decimal places to display when serializing decimal and double values to XferLang. This attribute only affects the string representation and does not modify the underlying value.
Properties
Name | Type | Description |
---|---|---|
DecimalPlaces |
int |
The maximum number of decimal places to display. |
RemoveTrailingZeros |
bool |
Whether to remove trailing zeros after the decimal point. Default is true. |
Methods
Constructor
XferDecimalPrecisionAttribute(int decimalPlaces)
Initializes a new instance of the XferDecimalPrecisionAttribute.
Parameters
Name | Type | Description |
---|---|---|
decimalPlaces |
int |
The maximum number of decimal places to display. Must be 0 or greater. |
Class: XferEvaluatedAttribute
Indicates that a property should be serialized as an evaluated element in XferLang. Evaluated elements use angle bracket delimiters and their content is processed for dynamic content, variable substitution, or expressions during serialization.
Methods
Constructor
XferEvaluatedAttribute()
Enum: XferNumericFormat
Specifies the format for numeric serialization in XferLang.
Members
Name | Value | Description |
---|---|---|
Binary |
3 |
Serialize as binary with prefix: #%00101010 |
Decimal |
1 |
Serialize as decimal number: 42 |
Default |
0 |
Use default format based on settings and type (implicit for int, compact for others). |
Hexadecimal |
2 |
Serialize as hexadecimal with prefix: #$2A |
Class: XferNumericFormatAttribute
Specifies how a numeric property should be formatted when serialized to XferLang.
Properties
Name | Type | Description |
---|---|---|
Format |
XferNumericFormat |
The format to use for numeric serialization. |
MinBits |
int |
For binary format, specifies the minimum number of bits to display. Default is to use the minimum required bits. |
MinDigits |
int |
For hex format, specifies the minimum number of hex digits to display. Default is to use the minimum required digits. |
Methods
Constructor
XferNumericFormatAttribute(XferNumericFormat format)
Initializes a new instance of the XferNumericFormatAttribute.
Parameters
Name | Type | Description |
---|---|---|
format |
XferNumericFormat |
The numeric format to use. |
Class: XferPropertyAttribute
Specifies the XferLang property name for a .NET property during serialization and deserialization. When applied to a property, it overrides the default property name mapping behavior.
Properties
Name | Type | Description |
---|---|---|
Name |
string |
Gets or sets the custom name to use for this property in XferLang serialization. If null or not specified, the property's actual name will be used. |
Methods
Constructor
XferPropertyAttribute(string name)
Initializes a new instance of the class.
Parameters
Name | Type | Description |
---|---|---|
name |
string |
The custom name to use for this property, or null to use the property's actual name. |
Namespace: ParksComputing.Xfer.Lang.CharDef
Class: CharDefProcessor
Handles charDef PI processing and efficient lookup for CharacterElements. Register with Parser.RegisterPIProcessor and RegisterElementProcessor.
Methods
Constructor
CharDefProcessor()
ElementHandler
void ElementHandler(Element element)
Handles element processing for character definitions. Currently a no-op implementation as character definitions are processed via processing instructions.
Parameters
Name | Type | Description |
---|---|---|
element |
Element |
The element to process |
PIHandler
void PIHandler(KeyValuePairElement charDefKvp)
Handles processing instruction elements for character definitions. Updates the global character registry with custom character mappings from the PI.
Parameters
Name | Type | Description |
---|---|---|
charDefKvp |
KeyValuePairElement |
The key-value pair element containing character definition data |
UpdateGlobalRegistryFromPI
void UpdateGlobalRegistryFromPI(KeyValuePairElement charDefKvp)
Update the global charDef registry with a charDef PI object.
Namespace: ParksComputing.Xfer.Lang.Configuration
Enum: ElementStylePreference
Defines preferences for element serialization styles.
Members
Name | Value | Description |
---|---|---|
CompactWhenSafe |
1 |
Use compact style when safe, explicit when necessary. Strings use quotes: "value" (when safe) |
Explicit |
0 |
Use explicit style for maximum safety and compatibility (default). Strings use angle brackets: <"value"> |
ForceCompact |
3 |
Always use compact style, even if potentially unsafe. Use with caution - may produce unparseable output. |
MinimalWhenSafe |
2 |
Use most compact form possible, including implicit syntax. Integers without # prefix, strings without quotes when possible. |
Enum: NullValueHandling
Specifies how null values should be handled during XferLang serialization.
Members
Name | Value | Description |
---|---|---|
Ignore |
1 |
Ignore (exclude) null values from the serialized output. |
Include |
0 |
Include null values in the serialized output. |
Class: XferProcessingInstruction
Represents a processing instruction in an XferLang document.
Properties
Name | Type | Description |
---|---|---|
AppliesTo |
Element |
Reference to the element this PI applies to (if any). |
DocumentIndex |
int |
Optional: position of the PI in the document. |
Parameters |
Dictionary<string, Object> |
Parameters for the processing instruction, as parsed from the document. |
Type |
string |
The type or name of the processing instruction (e.g., "processor", "id", "culture"). |
Methods
Constructor
XferProcessingInstruction()
Class: XferSerializerSettings
Configuration settings for XferLang serialization and deserialization. Controls how .NET objects are converted to/from XferLang format, including null handling, contract resolution, custom converters, and element styling preferences.
Properties
Name | Type | Description |
---|---|---|
ContractResolver |
IContractResolver |
The contract resolver used to determine which properties to serialize and how to resolve property names during serialization. |
Converters |
IList<IXferConverter> |
Collection of custom converters for handling specific types during serialization. Converters are checked in order and the first matching converter is used. |
NullValueHandling |
NullValueHandling |
Specifies how null values are handled during serialization. Controls whether null properties are included or excluded from the output. |
PreferImplicitSyntax |
bool |
When StylePreference allows it, prefer implicit syntax for simple values. For example, serialize integers as "42" instead of "#42". |
PreserveDateTimePrecision |
bool |
When true, DateTime values preserve original precision instead of adding microseconds. Helps maintain round-trip consistency with original documents. |
StylePreference |
ElementStylePreference |
Controls how elements are serialized for compactness vs safety. Default is CompactWhenSafe for optimal balance of safety and readability. |
Methods
Constructor
XferSerializerSettings()
Namespace: ParksComputing.Xfer.Lang.ContractResolvers
Class: DefaultContractResolver
Default implementation of contract resolution for XferLang serialization. Resolves public instance properties and preserves original property names without modification. Provides the standard behavior for most serialization scenarios.
Methods
Constructor
DefaultContractResolver()
ResolveProperties
List<PropertyInfo> ResolveProperties(Type type)
Resolves all public instance properties of the specified type for serialization.
Parameters
Name | Type | Description |
---|---|---|
type |
Type |
The type to resolve properties for. |
Returns
A list of all public instance properties.
ResolvePropertyName
string ResolvePropertyName(string propertyName)
Returns the property name unchanged. Override to implement custom name transformation.
Parameters
Name | Type | Description |
---|---|---|
propertyName |
string |
The original property name. |
Returns
The unmodified property name.
Interface: IContractResolver
Defines contract resolution for XferLang serialization. Contract resolvers determine which properties to serialize and how property names should be transformed during the serialization process.
Methods
ResolveProperties
List<PropertyInfo> ResolveProperties(Type type)
Resolves which properties of a type should be included in serialization. Returns a list of PropertyInfo objects representing the properties to serialize.
Parameters
Name | Type | Description |
---|---|---|
type |
Type |
The type to resolve properties for. |
Returns
A list of properties to include in serialization.
ResolvePropertyName
string ResolvePropertyName(string propertyName)
Resolves the name to use for a property during serialization. Allows transformation of property names (e.g., camelCase conversion).
Parameters
Name | Type | Description |
---|---|---|
propertyName |
string |
The original property name. |
Returns
The transformed property name to use in the serialized output.
Namespace: ParksComputing.Xfer.Lang.Converters
Interface: IXferConverter
Defines custom conversion logic for XferLang serialization and deserialization. Custom converters enable specialized handling of specific types during the conversion process between .NET objects and XferLang elements.
Methods
CanConvert
bool CanConvert(Type objectType)
Determines whether this converter can handle the specified object type.
Parameters
Name | Type | Description |
---|---|---|
objectType |
Type |
The type to check for conversion support. |
Returns
True if this converter can handle the type; otherwise, false.
ReadXfer
Object ReadXfer(Element element, Type objectType, XferSerializerSettings settings)
Converts a XferLang element back to a .NET object during deserialization.
Parameters
Name | Type | Description |
---|---|---|
element |
Element |
The XferLang element to convert. |
objectType |
Type |
The target .NET type to convert to. |
settings |
XferSerializerSettings |
Serializer settings to control conversion behavior. |
Returns
The deserialized .NET object, or null if conversion fails.
WriteXfer
Element WriteXfer(Object value, XferSerializerSettings settings)
Converts a .NET object to a XferLang element during serialization.
Parameters
Name | Type | Description |
---|---|---|
value |
Object |
The object to convert. |
settings |
XferSerializerSettings |
Serializer settings to control conversion behavior. |
Returns
The XferLang element representation of the object.
Abstract Class: XferConverter<T>
Abstract base class for type-specific XferLang converters. Provides a strongly-typed foundation for implementing custom conversion logic for specific .NET types during XferLang serialization and deserialization.
Methods
CanConvert
bool CanConvert(Type objectType)
Determines if this converter can handle the specified object type. By default, returns true if the type is assignable from T.
Parameters
Name | Type | Description |
---|---|---|
objectType |
Type |
The type to check for conversion support. |
Returns
True if the type can be converted; otherwise, false.
ReadXfer
Object ReadXfer(Element element, Type objectType, XferSerializerSettings settings)
Converts a XferLang element to an object. Calls the strongly-typed ReadXfer method.
Parameters
Name | Type | Description |
---|---|---|
element |
Element |
The XferLang element to convert. |
objectType |
Type |
The target object type. |
settings |
XferSerializerSettings |
Serializer settings to control conversion behavior. |
Returns
The deserialized object.
ReadXfer
T ReadXfer(Element element, XferSerializerSettings settings)
Converts a XferLang element to a strongly-typed value. Implement this method to provide custom deserialization logic for type T.
Parameters
Name | Type | Description |
---|---|---|
element |
Element |
The XferLang element to convert. |
settings |
XferSerializerSettings |
Serializer settings to control conversion behavior. |
Returns
The deserialized value of type T, or null if conversion fails.
WriteXfer
Element WriteXfer(Object value, XferSerializerSettings settings)
Converts an object to a XferLang element. Calls the strongly-typed WriteXfer method.
Parameters
Name | Type | Description |
---|---|---|
value |
Object |
The object to convert. |
settings |
XferSerializerSettings |
Serializer settings to control conversion behavior. |
Returns
The XferLang element representation.
WriteXfer
Element WriteXfer(T value, XferSerializerSettings settings)
Namespace: ParksComputing.Xfer.Lang.DynamicSource
Class: DefaultDynamicSourceResolver
Default implementation of dynamic source resolution for XferLang. Resolves dynamic values from files, environment variables, constants, and the dynamic source registry. Provides backward compatibility with legacy dynamic source processing instructions.
Methods
Constructor
DefaultDynamicSourceResolver()
Resolve
string Resolve(string key, XferDocument document)
Resolves a dynamic value for the given key using the dynamic source registry and legacy processing instructions. First attempts to resolve from the new DynamicSourceRegistry, then falls back to legacy PI scanning for backward compatibility.
Parameters
Name | Type | Description |
---|---|---|
key |
string |
The dynamic key to resolve |
document |
XferDocument |
The parsed XferDocument containing processing instructions |
Returns
The resolved value, or null if not found
Interface: IDynamicSourceResolver
Interface for resolving dynamic values in XferLang documents. Implementations can resolve dynamic keys using processing instructions or other mechanisms.
Methods
Resolve
string Resolve(string key, XferDocument document)
Resolves a dynamic value for the given key using PI directives in the document.
Parameters
Name | Type | Description |
---|---|---|
key |
string |
The dynamic key to resolve. |
document |
XferDocument |
The parsed XferDocument. |
Returns
The resolved value, or null if not found.
Namespace: ParksComputing.Xfer.Lang.Elements
Class: ArrayElement
Represents an array element in XferLang, containing an ordered collection of elements enclosed in square brackets []. Arrays can contain elements of any type and maintain insertion order. This class extends ListElement to provide array-specific functionality including type tracking and validation.
Properties
Name | Type | Description |
---|---|---|
ElementType |
Type |
Gets the element type for this homogeneous array, or null if empty. |
Item |
Element |
Methods
Constructor
ArrayElement(ElementStyle style)
Initializes a new instance of the ArrayElement class with the specified element style.
Parameters
Name | Type | Description |
---|---|---|
style |
ElementStyle |
The element style for delimiter handling |
Constructor
ArrayElement(IEnumerable<Element> values)
Initializes a new instance of the ArrayElement class with a collection of elements. Elements are added with type validation to maintain homogeneous typing.
Parameters
Name | Type | Description |
---|---|---|
values |
IEnumerable<Element> |
The elements to add to the array |
Constructor
ArrayElement(Element[] values)
Initializes a new instance of the ArrayElement class with a variable number of elements. Elements are added with type validation to maintain homogeneous typing.
Parameters
Name | Type | Description |
---|---|---|
values |
Element[] |
The elements to add to the array |
Add
bool Add(Element element)
Adds an element to this array with type validation. Enforces homogeneous typing - all elements must be the same type after the first element is added. Processing instructions and comments are added to the children collection without type checking.
Parameters
Name | Type | Description |
---|---|---|
element |
Element |
The element to add to the array |
Returns
True if the element was added successfully, false if type validation failed
Remove
bool Remove(Element element)
Removes the specified element from this array. If this was the last element and it's removed, the element type constraint is reset.
Parameters
Name | Type | Description |
---|---|---|
element |
Element |
The element to remove |
Returns
True if the element was found and removed, false otherwise
RemoveAllChildren
int RemoveAllChildren()
Removes all child elements from this array. Resets the element type constraint when the array becomes empty.
Returns
The number of children that were removed
RemoveAt
bool RemoveAt(int index)
Removes the element at the specified index. If this was the last element and it's removed, the element type constraint is reset.
Parameters
Name | Type | Description |
---|---|---|
index |
int |
The zero-based index of the element to remove |
Returns
True if the element was found and removed, false otherwise
ToString
string ToString()
Returns a string representation of this array element using its XferLang serialization.
Returns
The string representation of this array element
ToXfer
string ToXfer()
Serializes this array element to its XferLang string representation using default formatting.
Returns
The XferLang string representation of this array element
ToXfer
string ToXfer(Formatting formatting, Char indentChar, int indentation, int depth)
Serializes this array element to its XferLang string representation with specified formatting. Uses square bracket delimiters and applies proper indentation for nested elements.
Parameters
Name | Type | Description |
---|---|---|
formatting |
Formatting |
The formatting style to apply during serialization |
indentChar |
Char |
The character to use for indentation (default: space) |
indentation |
int |
The number of indentation characters per level (default: 2) |
depth |
int |
The current nesting depth for indentation calculation (default: 0) |
Returns
The XferLang string representation of this array element
Class: BooleanElement
Represents a boolean element in XferLang using tilde (~) delimiters. Boolean elements store true/false values and are rendered as "true" or "false" in the XferLang format. The compact style uses ~ delimiters by default.
Methods
Constructor
BooleanElement(bool value, int specifierCount, ElementStyle style)
Initializes a new BooleanElement with the specified value and formatting options.
Parameters
Name | Type | Description |
---|---|---|
value |
bool |
The boolean value to store. |
specifierCount |
int |
The number of delimiter characters to use (default: 1). |
style |
ElementStyle |
The element style for formatting (default: Compact). |
ToString
string ToString()
Returns the string representation of the boolean value.
Returns
The boolean value as a string.
ToXfer
string ToXfer()
Converts the boolean element to its XferLang string representation without formatting.
Returns
The XferLang string representation of the boolean value.
ToXfer
string ToXfer(Formatting formatting, Char indentChar, int indentation, int depth)
Converts the boolean element to its XferLang string representation with formatting options.
Parameters
Name | Type | Description |
---|---|---|
formatting |
Formatting |
The formatting style to apply. |
indentChar |
Char |
The character to use for indentation. |
indentation |
int |
The number of indent characters per level. |
depth |
int |
The current indentation depth. |
Returns
The formatted XferLang string representation of the boolean value.
Class: CharacterElement
Represents a character element in XferLang using backslash (\) delimiters. Character elements store Unicode code points as integers and can represent any valid Unicode character. The value represents the numeric code point (0 to 0x10FFFF) rather than the character itself.
Properties
Name | Type | Description |
---|---|---|
NumericValue |
NumericValue<int> |
Gets or sets the underlying numeric value (code point) plus its base information. Setting updates the exposed . |
Methods
Constructor
CharacterElement(int codePoint, int specifierCount, ElementStyle style)
Initializes a new CharacterElement with the specified Unicode code point and formatting options.
Parameters
Name | Type | Description |
---|---|---|
codePoint |
int |
The Unicode code point to store (0 to 0x10FFFF). |
specifierCount |
int |
The number of delimiter characters to use (default: 1). |
style |
ElementStyle |
The element style for formatting (default: Compact). |
Constructor
CharacterElement(NumericValue<int> numericValue, int specifierCount, ElementStyle style)
Initializes a new character element from an existing code point wrapper.
Parameters
Name | Type | Description |
---|---|---|
numericValue |
NumericValue<int> |
The numeric value wrapper containing the code point and base. |
specifierCount |
int |
Number of delimiter characters to use (default 1). |
style |
ElementStyle |
The element style (Compact or Explicit). |
ToString
string ToString()
Returns the Unicode character represented by this code point.
Returns
The Unicode character as a string.
ToXfer
string ToXfer()
Converts the character element to its XferLang string representation without formatting.
Returns
The XferLang string representation of the Unicode code point.
ToXfer
string ToXfer(Formatting formatting, Char indentChar, int indentation, int depth)
Converts the character element to its XferLang string representation with formatting options.
Parameters
Name | Type | Description |
---|---|---|
formatting |
Formatting |
The formatting style to apply. |
indentChar |
Char |
The character to use for indentation. |
indentation |
int |
The number of indent characters per level. |
depth |
int |
The current indentation depth. |
Returns
The formatted XferLang string representation of the Unicode code point.
Abstract Class: CollectionElement
Abstract base class for elements that contain collections of other elements. Provides common functionality for array-like and object-like elements that store multiple child elements with appropriate indexing and enumeration capabilities.
Properties
Name | Type | Description |
---|---|---|
Count |
int |
Gets the number of elements in this collection. |
ParsedValue |
Object |
Gets the parsed value of this collection element, which is the collection of child elements. For collections, this returns the Values enumerable. |
Values |
IEnumerable<Element> |
Gets an enumerable view of all elements in this collection. |
Methods
Add
bool Add(Element element)
Adds an element to this collection.
Parameters
Name | Type | Description |
---|---|---|
element |
Element |
The element to add to the collection. |
Returns
True if the element was successfully added; otherwise, false.
GetElementAt
Element GetElementAt(int index)
Retrieves the element at the specified index in the collection.
Parameters
Name | Type | Description |
---|---|---|
index |
int |
The zero-based index of the element to retrieve. |
Returns
The element at the specified index, or null if the index is out of range.
Class: CommentElement
Represents a comment element in XferLang using forward slash (/) delimiters. Comments are non-semantic elements that provide documentation or annotations but are not included in the actual data output. They are preserved during parsing but excluded from serialization.
Methods
Constructor
CommentElement()
Initializes a new instance of the CommentElement class.
ToString
string ToString()
Returns a string representation of this comment element.
Returns
An empty string
ToXfer
string ToXfer()
Serializes this comment element to its XferLang string representation.
Returns
An empty string, as comments are excluded from serialization output
ToXfer
string ToXfer(Formatting formatting, Char indentChar, int indentation, int depth)
Serializes this comment element to its XferLang string representation with formatting options.
Parameters
Name | Type | Description |
---|---|---|
formatting |
Formatting |
The formatting style (ignored for comments) |
indentChar |
Char |
The indentation character (ignored for comments) |
indentation |
int |
The indentation level (ignored for comments) |
depth |
int |
The nesting depth (ignored for comments) |
Returns
An empty string, as comments are excluded from serialization output
Class: DateElement
Represents a date-only element in XferLang using pipe (|) delimiters. Date elements store DateOnly values and support various formatting options through the DateTimeHandling property. This is used for date values without time components.
Properties
Name | Type | Description |
---|---|---|
DateTimeHandling |
DateTimeHandling |
Gets or sets how the date value is formatted during serialization. Controls UTC, Local, Unspecified, or RoundTrip formatting modes. |
Methods
Constructor
DateElement(DateTimeHandling dateTimeHandling, int specifierCount, ElementStyle elementStyle)
Initializes a new instance of the DateElement class with the current date and specified formatting options.
Parameters
Name | Type | Description |
---|---|---|
dateTimeHandling |
DateTimeHandling |
How to handle date serialization (default: RoundTrip) |
specifierCount |
int |
The number of delimiter characters to use (default: 1) |
elementStyle |
ElementStyle |
The element style for delimiter handling (default: Compact) |
Constructor
DateElement(string stringValue, DateTimeHandling dateTimeHandling, int specifierCount, ElementStyle elementStyle)
Initializes a new instance of the DateElement class by parsing a date string.
Parameters
Name | Type | Description |
---|---|---|
stringValue |
string |
The date string to parse (must be in ISO 8601 format) |
dateTimeHandling |
DateTimeHandling |
How to handle date serialization (default: RoundTrip) |
specifierCount |
int |
The number of delimiter characters to use (default: 1) |
elementStyle |
ElementStyle |
The element style for delimiter handling (default: Compact) |
Constructor
DateElement(DateOnly dateOnly, DateTimeHandling dateTimeHandling, int specifierCount, ElementStyle elementStyle)
Initializes a new instance of the DateElement class with the specified DateOnly value and formatting options.
Parameters
Name | Type | Description |
---|---|---|
dateOnly |
DateOnly |
The DateOnly value to represent |
dateTimeHandling |
DateTimeHandling |
How to handle date serialization (default: RoundTrip) |
specifierCount |
int |
The number of delimiter characters to use (default: 1) |
elementStyle |
ElementStyle |
The element style for delimiter handling (default: Compact) |
FormatDate
string FormatDate(DateOnly dateValue, DateTimeHandling dateTimeHandling)
Formats a DateOnly value according to the specified DateTimeHandling strategy. Handles different formatting modes for date-only values.
Parameters
Name | Type | Description |
---|---|---|
dateValue |
DateOnly |
The DateOnly value to format |
dateTimeHandling |
DateTimeHandling |
The formatting strategy to apply |
Returns
The formatted date string
GetFormatString
string GetFormatString(DateTimeHandling dateTimeHandling)
Gets the appropriate format string for the specified DateTimeHandling strategy for date-only values. Returns ISO 8601 date formats for different handling modes.
Parameters
Name | Type | Description |
---|---|---|
dateTimeHandling |
DateTimeHandling |
The DateTimeHandling strategy |
Returns
A format string suitable for DateOnly.ToString() method
ToString
string ToString()
Returns a string representation of this date element using the configured DateTimeHandling strategy.
Returns
The formatted date string according to the DateTimeHandling setting
ToXfer
string ToXfer()
Serializes this date element to its XferLang string representation using default formatting.
Returns
The XferLang string representation of this date element
ToXfer
string ToXfer(Formatting formatting, Char indentChar, int indentation, int depth)
Serializes this date element to its XferLang string representation with specified formatting. Uses tilde delimiters and applies the configured DateTimeHandling strategy.
Parameters
Name | Type | Description |
---|---|---|
formatting |
Formatting |
The formatting style to apply during serialization |
indentChar |
Char |
The character to use for indentation (default: space) |
indentation |
int |
The number of indentation characters per level (default: 2) |
depth |
int |
The current nesting depth for indentation calculation (default: 0) |
Returns
The XferLang string representation of this date element
Class: DateTimeElement
Represents a date-time element in XferLang using at (@) delimiters. DateTime elements store DateTime values with support for various formatting and timezone handling options through the DateTimeHandling property.
Properties
Name | Type | Description |
---|---|---|
DateTimeHandling |
DateTimeHandling |
Gets or sets how the DateTime value is formatted during serialization. Controls UTC, Local, Unspecified, or RoundTrip formatting modes. |
Methods
Constructor
DateTimeElement(string stringValue, DateTimeHandling dateTimeHandling, int specifierCount, ElementStyle elementStyle)
Initializes a new instance of the DateTimeElement class by parsing a DateTime string.
Parameters
Name | Type | Description |
---|---|---|
stringValue |
string |
The DateTime string to parse (must be in ISO 8601 format) |
dateTimeHandling |
DateTimeHandling |
How to handle DateTime serialization (default: RoundTrip) |
specifierCount |
int |
The number of delimiter characters to use (default: 1) |
elementStyle |
ElementStyle |
The element style for delimiter handling (default: Compact) |
Constructor
DateTimeElement(TimeOnly timeOnly, DateTimeHandling dateTimeHandling, int specifierCount, ElementStyle elementStyle)
Initializes a new instance of the DateTimeElement class from a TimeOnly value. Creates a DateTime with today's date and the specified time.
Parameters
Name | Type | Description |
---|---|---|
timeOnly |
TimeOnly |
The TimeOnly value to convert to DateTime |
dateTimeHandling |
DateTimeHandling |
How to handle DateTime serialization (default: RoundTrip) |
specifierCount |
int |
The number of delimiter characters to use (default: 1) |
elementStyle |
ElementStyle |
The element style for delimiter handling (default: Compact) |
Constructor
DateTimeElement(DateTime dateValue, DateTimeHandling dateTimeHandling, int specifierCount, ElementStyle elementStyle)
Initializes a new instance of the DateTimeElement class with the specified DateTime value and formatting options.
Parameters
Name | Type | Description |
---|---|---|
dateValue |
DateTime |
The DateTime value to represent |
dateTimeHandling |
DateTimeHandling |
How to handle DateTime serialization (default: RoundTrip) |
specifierCount |
int |
The number of delimiter characters to use (default: 1) |
elementStyle |
ElementStyle |
The element style for delimiter handling (default: Compact) |
FormatDate
string FormatDate(DateTime dateValue, DateTimeHandling dateTimeHandling)
Formats a DateTime value according to the specified DateTimeHandling strategy. Handles UTC, Local, Unspecified, and RoundTrip formatting modes.
Parameters
Name | Type | Description |
---|---|---|
dateValue |
DateTime |
The DateTime value to format |
dateTimeHandling |
DateTimeHandling |
The formatting strategy to apply |
Returns
The formatted DateTime string
GetFormatString
string GetFormatString(DateTimeHandling dateTimeHandling)
Gets the appropriate format string for the specified DateTimeHandling strategy. Returns ISO 8601 formats for different DateTime handling modes.
Parameters
Name | Type | Description |
---|---|---|
dateTimeHandling |
DateTimeHandling |
The DateTimeHandling strategy |
Returns
A format string suitable for DateTime.ToString() method
ToString
string ToString()
Returns a string representation of this DateTime element using the configured DateTimeHandling strategy.
Returns
The formatted DateTime string according to the DateTimeHandling setting
ToXfer
string ToXfer()
Serializes this DateTime element to its XferLang string representation using default formatting.
Returns
The XferLang string representation of this DateTime element
ToXfer
string ToXfer(Formatting formatting, Char indentChar, int indentation, int depth)
Serializes this DateTime element to its XferLang string representation with specified formatting. Uses tilde delimiters and applies the configured DateTimeHandling strategy.
Parameters
Name | Type | Description |
---|---|---|
formatting |
Formatting |
The formatting style to apply during serialization |
indentChar |
Char |
The character to use for indentation (default: space) |
indentation |
int |
The number of indentation characters per level (default: 2) |
depth |
int |
The current nesting depth for indentation calculation (default: 0) |
Returns
The XferLang string representation of this DateTime element
Class: DecimalElement
Represents a decimal number element in XferLang using asterisk (*) delimiters. Attribute metadata can control precision, trailing zeros, and alternative bases (hex/binary).
Methods
Constructor
DecimalElement(decimal value, int specifierCount, ElementStyle style)
Initializes a new instance of the DecimalElement class with the specified value and formatting options.
Parameters
Name | Type | Description |
---|---|---|
value |
decimal |
The decimal value to represent |
specifierCount |
int |
The number of delimiter characters to use (default: 1) |
style |
ElementStyle |
The element style for delimiter handling (default: Compact) |
Constructor
DecimalElement(NumericValue<decimal> numericValue, int specifierCount, ElementStyle style)
Initializes a new instance of using a wrapper to carry formatting metadata.
Parameters
Name | Type | Description |
---|---|---|
numericValue |
NumericValue<decimal> |
The wrapped decimal value including formatting metadata. |
specifierCount |
int |
The number of delimiter specifier characters to use. |
style |
ElementStyle |
The delimiter style. |
ToXfer
string ToXfer(Formatting formatting, Char indentChar, int indentation, int depth)
Serializes this decimal element to its XferLang string representation. Uses asterisk delimiters and applies custom formatting if specified.
Parameters
Name | Type | Description |
---|---|---|
formatting |
Formatting |
The formatting style to apply during serialization |
indentChar |
Char |
The character to use for indentation (default: space) |
indentation |
int |
The number of indentation characters per level (default: 2) |
depth |
int |
The current nesting depth for indentation calculation (default: 0) |
Returns
The XferLang string representation of this decimal element
Abstract Class: DictionaryElement
Abstract base class representing a dictionary-based collection element in XferLang. Manages key-value pair collections with efficient key-based lookups. Non-semantic elements (processing instructions, comments) are stored separately from key-value pairs.
Properties
Name | Type | Description |
---|---|---|
Count |
int |
Gets the number of key-value pairs in this dictionary (excludes processing instructions and comments). |
Values |
IEnumerable<Element> |
Gets an enumerable view of all key-value pair elements in this dictionary. |
Methods
Add
void Add(string key, KeyValuePairElement value)
Add a semantic key-value pair. Non-semantic elements (PIs/comments) should be added to Children only.
Add
bool Add(Element element)
Adds an element to this dictionary. Supports key-value pairs and non-semantic elements. Key-value pairs are added to the dictionary, while processing instructions and comments are added only to the children collection.
Parameters
Name | Type | Description |
---|---|---|
element |
Element |
The element to add |
Returns
True if the element was added successfully, false if it was a duplicate key-value pair
GetElementAt
Element GetElementAt(int index)
Gets the key-value pair element at the specified index, or null if the index is out of bounds.
Parameters
Name | Type | Description |
---|---|---|
index |
int |
The zero-based index of the element to retrieve |
Returns
The key-value pair element at the specified index, or null if index is invalid
GetValue
Element GetValue(string key)
Get a semantic value by key (returns null if not found)
ToString
string ToString()
Returns a string representation of this dictionary by serializing all key-value pairs.
Returns
A space-separated string of all key-value pairs in the dictionary
Class: DoubleElement
Represents a double-precision floating-point number element in XferLang using caret (^) delimiters. Attribute metadata can control precision, trailing zeros, and alternative bases (hex/binary).
Methods
Constructor
DoubleElement(double value, int specifierCount, ElementStyle style)
Initializes a new instance of the DoubleElement class with the specified value and formatting options.
Parameters
Name | Type | Description |
---|---|---|
value |
double |
The double-precision floating-point value to represent |
specifierCount |
int |
The number of delimiter characters to use (default: 1) |
style |
ElementStyle |
The element style for delimiter handling (default: Compact) |
Constructor
DoubleElement(NumericValue<double> numericValue, int specifierCount, ElementStyle style)
Initializes a new instance of the DoubleElement class with the specified numeric value. The numeric value to represent as a doubleThe number of delimiter characters to use (default: 1)The element style for delimiter handling (default: Compact)
ToXfer
string ToXfer(Formatting formatting, Char indentChar, int indentation, int depth)
Serializes this double element to its XferLang string representation. Uses caret delimiters and applies custom formatting if specified.
Parameters
Name | Type | Description |
---|---|---|
formatting |
Formatting |
The formatting style to apply during serialization |
indentChar |
Char |
The character to use for indentation (default: space) |
indentation |
int |
The number of indentation characters per level (default: 2) |
depth |
int |
The current nesting depth for indentation calculation (default: 0) |
Returns
The XferLang string representation of this double element
Class: DynamicElement
Represents a dynamic element in XferLang using pipe (|) delimiters. Dynamic elements contain text that can be dynamically resolved or evaluated at runtime, often used for variable substitution or dynamic content generation.
Properties
Name | Type | Description |
---|---|---|
ParsedValue |
Object |
Gets the parsed value of this dynamic element, which is the resolved value. For dynamic elements, this returns the already-resolved Value. Returns null if the dynamic element resolved to an empty or null value. For setting, use the Value property to set the resolved value. |
Methods
Constructor
DynamicElement(string text, int specifierCount, ElementStyle style)
Initializes a new instance of the DynamicElement class with the specified text and formatting options.
Parameters
Name | Type | Description |
---|---|---|
text |
string |
The dynamic text content that can be resolved at runtime |
specifierCount |
int |
The number of delimiter characters to use (default: 1) |
style |
ElementStyle |
The element style for delimiter handling (default: Compact) |
Abstract Class: Element
The abstract base class for all XferLang elements. Provides common functionality for element hierarchies, metadata, IDs, and serialization.
Properties
Name | Type | Description |
---|---|---|
Children |
List<Element> |
Gets the collection of child elements contained within this element. |
Delimiter |
ElementDelimiter |
Gets or sets the delimiter information for this element, including opening/closing characters and style. |
FirstChild |
Element |
Gets the first child element, or null if this element has no children. |
Id |
string |
Optional ID for this element, settable via inline PI: |
LastChild |
Element |
Gets the last child element, or null if this element has no children. |
Name |
string |
Gets the name of this element type. |
NextSibling |
Element |
Gets the next sibling element in the parent's children collection. |
Parent |
Element |
Gets or sets the parent element of this element in the document hierarchy. |
ParsedValue |
Object |
Optional parsed value associated with this element (e.g., a numeric primitive after lexical analysis). Implementations may set during parsing for faster scripting/operator evaluation. |
PreviousSibling |
Element |
Gets the previous sibling element in the parent's children collection. |
Tags |
List<string> |
Optional tags for this element, set via inline PI(s): . Tags allow non-unique categorization and multiple tags may be applied to a single element. |
Methods
Constructor
Element(string name, ElementDelimiter delimiter)
Initializes a new instance of the class.
Parameters
Name | Type | Description |
---|---|---|
name |
string |
The name of the element type. |
delimiter |
ElementDelimiter |
The delimiter information for this element. |
AddChild
void AddChild(Element child)
Adds a child element to this element's children collection. Automatically sets the parent relationship and prevents duplicate additions.
Parameters
Name | Type | Description |
---|---|---|
child |
Element |
The child element to add |
FindElementById
Element FindElementById(string id)
Recursively finds the first descendant element with the specified ID.
Parameters
Name | Type | Description |
---|---|---|
id |
string |
The ID to search for. |
Returns
The found element, or null if no element is found.
FindElementsByTag
IReadOnlyCollection<Element> FindElementsByTag(string tag)
Recursively finds all descendant elements with the specified tag.
Parameters
Name | Type | Description |
---|---|---|
tag |
string |
The tag to search for. |
Returns
A collection of elements that have the specified tag.
FindElementsByType
IReadOnlyCollection<T> FindElementsByType()
Recursively finds all descendant elements of the specified type.
Returns
A collection of elements of the specified type.
FindElementsByType
IReadOnlyCollection<Element> FindElementsByType(Type elementType)
Recursively finds all descendant elements of the specified type.
Parameters
Name | Type | Description |
---|---|---|
elementType |
Type |
The element type to search for. |
Returns
A collection of elements of the specified type.
GetAncestors
IEnumerable<Element> GetAncestors()
Gets all ancestor elements from parent up to the root.
Returns
A collection of ancestor elements, ordered from immediate parent to root.
GetDescendants
IEnumerable<Element> GetDescendants()
Gets all descendant elements in depth-first order.
Returns
A collection of all descendant elements.
GetSiblings
IEnumerable<Element> GetSiblings()
Gets all sibling elements (excluding this element).
Returns
A collection of sibling elements.
Remove
bool Remove()
Removes this element from its parent element. DOM-like removal that handles parent-child relationship cleanup.
Returns
True if the element was successfully removed, false if it had no parent
RemoveAllChildren
int RemoveAllChildren()
Removes all child elements from this element's children collection. Automatically clears parent relationships for all removed children.
Returns
The number of children that were removed
RemoveChild
bool RemoveChild(Element child)
Removes a specific child element from this element's children collection. Automatically clears the parent relationship.
Parameters
Name | Type | Description |
---|---|---|
child |
Element |
The child element to remove |
Returns
True if the child was found and removed, false otherwise
RemoveChildAt
bool RemoveChildAt(int index)
Removes a child element at the specified index from this element's children collection. Automatically clears the parent relationship.
Parameters
Name | Type | Description |
---|---|---|
index |
int |
The zero-based index of the child to remove |
Returns
True if the child was successfully removed, false if index was out of range
ReplaceChild
bool ReplaceChild(Element oldChild, Element newChild)
Replaces a child element with a new element. Automatically manages parent-child relationships.
Parameters
Name | Type | Description |
---|---|---|
oldChild |
Element |
The existing child element to replace |
newChild |
Element |
The new child element to add in its place |
Returns
True if the replacement was successful, false if oldChild was not found
ToXfer
string ToXfer()
Serializes this element to its XferLang string representation using default formatting.
Returns
The XferLang string representation of this element
ToXfer
string ToXfer(Formatting formatting, Char indentChar, int indentation, int depth)
Serializes this element to its XferLang string representation with specified formatting options.
Parameters
Name | Type | Description |
---|---|---|
formatting |
Formatting |
The formatting style to apply during serialization |
indentChar |
Char |
The character to use for indentation (default: space) |
indentation |
int |
The number of indentation characters per level (default: 2) |
depth |
int |
The current nesting depth for indentation calculation (default: 0) |
Returns
The XferLang string representation of this element
Class: ElementDelimiter
Represents the delimiter information for an XferLang element, including opening/closing characters, specifier count, and element style. This class manages the construction of element delimiters for different serialization styles.
Properties
Name | Type | Description |
---|---|---|
ClosingSpecifier |
Char |
Gets the character used to close this element type. |
CompactClosing |
string |
Gets the minimal closing delimiter string without angle brackets. |
CompactOpening |
string |
Gets the minimal opening delimiter string without angle brackets. |
ExplicitClosing |
string |
Gets the full closing delimiter string including angle brackets. |
ExplicitOpening |
string |
Gets the full opening delimiter string including angle brackets. |
ImplicitClosing |
string |
Gets the implicit closing delimiter string, which is empty by default. |
ImplicitOpening |
string |
Gets the implicit opening delimiter string, which is empty by default. |
OpeningSpecifier |
Char |
Gets the character used to open this element type. |
SpecifierCount |
int |
Gets or sets the number of specifier characters to repeat in the delimiter. Setting this value updates the Opening, Closing, MinOpening, and MinClosing properties. |
Style |
ElementStyle |
Gets or sets the style of this element (Explicit, Compact, or Implicit). |
Methods
Constructor
ElementDelimiter()
Initializes a new instance of the ElementDelimiter class with default values. Uses null characters and a specifier count of 1.
Constructor
ElementDelimiter(int specifierCount)
Initializes a new instance of the ElementDelimiter class with the specified specifier count. Uses null characters for the opening and closing specifiers.
Parameters
Name | Type | Description |
---|---|---|
specifierCount |
int |
The number of delimiter characters to use |
Constructor
ElementDelimiter(Char openingSpecifier, Char closingSpecifier, ElementStyle elementStyle)
Initializes a new instance of the ElementDelimiter class with the specified delimiter characters.
Parameters
Name | Type | Description |
---|---|---|
openingSpecifier |
Char |
The opening delimiter character |
closingSpecifier |
Char |
The closing delimiter character |
elementStyle |
ElementStyle |
The element style for delimiter handling (default: Compact) |
Constructor
ElementDelimiter(Char openingSpecifier, Char closingSpecifier, int specifierCount, ElementStyle style)
Initializes a new instance of the ElementDelimiter class with full configuration.
Parameters
Name | Type | Description |
---|---|---|
openingSpecifier |
Char |
The opening delimiter character |
closingSpecifier |
Char |
The closing delimiter character |
specifierCount |
int |
The number of delimiter characters to use |
style |
ElementStyle |
The element style for delimiter handling (default: Compact) |
ToString
string ToString()
Returns a string representation of this delimiter showing the opening and closing patterns.
Returns
A string in the format "Opening...Closing" showing the delimiter pattern
Enum: ElementStyle
Specifies the different styles in which XferLang elements can be written and parsed.
Members
Name | Value | Description |
---|---|---|
Compact |
1 |
Compact style with simplified delimiters and minimal whitespace. |
Explicit |
0 |
Explicit style with full element delimiters: |
Implicit |
2 |
Implicit style where element type is inferred from content format. |
Class: EmptyClosingElementDelimiter
Delimiter variant whose compact closing sequence is empty (used by dereference & numeric forms).
Properties
Name | Type | Description |
---|---|---|
CompactClosing |
string |
The closing delimiter character for integer elements. |
CompactOpening |
string |
The opening delimiter character for integer elements. |
Methods
Constructor
EmptyClosingElementDelimiter(Char openingSpecifier, Char closingSpecifier, ElementStyle style)
Create a delimiter with empty closing sequence and specifier count 1.
Parameters
Name | Type | Description |
---|---|---|
openingSpecifier |
Char |
Opening delimiter character. |
closingSpecifier |
Char |
Closing delimiter character (same as opening). |
style |
ElementStyle |
Delimiter style. |
Constructor
EmptyClosingElementDelimiter(Char openingSpecifier, Char closingSpecifier, int specifierCount, ElementStyle style)
Create a delimiter with an explicit specifier count.
Parameters
Name | Type | Description |
---|---|---|
openingSpecifier |
Char |
Opening delimiter character. |
closingSpecifier |
Char |
Closing delimiter character (same as opening). |
specifierCount |
int |
Number of specifier characters. |
style |
ElementStyle |
Delimiter style. |
Class: EmptyElement
Represents an empty element in XferLang that contains no value. Used for representing null or void values in the serialization format.
Properties
Name | Type | Description |
---|---|---|
Value |
string |
Gets the value of this empty element, which is always an empty string. |
Methods
Constructor
EmptyElement()
Initializes a new instance of the EmptyElement class.
ToString
string ToString()
Returns a string representation of this empty element.
Returns
An empty string
ToXfer
string ToXfer()
Serializes this empty element to its XferLang string representation.
Returns
An empty string, as empty elements have no serialized representation
ToXfer
string ToXfer(Formatting formatting, Char indentChar, int indentation, int depth)
Serializes this empty element to its XferLang string representation with formatting options.
Parameters
Name | Type | Description |
---|---|---|
formatting |
Formatting |
The formatting style (ignored for empty elements) |
indentChar |
Char |
The indentation character (ignored for empty elements) |
indentation |
int |
The indentation level (ignored for empty elements) |
depth |
int |
The nesting depth (ignored for empty elements) |
Returns
An empty string, as empty elements have no serialized representation
Class: IdentifierElement
Represents an identifier element in XferLang using colon (:) delimiters. Identifiers are used for variable names, property keys, and other symbolic references. They follow standard identifier naming rules (letters, digits, underscores, hyphens, dots) but must start with a letter or underscore.
Methods
Constructor
IdentifierElement(string text, int specifierCount, ElementStyle style)
Initializes a new instance of the IdentifierElement class with the specified text and formatting options.
Parameters
Name | Type | Description |
---|---|---|
text |
string |
The identifier text |
specifierCount |
int |
The number of delimiter characters to use (default: 1) |
style |
ElementStyle |
The element style for delimiter handling (default: Implicit) |
IsIdentifierLeadingChar
bool IsIdentifierLeadingChar(Char c)
Determines whether the specified character is valid as the first character of an identifier. Identifiers must start with a letter or underscore.
Parameters
Name | Type | Description |
---|---|---|
c |
Char |
The character to check |
Returns
True if the character can start an identifier, false otherwise
ToXfer
string ToXfer(Formatting formatting, Char indentChar, int indentation, int depth)
Serializes this identifier element to its XferLang string representation. Uses colon delimiters with style determined by identifier validation rules.
Parameters
Name | Type | Description |
---|---|---|
formatting |
Formatting |
The formatting style to apply during serialization |
indentChar |
Char |
The character to use for indentation (default: space) |
indentation |
int |
The number of indentation characters per level (default: 2) |
depth |
int |
The current nesting depth for indentation calculation (default: 0) |
Returns
The XferLang string representation of this identifier element
Class: IntegerElement
Represents a 32-bit signed integer element in XferLang. Uses hash (#) delimiters and supports attribute-driven hexadecimal or binary formatting.
Methods
Constructor
IntegerElement(int value, int specifierCount, ElementStyle elementStyle)
Initializes a new instance of the IntegerElement class with the specified value and formatting options.
Parameters
Name | Type | Description |
---|---|---|
value |
int |
The integer value to represent |
specifierCount |
int |
The number of delimiter characters to use (default: 1) |
elementStyle |
ElementStyle |
The element style for delimiter handling (default: Compact) |
Constructor
IntegerElement(NumericValue<int> value, int specifierCount, ElementStyle elementStyle)
Initializes a new instance of the IntegerElement class with the specified numeric value.
ToXfer
string ToXfer(Formatting formatting, Char indentChar, int indentation, int depth)
Serializes this integer element to its XferLang string representation. Uses hash delimiters and applies custom formatting if specified.
Parameters
Name | Type | Description |
---|---|---|
formatting |
Formatting |
The formatting style to apply during serialization |
indentChar |
Char |
The character to use for indentation (default: space) |
indentation |
int |
The number of indentation characters per level (default: 2) |
depth |
int |
The current nesting depth for indentation calculation (default: 0) |
Returns
The XferLang string representation of this integer element
Class: InterpolatedElement
Represents an interpolated string element in XferLang. Uses single quote (') delimiters and supports string interpolation with embedded expressions.
Methods
Constructor
InterpolatedElement(string text, int specifierCount, ElementStyle style)
Initializes a new instance of the InterpolatedElement class with the specified text and formatting options.
Parameters
Name | Type | Description |
---|---|---|
text |
string |
The interpolated string text with embedded expressions |
specifierCount |
int |
The number of delimiter characters to use (default: 1) |
style |
ElementStyle |
The element style for delimiter handling (default: Compact) |
Class: KeyValuePairElement
Represents a key-value pair element in XferLang, where the key is a text element and the value can be any element type. This is the fundamental building block for object properties and named elements in the XferLang format.
Properties
Name | Type | Description |
---|---|---|
Key |
string |
Gets the string representation of the key. |
KeyElement |
KeywordElement |
Gets or sets the keyword element that represents the key portion of the key-value pair. |
Value |
Element |
Gets or sets the value element of the key-value pair. |
Methods
Constructor
KeyValuePairElement(KeywordElement keyElement, int specifierCount)
Initializes a new instance of the KeyValuePairElement class with a keyword element and default empty value.
Parameters
Name | Type | Description |
---|---|---|
keyElement |
KeywordElement |
The keyword element representing the key. |
specifierCount |
int |
The number of delimiter characters to use. |
Constructor
KeyValuePairElement(KeywordElement keyElement, Element value, int specifierCount)
Initializes a new instance of the KeyValuePairElement class with a keyword element and value element.
Parameters
Name | Type | Description |
---|---|---|
keyElement |
KeywordElement |
The keyword element representing the key. |
value |
Element |
The element representing the value. |
specifierCount |
int |
The number of delimiter characters to use. |
ToString
string ToString()
Returns a string representation of the key-value pair element.
Returns
The XferLang representation of the key-value pair element.
ToXfer
string ToXfer()
Converts the key-value pair element to its XferLang string representation without formatting.
Returns
The XferLang representation of the key-value pair element.
ToXfer
string ToXfer(Formatting formatting, Char indentChar, int indentation, int depth)
Converts the key-value pair element to its XferLang string representation with specified formatting options.
Parameters
Name | Type | Description |
---|---|---|
formatting |
Formatting |
The formatting options to apply. |
indentChar |
Char |
The character to use for indentation (default is space). |
indentation |
int |
The number of indent characters per level (default is 2). |
depth |
int |
The current nesting depth (default is 0). |
Returns
The formatted XferLang representation of the key-value pair element.
Class: KeywordElement
Represents a keyword element in XferLang using equals (=) delimiters. Keywords are reserved words or language constructs that have special meaning in the XferLang syntax, such as data types, control structures, or built-in functions.
Methods
Constructor
KeywordElement(string text, int specifierCount, ElementStyle style)
Initializes a new instance of the KeywordElement class with the specified text and formatting options.
Parameters
Name | Type | Description |
---|---|---|
text |
string |
The keyword text. |
specifierCount |
int |
The number of delimiter characters to use. |
style |
ElementStyle |
The element style to apply (default is implicit). |
IsKeywordLeadingChar
bool IsKeywordLeadingChar(Char c)
Determines whether a character is valid as the leading character of a keyword. Keywords must start with a letter or underscore.
Parameters
Name | Type | Description |
---|---|---|
c |
Char |
The character to test. |
Returns
True if the character can start a keyword; otherwise, false.
ToXfer
string ToXfer(Formatting formatting, Char indentChar, int indentation, int depth)
Serializes this keyword element to its XferLang string representation. Keywords are represented with equals (=) delimiters using the keyword name followed by its value.
Parameters
Name | Type | Description |
---|---|---|
formatting |
Formatting |
The formatting style to apply during serialization |
indentChar |
Char |
The character to use for indentation (default: space) |
indentation |
int |
The number of indentation characters per level (default: 2) |
depth |
int |
The current nesting depth for indentation calculation (default: 0) |
Returns
The XferLang string representation of this keyword element
Abstract Class: ListElement
Abstract base class representing a list-based collection element in XferLang. Manages ordered collections of semantic items with proper parent-child relationships. Non-semantic elements (processing instructions, comments) are stored separately from semantic items.
Properties
Name | Type | Description |
---|---|---|
Count |
int |
Gets the number of semantic items in this list (excludes processing instructions and comments). |
Item |
Element |
Methods
Add
bool Add(Element element)
Add a semantic item. Non-semantic elements (PIs/comments) should be added to Children only.
GetElementAt
Element GetElementAt(int index)
Gets the semantic element at the specified index, or null if the index is out of bounds.
Parameters
Name | Type | Description |
---|---|---|
index |
int |
The zero-based index of the element to retrieve |
Returns
The element at the specified index, or null if index is invalid
Remove
bool Remove(Element element)
Removes the specified element from this list.
Parameters
Name | Type | Description |
---|---|---|
element |
Element |
The element to remove |
Returns
True if the element was found and removed, false otherwise
RemoveAllChildren
int RemoveAllChildren()
Removes all child elements from this list. Overrides base implementation to handle both _items and Children collections.
Returns
The number of children that were removed
RemoveAt
bool RemoveAt(int index)
Removes the element at the specified index.
Parameters
Name | Type | Description |
---|---|---|
index |
int |
The zero-based index of the element to remove |
Returns
True if the element was found and removed, false otherwise
RemoveChild
bool RemoveChild(Element child)
Removes a specific child element from this list. Overrides base implementation to handle both _items and Children collections.
Parameters
Name | Type | Description |
---|---|---|
child |
Element |
The child element to remove |
Returns
True if the child was found and removed, false otherwise
RemoveChildAt
bool RemoveChildAt(int index)
Removes a child element at the specified index. Overrides base implementation to handle both _items and Children collections.
Parameters
Name | Type | Description |
---|---|---|
index |
int |
The zero-based index of the child to remove |
Returns
True if the child was successfully removed, false if index was out of range
ReplaceChild
bool ReplaceChild(Element oldChild, Element newChild)
Replaces a child element with a new element. Overrides base implementation to handle both _items and Children collections.
Parameters
Name | Type | Description |
---|---|---|
oldChild |
Element |
The existing child element to replace |
newChild |
Element |
The new child element to add in its place |
Returns
True if the replacement was successful, false if oldChild was not found
ToString
string ToString()
Returns a string representation of this list by joining all semantic items with spaces.
Returns
A space-separated string of all semantic items in the list
Class: LongElement
Represents a 64-bit signed integer element in XferLang. Uses ampersand (&) delimiters and supports attribute-driven hexadecimal or binary formatting.
Methods
Constructor
LongElement(long value, int specifierCount, ElementStyle style)
Initializes a new instance of the LongElement class with the specified value and formatting options.
Parameters
Name | Type | Description |
---|---|---|
value |
long |
The long integer value to represent |
specifierCount |
int |
The number of delimiter characters to use (default: 1) |
style |
ElementStyle |
The element style for delimiter handling (default: Compact) |
Constructor
LongElement(NumericValue<long> numericValue, int specifierCount, ElementStyle style)
Initializes a new instance of the LongElement class with the specified numeric value.
ToXfer
string ToXfer(Formatting formatting, Char indentChar, int indentation, int depth)
Serializes this long integer element to its XferLang string representation. Uses ampersand delimiters and applies custom formatting if specified.
Parameters
Name | Type | Description |
---|---|---|
formatting |
Formatting |
The formatting style to apply during serialization |
indentChar |
Char |
The character to use for indentation (default: space) |
indentation |
int |
The number of indentation characters per level (default: 2) |
depth |
int |
The current nesting depth for indentation calculation (default: 0) |
Returns
The XferLang string representation of this long integer element
Class: NullElement
Represents a null literal element in XferLang. Public so scripting tests can construct it.
Methods
Constructor
NullElement(ElementStyle style)
Create a new null element.
Parameters
Name | Type | Description |
---|---|---|
style |
ElementStyle |
Delimiter style (implicit, compact, explicit). |
ToString
string ToString()
ToXfer
string ToXfer()
ToXfer
string ToXfer(Formatting formatting, Char indentChar, int indentation, int depth)
Enum: NumericBase
Represents the numeric base used when interpreting or serializing a . Prefix conventions (when serialized through helper types): : no prefix: '$' prefix: '%' prefix
Members
Name | Value | Description |
---|---|---|
Binary |
2 |
Base 2 ('%' prefix) |
Decimal |
10 |
Base 10 (no prefix) |
Hexadecimal |
16 |
Base 16 ('$' prefix) |
Abstract Class: NumericElement<T>
Abstract base class for numeric elements in XferLang. Provides common functionality for serializing numeric types with configurable delimiters.
Properties
Name | Type | Description |
---|---|---|
NumericValue |
NumericValue<T> |
Strongly typed wrapper including formatting metadata for the numeric value. Setting updates the public . |
Methods
Constructor
NumericElement`1(T value, string name, ElementDelimiter delimiter)
Constructor
NumericElement`1(NumericValue<T> numericValue, string name, ElementDelimiter delimiter)
ToString
string ToString()
Returns a string representation of this numeric element using its value.
Returns
The string representation of the numeric value
ToXfer
string ToXfer()
Serializes this numeric element to its XferLang string representation using default formatting.
Returns
The XferLang string representation of this numeric element
ToXfer
string ToXfer(Formatting formatting, Char indentChar, int indentation, int depth)
Serializes this numeric element to its XferLang string representation with specified formatting. Supports implicit, compact, and explicit delimiter styles.
Parameters
Name | Type | Description |
---|---|---|
formatting |
Formatting |
The formatting style to apply during serialization |
indentChar |
Char |
The character to use for indentation (default: space) |
indentation |
int |
The number of indentation characters per level (default: 2) |
depth |
int |
The current nesting depth for indentation calculation (default: 0) |
Returns
The XferLang string representation of this numeric element
Class: NumericValue<T>
Represents a typed numeric value together with its and a flag indicating whether an explicit value was assigned. This wrapper is used by numeric element types to retain formatting intent (hex / binary) even if the underlying integer value can be represented in multiple ways.
Properties
Name | Type | Description |
---|---|---|
Base |
NumericBase |
Gets or sets the numeric base used for serialization / display. |
HasValue |
bool |
True once a value has been explicitly assigned (distinguishes default construction). |
Value |
T |
Gets or sets the underlying numeric value. Setting a value marks true. |
Methods
Constructor
NumericValue`1(T value, NumericBase numericBase)
Constructor
NumericValue`1()
Initializes a new instance with no explicit value (HasValue remains false until set).
ToString
string ToString()
Returns a string representing the value with an optional prefix ($ for hex, % for binary).
Class: ObjectElement
Represents an object element in XferLang that contains key-value pairs. Objects are delimited by curly braces {} and store structured data as named properties. Supports both semantic key-value pairs and metadata elements for round-trip preservation.
Properties
Name | Type | Description |
---|---|---|
Dictionary |
IReadOnlyDictionary<string, KeyValuePairElement> |
Only semantic key-value pairs (not PIs/comments) |
Item |
Element |
|
TypedValue |
List<KeyValuePairElement> |
Gets a list of all key-value pair elements in this object. This provides access to all the object's properties as a typed collection. |
Methods
Constructor
ObjectElement()
Initializes a new instance of the ObjectElement class.
AddOrUpdate
void AddOrUpdate(KeyValuePairElement value)
Adds a new key-value pair to the object or updates an existing one. If the key already exists, the existing pair is replaced in both the dictionary and children collection.
Parameters
Name | Type | Description |
---|---|---|
value |
KeyValuePairElement |
The key-value pair element to add or update |
AddOrUpdate
void AddOrUpdate(Element element)
Adds an element to the object. Supports key-value pairs and processing instructions. Key-value pairs are added to the object's dictionary, while processing instructions are added only to the children collection.
Parameters
Name | Type | Description |
---|---|---|
element |
Element |
The element to add (must be KeyValuePairElement or ProcessingInstruction) |
ContainsKey
bool ContainsKey(string key)
Determines whether the object contains an element with the specified key.
Parameters
Name | Type | Description |
---|---|---|
key |
string |
The key to locate in the object. |
Returns
True if the object contains an element with the key; otherwise, false.
GetElement
Element GetElement(string key)
Gets the element value associated with the specified key.
Parameters
Name | Type | Description |
---|---|---|
key |
string |
The key of the element to retrieve |
Returns
The element associated with the specified key
Remove
bool Remove(string key)
Removes the key-value pair with the specified key from the object.
Parameters
Name | Type | Description |
---|---|---|
key |
string |
The key of the element to remove |
Returns
True if the element was found and removed, false otherwise
RemoveAllChildren
int RemoveAllChildren()
Removes all key-value pairs and children from this object.
Returns
The number of children that were removed
RemoveChild
bool RemoveChild(Element child)
Removes a specific child element from this object. Overrides base implementation to handle both _values dictionary and Children collection.
Parameters
Name | Type | Description |
---|---|---|
child |
Element |
The child element to remove |
Returns
True if the child was found and removed, false otherwise
RemoveChildAt
bool RemoveChildAt(int index)
Removes a child element at the specified index from the Children collection. Note: Objects are not naturally ordered, but this provides access to Children collection by index.
Parameters
Name | Type | Description |
---|---|---|
index |
int |
The zero-based index of the child to remove |
Returns
True if the child was successfully removed, false if index was out of range
ReplaceChild
bool ReplaceChild(Element oldChild, Element newChild)
Replaces a child element with a new element. For KeyValuePairElements, replaces the value for the same key.
Parameters
Name | Type | Description |
---|---|---|
oldChild |
Element |
The existing child element to replace |
newChild |
Element |
The new child element to add in its place |
Returns
True if the replacement was successful, false if oldChild was not found
ToString
string ToString()
Returns a string representation of the object element.
Returns
The XferLang representation of the object element.
ToXfer
string ToXfer()
Converts the object element to its XferLang string representation without formatting.
Returns
The XferLang representation of the object element.
ToXfer
string ToXfer(Formatting formatting, Char indentChar, int indentation, int depth)
Converts the object element to its XferLang string representation with specified formatting options.
Parameters
Name | Type | Description |
---|---|---|
formatting |
Formatting |
The formatting options to apply. |
indentChar |
Char |
The character to use for indentation (default is space). |
indentation |
int |
The number of indent characters per level (default is 2). |
depth |
int |
The current nesting depth (default is 0). |
Returns
The formatted XferLang representation of the object element.
TryGetElement
bool TryGetElement(string key, TElement& result)
Class: QueryElement
Represents a query element introduced by semicolon specifiers. Wraps a whose key/value pair expresses the query semantics.
Properties
Name | Type | Description |
---|---|---|
Kvp |
KeyValuePairElement |
Gets or sets the key-value pair element that contains the processing instruction's name and value. This represents the structured data of the processing instruction. |
Target |
Element |
Gets or sets the target element that this processing instruction applies to. Can be null if the processing instruction applies globally or has no specific target. |
Methods
Constructor
QueryElement(KeyValuePairElement value, int specifierCount, ElementStyle style)
Initializes a new instance of the QueryElement class with the specified value and name.
Parameters
Name | Type | Description |
---|---|---|
value |
KeyValuePairElement |
The key/value pair carried by this query element. |
specifierCount |
int |
Number of leading specifier characters. |
style |
ElementStyle |
Delimiter style controlling serialization. |
ElementHandler
void ElementHandler(Element element)
Virtual method for handling element-specific processing. Override this method in derived classes to implement custom element handling logic.
Parameters
Name | Type | Description |
---|---|---|
element |
Element |
The element to be processed. |
QueryHandler
void QueryHandler()
Virtual method for handling query-specific logic. Override this method in derived classes to implement custom query behavior.
ToXfer
string ToXfer()
Converts the processing instruction to its XferLang string representation without formatting.
Returns
The XferLang representation of the processing instruction.
ToXfer
string ToXfer(Formatting formatting, Char indentChar, int indentation, int depth)
Converts the processing instruction to its XferLang string representation with specified formatting options.
Parameters
Name | Type | Description |
---|---|---|
formatting |
Formatting |
The formatting options to apply. |
indentChar |
Char |
The character to use for indentation (default is space). |
indentation |
int |
The number of indent characters per level (default is 2). |
depth |
int |
The current nesting depth (default is 0). |
Returns
The formatted XferLang representation of the processing instruction.
Class: ReferenceElement
Represents a dereference of a previously bound name using leading underscore(s): _name Uses empty closing delimiter semantics similar to numeric and boolean elements.
Properties
Name | Type | Description |
---|---|---|
IsClone |
bool |
Indicates this dereference element was produced as a clone during parse (for diagnostics). |
Methods
Constructor
ReferenceElement(string name, int specifierCount, ElementStyle style)
Creates a reference element for a previously bound name.
Parameters
Name | Type | Description |
---|---|---|
name |
string |
The binding name to resolve when evaluated. |
specifierCount |
int |
Number of leading underscores (>=1) for stylistic grouping. |
style |
ElementStyle |
Delimiter style controlling implicit/compact/explicit emission. |
ToXfer
string ToXfer()
ToXfer
string ToXfer(Formatting formatting, Char indentChar, int indentation, int depth)
Class: StringElement
Represents a string element in XferLang using double quote (") delimiters. String elements store text values and handle proper escaping of special characters within the XferLang format.
Methods
Constructor
StringElement()
Initializes a new StringElement with an empty string value.
Constructor
StringElement(string text, int specifierCount, ElementStyle style)
Initializes a new StringElement with the specified text value and formatting options.
Parameters
Name | Type | Description |
---|---|---|
text |
string |
The string value to store. |
specifierCount |
int |
The number of delimiter characters to use (default: 1). |
style |
ElementStyle |
The element style for formatting (default: Compact). |
Abstract Class: TextElement
Abstract base class for text-based elements in XferLang that store string values. Provides functionality for handling text delimiters and automatic delimiter count adjustment based on content to prevent parsing conflicts.
Properties
Name | Type | Description |
---|---|---|
Value |
string |
Gets or sets the text value of this element. Setting the value automatically adjusts delimiter count if needed to prevent parsing conflicts. |
Methods
Constructor
TextElement(string text, string name, ElementDelimiter delimiter)
Initializes a new TextElement with the specified text, name, and delimiter configuration.
Parameters
Name | Type | Description |
---|---|---|
text |
string |
The text value to store. |
name |
string |
The element type name. |
delimiter |
ElementDelimiter |
The delimiter configuration for this element. |
ToString
string ToString()
Returns the text value of this element.
Returns
The text value as a string.
ToXfer
string ToXfer()
Converts the text element to its XferLang string representation without formatting.
Returns
The XferLang string representation of the text value.
ToXfer
string ToXfer(Formatting formatting, Char indentChar, int indentation, int depth)
Converts the text element to its XferLang string representation with formatting options.
Parameters
Name | Type | Description |
---|---|---|
formatting |
Formatting |
The formatting style to apply. |
indentChar |
Char |
The character to use for indentation. |
indentation |
int |
The number of indent characters per level. |
depth |
int |
The current indentation depth. |
Returns
The formatted XferLang string representation of the text value.
Class: TimeElement
Represents a time-only element in XferLang that stores time values without date components. Uses the same delimiters as DateTimeElement but focuses specifically on time representation with support for various time formatting and precision options.
Properties
Name | Type | Description |
---|---|---|
DateTimeHandling |
DateTimeHandling |
Gets or sets the date/time handling strategy for formatting and parsing time values. |
Methods
Constructor
TimeElement(DateTimeHandling dateTimeHandling, int specifierCount, ElementStyle elementStyle)
Initializes a new instance of the TimeElement class with the current time and specified formatting options.
Parameters
Name | Type | Description |
---|---|---|
dateTimeHandling |
DateTimeHandling |
The date/time handling strategy to use. |
specifierCount |
int |
The number of delimiter characters to use. |
elementStyle |
ElementStyle |
The element style to apply. |
Constructor
TimeElement(string stringValue, DateTimeHandling dateTimeHandling, int specifierCount, ElementStyle elementStyle)
Initializes a new instance of the TimeElement class by parsing a time string with specified formatting options.
Parameters
Name | Type | Description |
---|---|---|
stringValue |
string |
The string representation of the time to parse. |
dateTimeHandling |
DateTimeHandling |
The date/time handling strategy to use. |
specifierCount |
int |
The number of delimiter characters to use. |
elementStyle |
ElementStyle |
The element style to apply. |
Constructor
TimeElement(TimeOnly timeOnly, DateTimeHandling dateTimeHandling, int specifierCount, ElementStyle elementStyle)
Initializes a new instance of the TimeElement class with the specified TimeOnly value and formatting options.
Parameters
Name | Type | Description |
---|---|---|
timeOnly |
TimeOnly |
The TimeOnly value to wrap in this element. |
dateTimeHandling |
DateTimeHandling |
The date/time handling strategy to use. |
specifierCount |
int |
The number of delimiter characters to use. |
elementStyle |
ElementStyle |
The element style to apply. |
FormatTime
string FormatTime(TimeOnly timeValue, DateTimeHandling dateTimeHandling)
Formats a TimeOnly value according to the specified DateTimeHandling strategy.
Parameters
Name | Type | Description |
---|---|---|
timeValue |
TimeOnly |
The time value to format. |
dateTimeHandling |
DateTimeHandling |
The formatting strategy to apply. |
Returns
The formatted time string.
GetFormatString
string GetFormatString(DateTimeHandling dateTimeHandling)
Gets the appropriate format string for the specified DateTimeHandling strategy.
Parameters
Name | Type | Description |
---|---|---|
dateTimeHandling |
DateTimeHandling |
The date/time handling strategy. |
Returns
The format string to use for time formatting.
ToString
string ToString()
Returns a string representation of the time element using the configured DateTimeHandling strategy.
Returns
The formatted time string.
ToXfer
string ToXfer()
Converts the time element to its XferLang string representation without formatting.
Returns
The XferLang representation of the time element.
ToXfer
string ToXfer(Formatting formatting, Char indentChar, int indentation, int depth)
Converts the time element to its XferLang string representation with specified formatting options.
Parameters
Name | Type | Description |
---|---|---|
formatting |
Formatting |
The formatting options to apply. |
indentChar |
Char |
The character to use for indentation (default is space). |
indentation |
int |
The number of indent characters per level (default is 2). |
depth |
int |
The current nesting depth (default is 0). |
Returns
The formatted XferLang representation of the time element.
Class: TimeSpanElement
Represents a time span element in XferLang that stores duration values. Uses the same delimiters as DateTimeElement but focuses specifically on time duration representation with support for various formatting and precision options.
Properties
Name | Type | Description |
---|---|---|
DateTimeHandling |
DateTimeHandling |
Gets or sets the date/time handling strategy for formatting and parsing time span values. |
Methods
Constructor
TimeSpanElement(DateTimeHandling dateTimeHandling, int specifierCount, ElementStyle elementStyle)
Initializes a new instance of the TimeSpanElement class with zero duration and specified formatting options.
Parameters
Name | Type | Description |
---|---|---|
dateTimeHandling |
DateTimeHandling |
The date/time handling strategy to use. |
specifierCount |
int |
The number of delimiter characters to use. |
elementStyle |
ElementStyle |
The element style to apply. |
Constructor
TimeSpanElement(string stringValue, DateTimeHandling dateTimeHandling, int specifierCount, ElementStyle elementStyle)
Initializes a new instance of the TimeSpanElement class by parsing a duration string with specified formatting options.
Parameters
Name | Type | Description |
---|---|---|
stringValue |
string |
The string representation of the time span to parse. |
dateTimeHandling |
DateTimeHandling |
The date/time handling strategy to use. |
specifierCount |
int |
The number of delimiter characters to use. |
elementStyle |
ElementStyle |
The element style to apply. |
Constructor
TimeSpanElement(TimeSpan timeSpan, DateTimeHandling dateTimeHandling, int specifierCount, ElementStyle elementStyle)
Initializes a new instance of the TimeSpanElement class with the specified TimeSpan value and formatting options.
Parameters
Name | Type | Description |
---|---|---|
timeSpan |
TimeSpan |
The TimeSpan value to wrap in this element. |
dateTimeHandling |
DateTimeHandling |
The date/time handling strategy to use. |
specifierCount |
int |
The number of delimiter characters to use. |
elementStyle |
ElementStyle |
The element style to apply. |
FormatTimeSpan
string FormatTimeSpan(TimeSpan timespanValue, DateTimeHandling dateTimeHandling)
Formats a TimeSpan value according to the specified DateTimeHandling strategy.
Parameters
Name | Type | Description |
---|---|---|
timespanValue |
TimeSpan |
The time span value to format. |
dateTimeHandling |
DateTimeHandling |
The formatting strategy to apply. |
Returns
The formatted time span string.
GetFormatString
string GetFormatString(DateTimeHandling dateTimeHandling)
Gets the appropriate format string for the specified DateTimeHandling strategy.
Parameters
Name | Type | Description |
---|---|---|
dateTimeHandling |
DateTimeHandling |
The date/time handling strategy. |
Returns
The format string to use for time span formatting.
ToString
string ToString()
Returns a string representation of the time span element using the configured DateTimeHandling strategy.
Returns
The formatted time span string.
ToXfer
string ToXfer()
Converts the time span element to its XferLang string representation without formatting.
Returns
The XferLang representation of the time span element.
ToXfer
string ToXfer(Formatting formatting, Char indentChar, int indentation, int depth)
Converts the time span element to its XferLang string representation with specified formatting options.
Parameters
Name | Type | Description |
---|---|---|
formatting |
Formatting |
The formatting options to apply. |
indentChar |
Char |
The character to use for indentation (default is space). |
indentation |
int |
The number of indent characters per level (default is 2). |
depth |
int |
The current nesting depth (default is 0). |
Returns
The formatted XferLang representation of the time span element.
Class: TupleElement
Represents a tuple element in XferLang that contains an ordered collection of elements. Tuples are delimited by parentheses () and preserve element order, making them suitable for representing structured data with positional significance.
Methods
Constructor
TupleElement(ElementStyle style)
Initializes a new instance of the TupleElement class with the specified style.
Parameters
Name | Type | Description |
---|---|---|
style |
ElementStyle |
The element style to use (default is compact). |
Constructor
TupleElement(IEnumerable<Element> values)
Initializes a new instance of the TupleElement class with the specified collection of elements.
Parameters
Name | Type | Description |
---|---|---|
values |
IEnumerable<Element> |
The elements to add to the tuple. |
Constructor
TupleElement(Element[] values)
Initializes a new instance of the TupleElement class with the specified array of elements.
Parameters
Name | Type | Description |
---|---|---|
values |
Element[] |
The elements to add to the tuple. |
ToString
string ToString()
Returns a string representation of the tuple element.
Returns
The XferLang representation of the tuple element.
ToXfer
string ToXfer()
Converts the tuple element to its XferLang string representation without formatting.
Returns
The XferLang representation of the tuple element.
ToXfer
string ToXfer(Formatting formatting, Char indentChar, int indentation, int depth)
Converts the tuple element to its XferLang string representation with specified formatting options.
Parameters
Name | Type | Description |
---|---|---|
formatting |
Formatting |
The formatting options to apply. |
indentChar |
Char |
The character to use for indentation (default is space). |
indentation |
int |
The number of indent characters per level (default is 2). |
depth |
int |
The current nesting depth (default is 0). |
Returns
The formatted XferLang representation of the tuple element.
Abstract Class: TypedElement<T>
Abstract base class for elements that store a strongly-typed value. Provides generic functionality for elements that wrap specific .NET types with appropriate XferLang formatting and delimiter handling.
Properties
Name | Type | Description |
---|---|---|
ParsedValue |
Object |
Gets the parsed value of this element for external evaluation. For typed elements, this returns the strongly-typed Value. |
Value |
T |
Gets or sets the strongly-typed value stored in this element. |
Methods
Constructor
TypedElement`1(T value, string name, ElementDelimiter delimiter)
ToString
string ToString()
Returns the string representation of the stored value.
Returns
The value as a string, or empty string if the value is null.
ToXfer
string ToXfer()
Converts the typed element to its XferLang string representation. The default implementation wraps the value with the configured delimiters.
Returns
The XferLang string representation of the typed value.
Namespace: ParksComputing.Xfer.Lang.Extensions
Static Class: CharExtensions
Provides extension methods for character operations specific to XferLang parsing and validation. Contains utility methods for identifying different types of characters used in XferLang syntax.
Methods
IsCollectionClosingSpecifier
bool IsCollectionClosingSpecifier(Char c)
Determines whether a character is a valid closing specifier for collection elements. Includes objects, arrays, and tuples.
Parameters
Name | Type | Description |
---|---|---|
c |
Char |
The character to test. |
Returns
True if the character closes a collection element; otherwise, false.
IsCollectionOpeningSpecifier
bool IsCollectionOpeningSpecifier(Char c)
Determines whether a character is a valid opening specifier for collection elements. Includes objects, arrays, and tuples.
Parameters
Name | Type | Description |
---|---|---|
c |
Char |
The character to test. |
Returns
True if the character opens a collection element; otherwise, false.
IsElementClosingCharacter
bool IsElementClosingCharacter(Char c)
Determines whether a character can serve as a closing delimiter for XferLang elements.
Parameters
Name | Type | Description |
---|---|---|
c |
Char |
The character to test. |
Returns
True if the character can be a closing delimiter; otherwise, false.
IsElementClosingSpecifier
bool IsElementClosingSpecifier(Char c)
Determines whether a character is a valid closing specifier for any XferLang element type. Checks against all known element closing specifiers including identifiers, numbers, booleans, etc.
Parameters
Name | Type | Description |
---|---|---|
c |
Char |
The character to test. |
Returns
True if the character is a valid closing specifier; otherwise, false.
IsElementOpeningCharacter
bool IsElementOpeningCharacter(Char c)
Determines whether a character can serve as an opening delimiter for XferLang elements.
Parameters
Name | Type | Description |
---|---|---|
c |
Char |
The character to test. |
Returns
True if the character can be an opening delimiter; otherwise, false.
IsElementOpeningSpecifier
bool IsElementOpeningSpecifier(Char c)
Determines whether a character is a valid opening specifier for any XferLang element type. Checks against all known element opening specifiers including identifiers, numbers, booleans, etc.
Parameters
Name | Type | Description |
---|---|---|
c |
Char |
The character to test. |
Returns
True if the character is a valid opening specifier; otherwise, false.
IsIntegerLeadingChar
bool IsIntegerLeadingChar(Char c)
Determines whether a character can be the first character of an integer literal. Includes digits, hexadecimal prefix, binary prefix, and sign characters.
Parameters
Name | Type | Description |
---|---|---|
c |
Char |
The character to test. |
Returns
True if the character can start an integer literal; otherwise, false.
IsKeywordChar
bool IsKeywordChar(Char c)
Determines whether a character is valid for use in XferLang keywords. Valid keyword characters include letters, digits, underscore, hyphen, and period.
Parameters
Name | Type | Description |
---|---|---|
c |
Char |
The character to test. |
Returns
True if the character is valid for keywords; otherwise, false.
IsWhiteSpace
bool IsWhiteSpace(Char c)
Determines whether a character is considered whitespace. Uses the standard .NET char.IsWhiteSpace method.
Parameters
Name | Type | Description |
---|---|---|
c |
Char |
The character to test. |
Returns
True if the character is whitespace; otherwise, false.
Static Class: ObjectExtensions
Provides extension methods for converting .NET objects to XferLang format. Simplifies serialization by adding convenient ToXfer() method to all objects.
Methods
ToXfer
string ToXfer(Object obj)
Converts any .NET object to its XferLang string representation. Uses XferConvert.Serialize internally with default settings.
Parameters
Name | Type | Description |
---|---|---|
obj |
Object |
The object to serialize to XferLang format. |
Returns
The XferLang string representation of the object.
Namespace: ParksComputing.Xfer.Lang.ProcessingInstructions
Class: CharDefProcessingInstruction
Processing instruction for defining custom character definitions in XferLang. Allows mapping of custom character names to Unicode code points for use in character elements. The instruction expects an object containing name-to-codepoint mappings.
Properties
Name | Type | Description |
---|---|---|
CustomCharIds |
Dictionary<string, int> |
Gets a dictionary of custom character IDs defined by this processing instruction. Maps custom character names to their corresponding Unicode code points. |
Methods
Constructor
CharDefProcessingInstruction(ObjectElement value)
Initializes a new instance of the CharDefProcessingInstruction class with the specified character definitions.
Parameters
Name | Type | Description |
---|---|---|
value |
ObjectElement |
The object element containing character name-to-codepoint mappings. |
ElementHandler
void ElementHandler(Element element)
Handles element processing by assigning the processing instruction's value as the element's ID. This provides element identification functionality for character definition contexts.
Parameters
Name | Type | Description |
---|---|---|
element |
Element |
The element to assign the ID to. |
ProcessingInstructionHandler
void ProcessingInstructionHandler()
Handles the processing of character definitions by registering the custom character mappings globally. Validates that all values are character elements and updates the CharacterIdRegistry.
Class: ConditionalElementException
Exception thrown when a conditional element should not be added to the document. This signals to the parser that the element should be skipped.
Methods
Constructor
ConditionalElementException(string message)
Creates a new .
Parameters
Name | Type | Description |
---|---|---|
message |
string |
Describes the element condition failure. |
Class: DefinedProcessingInstruction
Processing instruction for checking if any element is defined (has a meaningful value). Returns true if the element exists and has a non-null, non-empty value, false otherwise. This works like #ifdef but for any element type - dynamic elements, characters, references, etc. Integrates with the dynamic element system for powerful conditional logic.
Properties
Name | Type | Description |
---|---|---|
IsDefined |
bool |
The result of the definition check - true if the element is defined (has meaningful value), false otherwise. |
SourceElement |
Element |
The element to check for definition (any element type). |
Methods
Constructor
DefinedProcessingInstruction(Element value)
Initializes a new instance of the DefinedProcessingInstruction class.
Parameters
Name | Type | Description |
---|---|---|
value |
Element |
The element to check for definition (any element type). |
ElementHandler
void ElementHandler(Element element)
Handles element processing for the defined PI. This is typically not used for conditional PIs as they evaluate during processing instruction handling.
Parameters
Name | Type | Description |
---|---|---|
element |
Element |
The element to process (unused for this PI type). |
ProcessingInstructionHandler
void ProcessingInstructionHandler()
Handles the processing of the element definition check. This performs the actual conditional evaluation and stores the result. Now delegates to the DefinedOperator in the Scripting namespace for consistent logic.
ToString
string ToString()
Gets a string representation of this defined PI showing the element and result.
Returns
A string in the format "defined(element_type: 'element_value') = result".
Class: DocumentProcessingInstruction
Processing instruction for document-level metadata and configuration in XferLang. Contains document properties, schema information, versioning, and other metadata that applies to the entire XferLang document. The instruction expects an object containing document configuration parameters.
Properties
Name | Type | Description |
---|---|---|
Author |
StringElement |
Primary author/owner (use Authors for multiples). |
Authors |
ArrayElement |
Authors list. |
CreatedAt |
DateTimeElement |
Creation timestamp. |
Description |
StringElement |
Short description or summary. |
DocumentId |
StringElement |
Document identifier (string or GUID as string). |
DocumentTags |
ArrayElement |
Freeform document-level tags/labels. |
Environment |
StringElement |
Environment name (e.g., dev/test/prod). |
Item |
Element |
|
License |
StringElement |
License identifier or text. |
Object |
ObjectElement |
The underlying object that stores all document properties. |
Profile |
StringElement |
Profile or variant identifier. |
Properties |
IReadOnlyDictionary<string, KeyValuePairElement> |
Gets all properties as a read-only dictionary. |
Title |
StringElement |
Document title/name. |
UpdatedAt |
DateTimeElement |
Last updated timestamp. |
Version |
StringElement |
Human or semantic version string. |
XferLang |
StringElement |
The version of XferLang targeted by this document. |
Methods
Constructor
DocumentProcessingInstruction(ObjectElement value)
Initializes a new instance of the DocumentProcessingInstruction class with the specified object value.
Parameters
Name | Type | Description |
---|---|---|
value |
ObjectElement |
The object element containing document configuration parameters. |
Constructor
DocumentProcessingInstruction()
Initializes a new instance of the DocumentProcessingInstruction class with an empty object value.
Configure
DocumentProcessingInstruction Configure(Action<ObjectElement> configure)
Configure the document processing instruction.
Create
DocumentProcessingInstruction Create(Action<ObjectElement> configure)
Create a new instance with the specified configuration.
From
DocumentProcessingInstruction From(IDictionary<string, Element> properties)
Create an instance from a dictionary of element values.
Get
TElement Get(string key)
Get a typed element by key.
Remove
bool Remove(string key)
Remove a property by key.
RemoveProperty
bool RemoveProperty(string key)
Remove a property by key.
Parameters
Name | Type | Description |
---|---|---|
key |
string |
Set
void Set(string key, Element element)
Set a typed element by key.
SetCustom
void SetCustom(string key, Element element)
Set a custom element value by key.
ToDictionary
Dictionary<string, Element> ToDictionary()
Convert to a dictionary of element values.
TryGetCustom
bool TryGetCustom(string key, TElement& element)
Class: DynamicSourceProcessingInstruction
Processing instruction for configuring dynamic data sources in XferLang. Allows specification of external data sources, connection settings, and dynamic content resolution strategies. The instruction expects an object containing source configuration parameters.
Methods
Constructor
DynamicSourceProcessingInstruction(ObjectElement sourceConfig)
Initializes a new instance of the DynamicSourceProcessingInstruction class with the specified source configuration.
Parameters
Name | Type | Description |
---|---|---|
sourceConfig |
ObjectElement |
The object element containing dynamic source configuration parameters. |
ElementHandler
void ElementHandler(Element element)
Handles element-level processing for dynamic source instructions. Since dynamic source processing instructions are document-level and handled in ProcessingInstructionHandler, no specific element-level handling is needed.
Parameters
Name | Type | Description |
---|---|---|
element |
Element |
The element to be processed (unused for dynamic source instructions). |
ProcessingInstructionHandler
void ProcessingInstructionHandler()
Handles the processing of the dynamic source configuration by registering all source configurations globally. This makes the configurations available during parsing for dynamic content resolution.
Class: IdProcessingInstruction
Processing instruction for assigning unique identifiers to elements in XferLang. The ID processing instruction associates a string identifier with an element, enabling element referencing and uniqueness validation within the document.
Methods
Constructor
IdProcessingInstruction(TextElement value)
Initializes a new instance of the IdProcessingInstruction class with the specified ID value.
Parameters
Name | Type | Description |
---|---|---|
value |
TextElement |
The text element containing the ID value to assign to the target element. |
ElementHandler
void ElementHandler(Element element)
Handles element processing by assigning the ID value to the target element. Sets the element's Id property to the string representation of the processing instruction's value.
Parameters
Name | Type | Description |
---|---|---|
element |
Element |
The element to assign the ID to. |
Class: IfProcessingInstruction
Processing instruction for conditional execution based on expressions. Evaluates a condition and conditionally affects the target element based on the result. Demonstrates the hybrid approach where processing instructions delegate to reusable scripting operators.
Properties
Name | Type | Description |
---|---|---|
AppliedConditionMetSnapshot |
Nullable<bool> |
Snapshot of ConditionMet at the exact moment ElementHandler was invoked. Used to detect post-application mutation or evaluation/application divergence in intermittent failures. Null until ElementHandler runs for the first time. |
ConditionExpression |
Element |
The condition expression to evaluate. |
ConditionMet |
bool |
The result of the condition evaluation - true if the condition is met, false otherwise. |
DebugId |
int |
Public identifier (debug only usage) to correlate logs. Stable for lifetime of the PI instance. |
ElementHandlerInvoked |
bool |
Tracks whether ElementHandler executed (even if it later threw for suppression) to distinguish between "never applied" and "applied then mutated" scenarios. |
UnknownOperator |
bool |
True when the operator name in the condition expression was unknown and treated as a no-op. Used to preserve the PI in serialization for user visibility. |
Methods
Constructor
IfProcessingInstruction(Element conditionExpression, Parser parser)
Initializes a new instance of the class. The condition expression is stored and evaluated later during .
Parameters
Name | Type | Description |
---|---|---|
conditionExpression |
Element |
Expression whose truthiness determines whether the next element is included. |
parser |
Parser |
Optional parser used for emitting warnings (e.g. unknown operator). |
ElementHandler
void ElementHandler(Element element)
Handles element processing based on the conditional evaluation result. If the condition is met, the element is processed normally. If the condition is not met, we signal that the element should not be added to the document.
Parameters
Name | Type | Description |
---|---|---|
element |
Element |
The target element to conditionally process. |
ProcessingInstructionHandler
void ProcessingInstructionHandler()
Handles the processing of the conditional expression evaluation. This delegates to the IfOperator in the Scripting namespace for consistent logic while providing the Processing Instruction interface for document-level usage.
ToString
string ToString()
Gets a string representation of this if PI showing the condition and result.
Returns
A string in the format "if(condition_type: 'condition_value') = result".
Class: LetProcessingInstruction
Standalone let processing instruction: !> Mirrors the let operator used inside a script processing instruction but as a first-class PI.
Properties
Name | Type | Description |
---|---|---|
BindingName |
string |
The identifier introduced into the current binding scope by this PI. Distinct from the PI keyword ("let"). |
BoundValue |
Element |
The (possibly structured) value element bound to . All internal dereferences are resolved before binding. |
Methods
ElementHandler
void ElementHandler(Element element)
Binds the resolved value to in the parser scope so subsequent siblings can dereference it. Suppresses serialization of the PI itself.
Parameters
Name | Type | Description |
---|---|---|
element |
Element |
The target element the PI is attached to. |
Class: ProcessingInstruction
Represents a processing instruction in XferLang that provides metadata or processing directives for elements in the document. Processing instructions are enclosed in delimiters and contain key-value pairs that affect parsing or element behavior.
Properties
Name | Type | Description |
---|---|---|
Kvp |
KeyValuePairElement |
Gets or sets the key-value pair element that contains the processing instruction's name and value. This represents the structured data of the processing instruction. |
SuppressSerialization |
bool |
When true, this processing instruction will not serialize (used for successful conditional IF PIs). |
Target |
Element |
Gets or sets the target element that this processing instruction applies to. Can be null if the processing instruction applies globally or has no specific target. |
Methods
Constructor
ProcessingInstruction(Element value, string name)
Initializes a new instance of the ProcessingInstruction class with the specified value and name.
Parameters
Name | Type | Description |
---|---|---|
value |
Element |
The element value for the processing instruction. |
name |
string |
The name/keyword for the processing instruction. |
ElementHandler
void ElementHandler(Element element)
Virtual method for handling element-specific processing. Override this method in derived classes to implement custom element handling logic.
Parameters
Name | Type | Description |
---|---|---|
element |
Element |
The element to be processed. |
ProcessingInstructionHandler
void ProcessingInstructionHandler()
Virtual method for handling processing instruction-specific logic. Override this method in derived classes to implement custom processing instruction behavior.
ToXfer
string ToXfer()
Converts the processing instruction to its XferLang string representation without formatting.
Returns
The XferLang representation of the processing instruction.
ToXfer
string ToXfer(Formatting formatting, Char indentChar, int indentation, int depth)
Converts the processing instruction to its XferLang string representation with specified formatting options.
Parameters
Name | Type | Description |
---|---|---|
formatting |
Formatting |
The formatting options to apply. |
indentChar |
Char |
The character to use for indentation (default is space). |
indentation |
int |
The number of indent characters per level (default is 2). |
depth |
int |
The current nesting depth (default is 0). |
Returns
The formatted XferLang representation of the processing instruction.
Class: PropertiesProcessingInstruction
Processing instruction for defining custom properties in XferLang documents. Allows specification of additional property-value pairs that can be used for application-specific configuration, validation rules, or other custom behaviors.
Properties
Name | Type | Description |
---|---|---|
CustomProperties |
Dictionary<string, string> |
Gets a dictionary of custom properties defined in this processing instruction. Maps property names to their corresponding string values. |
Methods
Constructor
PropertiesProcessingInstruction(ObjectElement value)
Initializes a new instance of the PropertiesProcessingInstruction class with the specified properties object.
Parameters
Name | Type | Description |
---|---|---|
value |
ObjectElement |
The object element containing custom property definitions. |
Class: ScriptProcessingInstruction
Processing Instruction that executes scripting operator invocations prior to parsing its target element. New syntax example: ) !>
Properties
Name | Type | Description |
---|---|---|
Operations |
TupleElement |
The tuple of operator invocations to execute prior to parsing the target element. Currently supports let bindings; future operators may be added. |
Methods
ElementHandler
void ElementHandler(Element element)
Executes supported operators (currently let) before normal element processing and updates the target subtree to resolve any dereferences that became available.
Parameters
Name | Type | Description |
---|---|---|
element |
Element |
The target element associated with this PI. |
Class: TagProcessingInstruction
Processing instruction for assigning a single tag to elements in XferLang. The tag processing instruction associates a string tag with an element, enabling element categorization and group selection within the document. Multiple elements can share the same tag, and elements may have multiple tags.
Methods
Constructor
TagProcessingInstruction(TextElement value)
Initializes a new instance of the TagProcessingInstruction class with the specified tag value.
Parameters
Name | Type | Description |
---|---|---|
value |
TextElement |
The text element containing the tag value to assign to the target element. |
ElementHandler
void ElementHandler(Element element)
Handles element processing by setting the tag value on the target element. Throws an exception if the element already has a tag assigned.
Parameters
Name | Type | Description |
---|---|---|
element |
Element |
The element to assign the tag to. |
Namespace: ParksComputing.Xfer.Lang.Schema
Class: Constraint
Represents a validation constraint that can be applied to schema fields or objects. Constraints define validation rules such as required fields, value ranges, patterns, or custom expressions.
Properties
Name | Type | Description |
---|---|---|
Name |
string |
Gets or sets the name of the constraint (e.g., "required", "minLength", "pattern"). |
Value |
Object |
Gets or sets the constraint value, which can be a boolean, string, number, or evaluable expression depending on the constraint type. |
Methods
Constructor
Constraint()
Class: ConstraintEvaluator
Provides static methods for evaluating schema constraints against document values. Handles boolean literals, expression constraints, and custom validation logic.
Methods
Constructor
ConstraintEvaluator()
Evaluate
bool Evaluate(Object value, ObjectElement document)
Evaluates a constraint value against a document context. Supports boolean literals, expression constraints, and complex validation scenarios.
Parameters
Name | Type | Description |
---|---|---|
value |
Object |
The constraint value to evaluate (boolean, expression, etc.). |
document |
ObjectElement |
The document context for expression evaluation. |
Returns
True if the constraint is satisfied; otherwise, false.
Class: ExpressionConstraint
Represents a constraint that uses logical expressions to validate fields in a document. Supports operators like "any" and "all" to check field presence or other conditions.
Properties
Name | Type | Description |
---|---|---|
Fields |
List<string> |
Gets or sets the list of field names that the expression operates on. |
Operator |
string |
Gets or sets the logical operator for the expression ("any", "all", etc.). |
Methods
Constructor
ExpressionConstraint()
Evaluate
bool Evaluate(ObjectElement document)
Evaluates the expression constraint against the specified document.
Parameters
Name | Type | Description |
---|---|---|
document |
ObjectElement |
The object element to evaluate against. |
Returns
True if the expression constraint is satisfied; otherwise, false.
Class: SchemaDefinition
Defines the structure and validation rules for a schema type in XferLang. Can represent objects, arrays, or individual elements with associated constraints and field definitions.
Properties
Name | Type | Description |
---|---|---|
Constraints |
List<Constraint> |
Gets or sets the validation constraints that apply to this schema definition. |
ElementType |
string |
Gets or sets the element type for array or collection schemas. Specifies what type of elements the array contains. |
Fields |
Dictionary<string, SchemaField> |
Gets or sets the field definitions for object-type schemas. Maps field names to their corresponding schema field specifications. |
Name |
string |
Gets or sets the name of the schema definition (e.g., "address", "person"). |
Type |
string |
Gets or sets the type category of the schema ("object", "array", "element", etc.). |
Methods
Constructor
SchemaDefinition()
Class: SchemaField
Represents a field definition within a schema object or structure. Defines the field's name, type, requirement status, and optional custom validation logic.
Properties
Name | Type | Description |
---|---|---|
CustomValidation |
Func<ListElement, bool> |
Gets or sets an optional custom validation function for complex field validation scenarios. The function receives a ListElement and returns true if validation passes. |
IsRequired |
bool |
Gets or sets a value indicating whether this field is required in the schema. |
Name |
string |
Gets or sets the name of the schema field. |
Type |
string |
Gets or sets the data type of the field (e.g., "string", "integer", "boolean"). |
Methods
Constructor
SchemaField()
Class: SchemaObject
Represents a structured object definition within a schema. Contains a collection of named fields that define the object's structure and validation rules.
Properties
Name | Type | Description |
---|---|---|
Fields |
Dictionary<string, SchemaField> |
Gets or sets the collection of fields that make up this schema object. Maps field names to their corresponding SchemaField definitions. |
Name |
string |
Gets or sets the name of the schema object. |
Methods
Constructor
SchemaObject()
Class: XferSchema
Represents an XferLang schema that defines the structure, validation rules, and constraints for XferLang documents. Contains schema definitions, type specifications, and validation metadata.
Properties
Name | Type | Description |
---|---|---|
Definitions |
Dictionary<string, SchemaDefinition> |
Gets or sets the collection of schema definitions contained in this schema. Maps definition names to their corresponding SchemaDefinition objects. |
Description |
string |
Gets or sets an optional description of the schema's purpose and usage. |
Name |
string |
Gets or sets the name of the schema. |
Methods
Constructor
XferSchema()
Class: XferSchemaParser
Parses XferLang schema definitions from document elements into structured schema objects. Converts schema syntax into usable schema models for validation and type checking.
Methods
Constructor
XferSchemaParser()
ParseSchema
Dictionary<string, SchemaObject> ParseSchema(ObjectElement schemaObjectElement)
Parses a schema object element into a dictionary of schema objects. Extracts schema definitions and converts them into structured SchemaObject instances.
Parameters
Name | Type | Description |
---|---|---|
schemaObjectElement |
ObjectElement |
The object element containing schema definitions to parse. |
Returns
A dictionary mapping schema names to their corresponding SchemaObject definitions.
Class: XferSchemaValidator
Validates XferLang documents against defined schemas. Performs structural validation, type checking, constraint evaluation, and rule enforcement to ensure documents conform to their specified schema definitions.
Methods
Constructor
XferSchemaValidator(Dictionary<string, SchemaObject> schemaObjects)
Initializes a new instance of the XferSchemaValidator class with the specified schema objects.
Parameters
Name | Type | Description |
---|---|---|
schemaObjects |
Dictionary<string, SchemaObject> |
A dictionary of schema objects to use for validation, keyed by schema name. |
Validate
void Validate(TupleElement document)
Validates a tuple element document against the configured schemas. Performs comprehensive validation including structure, types, and constraints.
Parameters
Name | Type | Description |
---|---|---|
document |
TupleElement |
The tuple element document to validate. |
Namespace: ParksComputing.Xfer.Lang.Scripting
Static Class: OperatorRegistry
Global registry for scripting operators that provides centralized operator management. This allows operators to query for other registered operators without circular dependencies.
Methods
Clear
void Clear()
Clears all registered operators.
ClearRegistry
void ClearRegistry()
Clears all registered operators (alias for Clear method).
CreateOperator
ScriptingOperator CreateOperator(string operatorName)
Creates an instance of the specified operator.
Parameters
Name | Type | Description |
---|---|---|
operatorName |
string |
The name of the operator to create. |
Returns
A new instance of the operator, or null if not found.
GetDiagnosticInfo
Dictionary<string, Object> GetDiagnosticInfo()
Gets diagnostic information about the operator registry.
Returns
A dictionary containing diagnostic information.
GetOperatorType
Type GetOperatorType(string operatorName)
Gets the type of the specified operator.
Parameters
Name | Type | Description |
---|---|---|
operatorName |
string |
The name of the operator. |
Returns
The type of the operator, or null if not found.
GetRegisteredOperatorNames
IReadOnlyCollection<string> GetRegisteredOperatorNames()
Gets all registered operator names.
Returns
A read-only collection of registered operator names.
IsOperatorRegistered
bool IsOperatorRegistered(string operatorName)
Checks if an operator is registered with the specified name.
Parameters
Name | Type | Description |
---|---|---|
operatorName |
string |
The name of the operator to check. |
Returns
True if the operator is registered; otherwise, false.
RegisterBuiltInOperators
void RegisterBuiltInOperators()
Registers all built-in operators that come with the scripting system. This method should be called during application initialization.
RegisterOperator
void RegisterOperator()
Registers an operator type with the global registry.
RegisterOperator
void RegisterOperator(string operatorName, Type operatorType)
Registers an operator type with the global registry by name and type.
Parameters
Name | Type | Description |
---|---|---|
operatorName |
string |
The name of the operator. |
operatorType |
Type |
The type of the operator. |
UnregisterOperator
bool UnregisterOperator(string operatorName)
Unregisters an operator from the global registry.
Parameters
Name | Type | Description |
---|---|---|
operatorName |
string |
The name of the operator to unregister. |
Returns
True if the operator was found and removed; otherwise, false.
Static Class: ScriptingArchitectureDemo
Demonstration and testing class for the new Scripting namespace architecture. Shows how the separated operators provide clean, reusable conditional logic outside of the Processing Instruction hierarchy.
Methods
DemonstrateBackwardCompatibility
void DemonstrateBackwardCompatibility()
Demonstrates how the new architecture maintains backward compatibility with existing Processing Instructions while providing enhanced capabilities.
RunBasicDemo
void RunBasicDemo()
Demonstrates the basic usage of the scripting engine with various operators.
ShowDiagnosticInfo
void ShowDiagnosticInfo()
Shows diagnostic information about the scripting engine state.
Class: ScriptingContext
Provides execution context for scripting operations including variable resolution, environment access, and parser integration for expression evaluation.
Properties
Name | Type | Description |
---|---|---|
Architecture |
string |
Gets the current processor architecture for architecture-specific conditional logic. |
CurrentElement |
Element |
Gets or sets the current element being processed, if any. |
DotNetVersion |
Version |
Gets the current .NET runtime version. |
IsDebug |
bool |
Gets a value indicating whether this is a debug build. |
Parser |
Parser |
Gets or sets the parser instance for access to parsing context and configuration. |
Platform |
string |
Gets the current platform name for platform-specific conditional logic. |
ProcessorCount |
int |
Gets the number of logical processors available on the current machine. |
Variables |
Dictionary<string, Object> |
Gets or sets the dictionary of user-defined variables available for dynamic element resolution. |
WorkingDirectory |
string |
Gets the current working directory. |
Methods
Constructor
ScriptingContext()
Initializes a new instance of the ScriptingContext class.
Constructor
ScriptingContext(Parser parser)
Initializes a new instance of the ScriptingContext class with the specified parser.
Parameters
Name | Type | Description |
---|---|---|
parser |
Parser |
The parser instance to associate with this context. |
ClearVariables
void ClearVariables()
Clears all variables from the context (except built-in environment variables).
GetEnvironmentVariable
string GetEnvironmentVariable(string variableName)
Gets the value of an environment variable.
Parameters
Name | Type | Description |
---|---|---|
variableName |
string |
The name of the environment variable. |
Returns
The value of the environment variable, or null if not found.
RemoveVariable
bool RemoveVariable(string name)
Removes a variable from the context.
Parameters
Name | Type | Description |
---|---|---|
name |
string |
The variable name to remove. |
Returns
True if the variable was found and removed; otherwise, false.
SetVariable
void SetVariable(string name, Object value)
Sets a variable in the context.
Parameters
Name | Type | Description |
---|---|---|
name |
string |
The variable name. |
value |
Object |
The variable value. |
TryResolveVariable
bool TryResolveVariable(string variableName, Object& value)
Class: ScriptingEngine
Scripting engine that provides expression evaluation capabilities using registered operators. This engine coordinates the execution of scripting operators and manages their lifecycle.
Properties
Name | Type | Description |
---|---|---|
Context |
ScriptingContext |
Gets the scripting context used by this engine. |
RegisteredOperators |
IEnumerable<string> |
Gets the collection of registered operator names. |
Methods
Constructor
ScriptingEngine(ScriptingContext context)
Initializes a new instance of the ScriptingEngine with a scripting context.
Parameters
Name | Type | Description |
---|---|---|
context |
ScriptingContext |
The scripting context containing variables and environment information. |
ClearCustomOperators
void ClearCustomOperators()
Clears all registered operators except built-in ones.
Evaluate
Object Evaluate(string operatorName, Element[] arguments)
Evaluates an expression using the specified operator and arguments.
Parameters
Name | Type | Description |
---|---|---|
operatorName |
string |
The name of the operator to use. |
arguments |
Element[] |
The arguments to pass to the operator. |
Returns
The result of the operator evaluation, or null if no result is available.
GetAllOperators
IEnumerable<ScriptingOperator> GetAllOperators()
Gets all registered operators.
Returns
A collection of all registered operators.
GetDiagnosticInfo
Dictionary<string, Object> GetDiagnosticInfo()
Gets diagnostic information about the scripting engine state.
Returns
A dictionary containing diagnostic information.
GetOperator
ScriptingOperator GetOperator(string operatorName)
Gets information about a registered operator.
Parameters
Name | Type | Description |
---|---|---|
operatorName |
string |
The name of the operator. |
Returns
The operator instance if found; otherwise, null.
GetOperatorsByCategory
IEnumerable<ScriptingOperator> GetOperatorsByCategory(string category)
Gets operators by category (based on namespace).
Parameters
Name | Type | Description |
---|---|---|
category |
string |
The category to filter by (e.g., "Comparison", "Logical", "Utility"). |
Returns
A collection of operators in the specified category.
IsOperatorRegistered
bool IsOperatorRegistered(string operatorName)
Checks if an operator is registered with the specified name.
Parameters
Name | Type | Description |
---|---|---|
operatorName |
string |
The name of the operator to check. |
Returns
True if the operator is registered; otherwise, false.
RegisterOperator
void RegisterOperator(ScriptingOperator operator)
Registers a scripting operator with the engine.
Parameters
Name | Type | Description |
---|---|---|
operator |
ScriptingOperator |
The operator to register. |
ToString
string ToString()
Returns a string representation of the scripting engine state.
Returns
A string describing the engine's current state.
TryEvaluate
bool TryEvaluate(string operatorName, Element[] arguments, Object& result)
UnregisterOperator
bool UnregisterOperator(string operatorName)
Unregisters a scripting operator from the engine.
Parameters
Name | Type | Description |
---|---|---|
operatorName |
string |
The name of the operator to unregister. |
Returns
True if the operator was found and removed; otherwise, false.
Abstract Class: ScriptingOperator
Abstract base class for scripting operators that evaluate expressions in XferLang. Provides the foundation for comparison, logical, utility, and other expression operators used in conditional logic and dynamic content resolution.
Properties
Name | Type | Description |
---|---|---|
Description |
string |
Gets a brief description of what this operator does. Used for documentation and error messages. |
MaxArguments |
int |
Gets the maximum number of arguments this operator accepts. Return -1 for unlimited arguments. |
MinArguments |
int |
Gets the minimum number of arguments this operator requires. |
OperatorName |
string |
Gets the unique name identifier for this operator. This name is used to register and lookup the operator in the scripting engine. |
Methods
Evaluate
Object Evaluate(ScriptingContext context, Element[] arguments)
Evaluates the operator with the specified arguments in the given context.
Parameters
Name | Type | Description |
---|---|---|
context |
ScriptingContext |
The scripting context containing variables and environment information. |
arguments |
Element[] |
The arguments to evaluate. Number and types depend on the specific operator. |
Returns
The result of the operator evaluation, or null if no result is available.
IsNumeric
bool IsNumeric(Type type)
Determines if a type is numeric (can be used in numeric comparisons).
Parameters
Name | Type | Description |
---|---|---|
type |
Type |
The type to check. |
Returns
True if the type is numeric; otherwise, false.
ToString
string ToString()
Returns a string representation of this operator.
Returns
A string containing the operator name and description.
Namespace: ParksComputing.Xfer.Lang.Scripting.Comparison
Class: EqualsOperator
Scripting operator that checks if two elements are equal. Provides flexible equality comparison handling different element types and values.
Properties
Name | Type | Description |
---|---|---|
Description |
string |
Gets a brief description of what this operator does. |
MaxArguments |
int |
Gets the maximum number of arguments this operator accepts. The equals operator accepts exactly two arguments. |
MinArguments |
int |
Gets the minimum number of arguments this operator requires. The equals operator requires exactly two arguments to compare. |
OperatorName |
string |
Gets the unique name identifier for this operator. |
Methods
Constructor
EqualsOperator()
Evaluate
Object Evaluate(ScriptingContext context, Element[] arguments)
Evaluates whether two elements are equal. Equality semantics: - Resolves both elements to their actual values using context - Handles null comparisons (null == null is true, null != anything else) - Performs type-appropriate comparisons: - String comparisons are case-sensitive by default - Numeric comparisons handle type coercion (int vs double, etc.) - Boolean comparisons are direct - Object comparisons use .Equals() method
Parameters
Name | Type | Description |
---|---|---|
context |
ScriptingContext |
The scripting context containing variables and environment information. |
arguments |
Element[] |
The two elements to compare. Must contain exactly two elements. |
Returns
Boolean true if the elements are equal; otherwise, false.
ToString
string ToString()
Returns a detailed string representation of this operator.
Returns
A string describing the operator and its usage.
Class: GreaterThanOperator
Scripting operator that determines whether the first argument is greater than the second. Supports numeric coercion; for non-numeric comparable types (string) falls back to ordinal comparison.
Properties
Name | Type | Description |
---|---|---|
Description |
string |
|
MaxArguments |
int |
|
MinArguments |
int |
|
OperatorName |
string |
Methods
Constructor
GreaterThanOperator()
Evaluate
Object Evaluate(ScriptingContext context, Element[] arguments)
Evaluates the operator returning true when the resolved left value is strictly greater than the resolved right value.
Parameters
Name | Type | Description |
---|---|---|
context |
ScriptingContext |
Active scripting context used to resolve element values. |
arguments |
Element[] |
Exactly two elements: left and right. |
Returns
true if left > right; otherwise false. If either operand is null the result is false.
Class: GreaterThanOrEqualOperator
Scripting operator that determines whether the first (left) argument is greater than or equal to the second (right) argument. Null handling: null >= null returns true; any other combination with null returns false.
Properties
Name | Type | Description |
---|---|---|
Description |
string |
|
MaxArguments |
int |
|
MinArguments |
int |
|
OperatorName |
string |
Methods
Constructor
GreaterThanOrEqualOperator()
Evaluate
Object Evaluate(ScriptingContext context, Element[] arguments)
Evaluates the operator returning true when left >= right after resolving argument values.
Parameters
Name | Type | Description |
---|---|---|
context |
ScriptingContext |
Active scripting context used to resolve element values. |
arguments |
Element[] |
Exactly two elements: left and right. |
Returns
true if left >= right; otherwise false. When both operands are null returns true.
Class: LessThanOperator
Scripting operator that determines whether the first (left) argument is strictly less than the second (right) argument. Supports numeric coercion, comparison, and falls back to ordinal string comparison when types differ. Symbol: lt
Properties
Name | Type | Description |
---|---|---|
Description |
string |
|
MaxArguments |
int |
|
MinArguments |
int |
|
OperatorName |
string |
Methods
Constructor
LessThanOperator()
Evaluate
Object Evaluate(ScriptingContext context, Element[] arguments)
Evaluates the operator returning true when the resolved left value is strictly less than the resolved right value.
Parameters
Name | Type | Description |
---|---|---|
context |
ScriptingContext |
Active scripting context used to resolve element values. |
arguments |
Element[] |
Exactly two elements: left and right. |
Returns
true if [0] is strictly less than [1]; otherwise false. Returns false if either side is null.
Class: LessThanOrEqualOperator
Scripting operator that determines whether the first (left) argument is less than or equal to the second (right) argument. Null handling: null <= null returns true; any other combination with null returns false.
Properties
Name | Type | Description |
---|---|---|
Description |
string |
|
MaxArguments |
int |
|
MinArguments |
int |
|
OperatorName |
string |
Methods
Constructor
LessThanOrEqualOperator()
Evaluate
Object Evaluate(ScriptingContext context, Element[] arguments)
Evaluates the operator returning true when left <= right after resolving argument values.
Parameters
Name | Type | Description |
---|---|---|
context |
ScriptingContext |
Active scripting context used to resolve element values. |
arguments |
Element[] |
Exactly two elements: left and right. |
Returns
true if left <= right; otherwise false. When both operands are null returns true.
Class: NotEqualOperator
Logical negation of EqualsOperator (eq). Returns true when operands are not equal.
Properties
Name | Type | Description |
---|---|---|
Description |
string |
|
MaxArguments |
int |
|
MinArguments |
int |
|
OperatorName |
string |
Methods
Constructor
NotEqualOperator()
Evaluate
Object Evaluate(ScriptingContext context, Element[] arguments)
Evaluates the operator returning true when the two resolved argument values are not equal. Delegates equality logic to and negates the result.
Parameters
Name | Type | Description |
---|---|---|
context |
ScriptingContext |
Active scripting context used to resolve element values. |
arguments |
Element[] |
Exactly two elements to compare. |
Returns
true if arguments are not equal; otherwise false.
Namespace: ParksComputing.Xfer.Lang.Scripting.Logical
Class: AndOperator
Logical conjunction operator that evaluates arguments left-to-right and short-circuits on the first falsey value.
Properties
Name | Type | Description |
---|---|---|
Description |
string |
|
MaxArguments |
int |
Unlimited additional arguments may be supplied. |
MinArguments |
int |
|
OperatorName |
string |
Methods
Constructor
AndOperator()
Evaluate
Object Evaluate(ScriptingContext context, Element[] arguments)
Returns false for the first falsey argument; otherwise true.
Class: IfOperator
Scripting operator providing conditional evaluation. Returns one of two values depending on the truthiness of the first argument. Usage: if condition trueValue [falseValue]. Also leveraged by the if processing instruction. Nested operator expressions (for example a defined test like: if defined DEREF) are supported. NOTE: Angle-bracket dereference placeholders were removed from the XML documentation example to avoid malformed XML warnings.
Properties
Name | Type | Description |
---|---|---|
Description |
string |
Gets a brief description of what this operator does. |
MaxArguments |
int |
Gets the maximum number of arguments this operator accepts. The if operator accepts at most 3 arguments: condition, true-value, and false-value. |
MinArguments |
int |
Gets the minimum number of arguments this operator requires. The if operator requires at least 2 arguments: condition and true-value. |
OperatorName |
string |
Gets the unique name identifier for this operator. |
Methods
Constructor
IfOperator()
Evaluate
Object Evaluate(ScriptingContext context, Element[] arguments)
Evaluates a conditional expression and returns the appropriate value. Conditional semantics: - First argument: The condition to evaluate (any element or expression) - Second argument: Value to return if condition is true - Third argument (optional): Value to return if condition is false (defaults to null) Truthiness evaluation: - Boolean true/false values are used directly - Non-null, non-empty strings are considered true - Non-zero numbers are considered true - Non-null objects are considered true - null, empty strings, and zero are considered false
Parameters
Name | Type | Description |
---|---|---|
context |
ScriptingContext |
The scripting context containing variables and environment information. |
arguments |
Element[] |
The condition and value arguments. Must contain 2-3 elements. |
Returns
The true-value if condition is true, false-value if condition is false, or null if no false-value provided.
ToString
string ToString()
Returns a detailed string representation of this operator.
Returns
A string describing the operator and its usage.
Class: NotOperator
Logical negation operator that inverts the truthiness of a single argument.
Properties
Name | Type | Description |
---|---|---|
Description |
string |
|
MaxArguments |
int |
Exactly one argument. |
MinArguments |
int |
|
OperatorName |
string |
Methods
Constructor
NotOperator()
Evaluate
Object Evaluate(ScriptingContext context, Element[] arguments)
Returns true when the argument is falsey; otherwise false.
Class: OrOperator
Logical disjunction operator that evaluates arguments left-to-right and short-circuits on the first truthy value.
Properties
Name | Type | Description |
---|---|---|
Description |
string |
|
MaxArguments |
int |
Unlimited additional arguments may be supplied. |
MinArguments |
int |
|
OperatorName |
string |
Methods
Constructor
OrOperator()
Evaluate
Object Evaluate(ScriptingContext context, Element[] arguments)
Returns true for the first truthy argument; otherwise false.
Class: XorOperator
Logical exclusive OR operator returning true only when exactly one of the two arguments is truthy.
Properties
Name | Type | Description |
---|---|---|
Description |
string |
|
MaxArguments |
int |
Exactly two arguments. |
MinArguments |
int |
|
OperatorName |
string |
Methods
Constructor
XorOperator()
Evaluate
Object Evaluate(ScriptingContext context, Element[] arguments)
Returns true when exactly one argument is truthy.
Namespace: ParksComputing.Xfer.Lang.Scripting.Utility
Class: DefinedOperator
Scripting operator that checks if an element has a meaningful value (is "defined"). This is the extracted core logic from DefinedProcessingInstruction, designed to be reusable across different contexts within the scripting system.
Properties
Name | Type | Description |
---|---|---|
Description |
string |
Gets a brief description of what this operator does. |
MaxArguments |
int |
Gets the maximum number of arguments this operator accepts. The defined operator accepts exactly one argument. |
MinArguments |
int |
Gets the minimum number of arguments this operator requires. The defined operator requires exactly one argument to check. |
OperatorName |
string |
Gets the unique name identifier for this operator. |
Methods
Constructor
DefinedOperator()
Evaluate
Object Evaluate(ScriptingContext context, Element[] arguments)
Evaluates whether the specified element is "defined" (has a meaningful value). Definition semantics: - An element is considered "defined" if its ParsedValue is not null - For DynamicElement: Uses runtime value resolution with string.IsNullOrEmpty check - For CollectionElement: Defined if has at least one child element - For other elements: Defined if ParsedValue is not null - Variables from context: Defined if variable exists and has non-null value
Parameters
Name | Type | Description |
---|---|---|
context |
ScriptingContext |
The scripting context containing variables and environment information. |
arguments |
Element[] |
The element to check for definition. Must contain exactly one element. |
Returns
Boolean true if the element is defined; otherwise, false.
ToString
string ToString()
Returns a detailed string representation of this operator.
Returns
A string describing the operator and its usage.
Namespace: ParksComputing.Xfer.Lang.Services
Static Class: CharacterIdRegistry
Provides a registry for mapping character IDs to Unicode code points in XferLang. Manages both built-in character definitions (ASCII control characters, common symbols) and custom character mappings defined by users or documents.
Properties
Name | Type | Description |
---|---|---|
Builtin |
IReadOnlyDictionary<string, int> |
Gets a read-only view of the built-in character ID mappings. Contains standard ASCII control characters and common symbols. |
Custom |
IReadOnlyDictionary<string, int> |
Gets a read-only view of the custom character ID mappings. Contains user-defined or document-specific character definitions. |
Methods
Resolve
Nullable<int> Resolve(string id)
Resolves a character ID to its corresponding Unicode code point. Searches first in custom mappings, then in built-in mappings.
Parameters
Name | Type | Description |
---|---|---|
id |
string |
The character ID to resolve (case-insensitive). |
Returns
The Unicode code point if found; otherwise, null.
SetCustomIds
void SetCustomIds(Dictionary<string, int> custom)
Sets the custom character ID mappings for the registry. This replaces any existing custom mappings with the provided dictionary.
Parameters
Name | Type | Description |
---|---|---|
custom |
Dictionary<string, int> |
A dictionary mapping custom character IDs to their Unicode code points. |
Class: DynamicSourceHandler
Handler delegate for resolving dynamic source values by source type.
Methods
Constructor
DynamicSourceHandler(Object object, IntPtr method)
BeginInvoke
IAsyncResult BeginInvoke(string sourceValue, string fallbackKey, AsyncCallback callback, Object object)
EndInvoke
string EndInvoke(IAsyncResult result)
Invoke
string Invoke(string sourceValue, string fallbackKey)
Static Class: DynamicSourceHandlerRegistry
Registry for dynamic source type handlers, allowing extensions to register custom source types.
Properties
Name | Type | Description |
---|---|---|
RegisteredSourceTypes |
IReadOnlyCollection<string> |
Gets all registered source types. |
Methods
RegisterHandler
void RegisterHandler(string sourceType, DynamicSourceHandler handler)
Registers a handler for a specific source type.
Parameters
Name | Type | Description |
---|---|---|
sourceType |
string |
The source type (e.g., "db", "api", "file") |
handler |
DynamicSourceHandler |
The handler function |
Resolve
string Resolve(string sourceType, string sourceValue, string fallbackKey)
Resolves a value using the registered handler for the given source type.
Parameters
Name | Type | Description |
---|---|---|
sourceType |
string |
The source type (e.g., "const", "env", "db") |
sourceValue |
string |
The source-specific value |
fallbackKey |
string |
The original key to use as fallback |
Returns
The resolved value, or null if no handler is registered or the handler returns null
UnregisterHandler
bool UnregisterHandler(string sourceType)
Unregisters a handler for a specific source type.
Parameters
Name | Type | Description |
---|---|---|
sourceType |
string |
The source type to unregister |
Returns
True if the handler was removed, false if it didn't exist
Static Class: DynamicSourceRegistry
Global registry for dynamic source configurations from dynamicSource PIs. This allows dynamicSource PIs to affect the entire document scope.
Properties
Name | Type | Description |
---|---|---|
Configurations |
IReadOnlyDictionary<string, Element> |
Gets all registered configurations (read-only). |
Methods
AddConfiguration
void AddConfiguration(string key, Element sourceConfig)
Adds or updates a single dynamic source configuration.
Parameters
Name | Type | Description |
---|---|---|
key |
string |
The dynamic element key |
sourceConfig |
Element |
The source configuration element |
Clear
void Clear()
Clears all dynamic source configurations. Useful for starting fresh between document parses.
GetConfiguration
Element GetConfiguration(string key)
Gets the source configuration for a dynamic element key.
Parameters
Name | Type | Description |
---|---|---|
key |
string |
The dynamic element key to lookup |
Returns
The source configuration element, or null if not found
Resolve
string Resolve(string key)
Resolves a dynamic element key using the configured source and registered handlers.
Parameters
Name | Type | Description |
---|---|---|
key |
string |
The dynamic element key to resolve |
Returns
The resolved value, or null if not found or cannot be resolved
SetConfigurations
void SetConfigurations(Dictionary<string, Element> configurations)
Sets the dynamic source configurations from a dynamicSource PI.
Parameters
Name | Type | Description |
---|---|---|
configurations |
Dictionary<string, Element> |
The source configurations to register |
Interface: IXferParser
Defines the contract for XferLang parsers that convert XferLang text into document objects.
Properties
Name | Type | Description |
---|---|---|
Encoding |
Encoding |
Gets the text encoding used by this parser. |
Methods
Parse
XferDocument Parse(Byte[] input)
Parses XferLang content from a byte array into an XferDocument.
Parameters
Name | Type | Description |
---|---|---|
input |
Byte[] |
The byte array containing XferLang content to parse. |
Returns
An XferDocument representing the parsed content.
Parse
XferDocument Parse(string input)
Parses XferLang content from a string into an XferDocument.
Parameters
Name | Type | Description |
---|---|---|
input |
string |
The string containing XferLang content to parse. |
Returns
An XferDocument representing the parsed content.
Class: Parser
The main XferLang parser that converts XferLang text into a structured document model. Supports extensible processing instructions, element processors, and dynamic source resolution. This parser provides comprehensive parsing capabilities including ID uniqueness validation, character definition resolution, and flexible element processing.
Properties
Name | Type | Description |
---|---|---|
CharDefResolver |
Func<Element, string, Nullable<int>> |
Optional: A delegate for resolving charDef keywords. Should return the codepoint for a keyword, or null if not found. |
DynamicSourceResolver |
IDynamicSourceResolver |
Gets or sets the dynamic source resolver used for resolving dynamic content references in XferLang documents. If set to null, defaults to the DefaultDynamicSourceResolver implementation. |
Encoding |
Encoding |
Gets the text encoding used by this parser instance for converting byte arrays to strings. |
Methods
Constructor
Parser()
Initializes a new instance of the Parser class with UTF-8 encoding.
Constructor
Parser(Encoding encoding)
Initializes a new instance of the Parser class with the specified encoding.
Parameters
Name | Type | Description |
---|---|---|
encoding |
Encoding |
The text encoding to use for parsing input data. |
HasPIProcessor
bool HasPIProcessor(string piKey)
Check if a processing instruction processor is registered for the given key.
Parse
XferDocument Parse(string input)
Parses a string containing XferLang content into an XferDocument.
Parameters
Name | Type | Description |
---|---|---|
input |
string |
The XferLang content to parse as a string. |
Parse
XferDocument Parse(Byte[] input)
Parses a byte array containing XferLang content into an XferDocument. Uses the parser's configured encoding to convert bytes to text before parsing.
Parameters
Name | Type | Description |
---|---|---|
input |
Byte[] |
The XferLang content to parse as a byte array. |
Returns
An XferDocument containing the parsed elements and metadata.
ParseFragment
Element ParseFragment(string fragment)
Parses a standalone XferLang fragment into a single Element using a sandboxed parser state. Useful for nested parsing scenarios (e.g., interpolated content) without disturbing outer state.
Parameters
Name | Type | Description |
---|---|---|
fragment |
string |
The XferLang text representing a single element. |
Returns
The parsed Element.
ParseFragmentMany
TupleElement ParseFragmentMany(string fragment)
Parses a fragment that may contain zero or more elements; returns a TupleElement of parsed children. State is fully sandboxed and restored on exit.
Parameters
Name | Type | Description |
---|---|---|
fragment |
string |
The XferLang text with one or more elements. |
Returns
A TupleElement containing all parsed elements in order.
RegisterElementProcessor
void RegisterElementProcessor(Action<Element> processor)
Register an element processor. Called with each element as it is constructed.
RegisterPIProcessor
void RegisterPIProcessor(string piKey, Action<KeyValuePairElement> processor)
Register a PI processor. Called with each ProcessingInstruction and its parent element (if any).
RegisterPIProcessor
void RegisterPIProcessor(string piKey, PIProcessor processor)
UnregisterPIProcessor
void UnregisterPIProcessor(string piKey)
Unregister a processing instruction processor.