Delegate DtdlParseLocator
A delegate to be provided by code that uses the ModelParser for converting a parse index and line number into a source name and line number.
Namespace: DTDLParser
Assembly: DTDLParser.dll
Syntax
public delegate bool DtdlParseLocator(int parseIndex, int parseLine, out string sourceName, out int sourceLine)
Parameters
Type | Name | Description |
---|---|---|
int | parseIndex | An index into an enumeration of JSON text strings passed to the parser. |
int | parseLine | A line number within the JSON text string indicated by the parse index. |
string | sourceName | The source name corresponding to the parse index and line number. |
int | sourceLine | The soure line number corresponding to the parse index and line number. |
Returns
Type | Description |
---|---|
bool | True if the source information could be obtained. |
Remarks
This delegate is used to enhance the reporting of errors in DTDL models.
A DtdlParseLocator
can be defined and passed into either the Parse(IEnumerable<string>, DtdlParseLocator) or ParseAsync(IAsyncEnumerable<string>, DtdlParseLocator, CancellationToken) methods of a ModelParser instance.
When the ModelParser
encounters an error in a model, it calls this delegate with a parseIndex
indicating the index of a submitted text string and a parseLine
indicating a line number within this string.
If the delegate is able to convert these values into a user-meaningful location, it should set the out-parameter sourceName
to the name of the appropriate source file, URL, etc.; set the out-parameter sourceLine
to the corresponding line number within this source; and return a value of true.
If it is not able to perform the conversion, it should return a value of false.